@searchcraft/javascript-sdk 0.1.8 → 0.2.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 (173) hide show
  1. package/dist/cjs/{index-7b49313c.js → index-6c5282a0.js} +11 -5
  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_13.cjs.entry.js → searchcraft-auto-search-form_17.cjs.entry.js} +307 -30
  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 +3 -3
  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-3d577aac.js → store-ccdd30e6.js} +102 -39
  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 +5 -1
  16. package/dist/collection/components/searchcraft-auto-search-form/searchcraft-auto-search-form.js +35 -9
  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 +155 -0
  30. package/dist/collection/components/searchcraft-filters-list/searchcraft-filters-list.js.map +1 -0
  31. package/dist/collection/components/searchcraft-filters-list/searchcraft-filters-list.module.css +70 -0
  32. package/dist/collection/components/searchcraft-input/searchcraft-input.js +21 -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 +121 -0
  38. package/dist/collection/components/searchcraft-slider/searchcraft-slider.js.map +1 -0
  39. package/dist/collection/components/searchcraft-slider/searchcraft-slider.module.css +77 -0
  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 +92 -0
  43. package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js.map +1 -0
  44. package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.module.css +31 -0
  45. package/dist/collection/provider/store.js +31 -2
  46. package/dist/collection/provider/store.js.map +1 -1
  47. package/dist/collection/utils/utils.js +2 -2
  48. package/dist/collection/utils/utils.js.map +1 -1
  49. package/dist/components/index.js +3 -3
  50. package/dist/components/{p-85d96d9b.js → p-01c5864b.js} +2 -2
  51. package/dist/components/{p-85d96d9b.js.map → p-01c5864b.js.map} +1 -1
  52. package/dist/components/{p-6b1d0cba.js → p-0ef8f141.js} +3 -3
  53. package/dist/components/{p-6b1d0cba.js.map → p-0ef8f141.js.map} +1 -1
  54. package/dist/components/{p-c14731ca.js → p-162887a4.js} +3 -3
  55. package/dist/components/{p-c14731ca.js.map → p-162887a4.js.map} +1 -1
  56. package/dist/components/{p-3ea9ba3a.js → p-2bff6d1e.js} +4 -4
  57. package/dist/components/{p-3ea9ba3a.js.map → p-2bff6d1e.js.map} +1 -1
  58. package/dist/components/{p-04bad430.js → p-2f5acc0e.js} +3 -3
  59. package/dist/components/{p-04bad430.js.map → p-2f5acc0e.js.map} +1 -1
  60. package/dist/components/{p-781a9a8c.js → p-42f8a605.js} +3 -3
  61. package/dist/components/{p-781a9a8c.js.map → p-42f8a605.js.map} +1 -1
  62. package/dist/components/p-544b2de1.js +86 -0
  63. package/dist/components/p-544b2de1.js.map +1 -0
  64. package/dist/components/{p-d73bc01d.js → p-68ad42b5.js} +2 -2
  65. package/dist/components/{p-d73bc01d.js.map → p-68ad42b5.js.map} +1 -1
  66. package/dist/components/{p-af65953e.js → p-7498e493.js} +7 -3
  67. package/dist/components/p-7498e493.js.map +1 -0
  68. package/dist/components/{p-9c617862.js → p-80ea9602.js} +102 -39
  69. package/dist/components/p-80ea9602.js.map +1 -0
  70. package/dist/components/{p-17c94ac1.js → p-aff5cd24.js} +3 -3
  71. package/dist/components/p-aff5cd24.js.map +1 -0
  72. package/dist/components/{p-62f37242.js → p-d11d9b1f.js} +17 -12
  73. package/dist/components/p-d11d9b1f.js.map +1 -0
  74. package/dist/components/{p-d33fdd81.js → p-ee5e7a8c.js} +2 -2
  75. package/dist/components/{p-d33fdd81.js.map → p-ee5e7a8c.js.map} +1 -1
  76. package/dist/components/{p-a3ea7edc.js → p-fc0540e5.js} +2 -2
  77. package/dist/components/{p-a3ea7edc.js.map → p-fc0540e5.js.map} +1 -1
  78. package/dist/components/{p-07fba086.js → p-fd1f6c2f.js} +6 -6
  79. package/dist/components/p-fd1f6c2f.js.map +1 -0
  80. package/dist/components/searchcraft-auto-search-form.js +35 -23
  81. package/dist/components/searchcraft-auto-search-form.js.map +1 -1
  82. package/dist/components/searchcraft-base-search-form.js +14 -14
  83. package/dist/components/searchcraft-base-search-result.js +1 -1
  84. package/dist/components/searchcraft-base-search-results.js +28 -14
  85. package/dist/components/searchcraft-base-search-results.js.map +1 -1
  86. package/dist/components/searchcraft-button-icon.js +1 -1
  87. package/dist/components/searchcraft-button.js +1 -1
  88. package/dist/components/searchcraft-clear-icon-set.js +1 -1
  89. package/dist/components/searchcraft-clear-input-button.js +1 -1
  90. package/dist/components/searchcraft-error-message.js +1 -1
  91. package/dist/components/searchcraft-filters-list.d.ts +11 -0
  92. package/dist/components/searchcraft-filters-list.js +127 -0
  93. package/dist/components/searchcraft-filters-list.js.map +1 -0
  94. package/dist/components/searchcraft-input-caption.js +1 -1
  95. package/dist/components/searchcraft-input-icon.js +1 -1
  96. package/dist/components/searchcraft-input-label.js +1 -1
  97. package/dist/components/searchcraft-input.js +1 -1
  98. package/dist/components/searchcraft-results-info.d.ts +11 -0
  99. package/dist/components/searchcraft-results-info.js +64 -0
  100. package/dist/components/searchcraft-results-info.js.map +1 -0
  101. package/dist/components/searchcraft-search-icon-set.js +1 -1
  102. package/dist/components/searchcraft-slider.d.ts +11 -0
  103. package/dist/components/searchcraft-slider.js +96 -0
  104. package/dist/components/searchcraft-slider.js.map +1 -0
  105. package/dist/components/searchcraft-spinner-dark.js +1 -1
  106. package/dist/components/searchcraft-spinner-light.js +1 -1
  107. package/dist/components/searchcraft-toggle-button.d.ts +11 -0
  108. package/dist/components/searchcraft-toggle-button.js +84 -0
  109. package/dist/components/searchcraft-toggle-button.js.map +1 -0
  110. package/dist/esm/{index-e4a4f86d.js → index-0ac5bb53.js} +11 -5
  111. package/dist/esm/index-0ac5bb53.js.map +1 -0
  112. package/dist/esm/index.js +2 -2
  113. package/dist/esm/loader.js +3 -3
  114. package/dist/esm/{searchcraft-auto-search-form_13.entry.js → searchcraft-auto-search-form_17.entry.js} +304 -31
  115. package/dist/esm/searchcraft-auto-search-form_17.entry.js.map +1 -0
  116. package/dist/esm/searchcraft-base-search-form.entry.js +3 -3
  117. package/dist/esm/searchcraft-button-icon.entry.js +1 -1
  118. package/dist/esm/searchcraft-button.entry.js +2 -2
  119. package/dist/esm/searchcraft-javascript-sdk.js +3 -3
  120. package/dist/esm/{store-03dc618f.js → store-311de204.js} +102 -39
  121. package/dist/esm/store-311de204.js.map +1 -0
  122. package/dist/esm/{utils-7bff0c78.js → utils-e2076797.js} +3 -3
  123. package/dist/esm/utils-e2076797.js.map +1 -0
  124. package/dist/searchcraft-javascript-sdk/index.esm.js +1 -1
  125. package/dist/searchcraft-javascript-sdk/p-0880cfbb.js +3 -0
  126. package/dist/searchcraft-javascript-sdk/p-0880cfbb.js.map +1 -0
  127. package/dist/searchcraft-javascript-sdk/{p-98eab6f9.entry.js → p-5ec960bd.entry.js} +2 -2
  128. package/dist/searchcraft-javascript-sdk/p-6108dd80.entry.js +2 -0
  129. package/dist/searchcraft-javascript-sdk/p-6108dd80.entry.js.map +1 -0
  130. package/dist/searchcraft-javascript-sdk/p-80ea9602.js +11 -0
  131. package/dist/searchcraft-javascript-sdk/p-80ea9602.js.map +1 -0
  132. package/dist/searchcraft-javascript-sdk/{p-6c825f8c.entry.js → p-a9bac3ca.entry.js} +2 -2
  133. package/dist/searchcraft-javascript-sdk/{p-17c94ac1.js → p-aff5cd24.js} +1 -1
  134. package/dist/searchcraft-javascript-sdk/p-aff5cd24.js.map +1 -0
  135. package/dist/searchcraft-javascript-sdk/{p-6a17384e.entry.js → p-cc454542.entry.js} +2 -2
  136. package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js +1 -1
  137. package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js.map +1 -1
  138. package/dist/types/components/searchcraft-auto-search-form/searchcraft-auto-search-form.d.ts +4 -2
  139. package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +3 -1
  140. package/dist/types/components/searchcraft-filters-list/searchcraft-filters-list.d.ts +30 -0
  141. package/dist/types/components/searchcraft-input/searchcraft-input.d.ts +2 -0
  142. package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +10 -0
  143. package/dist/types/components/searchcraft-slider/searchcraft-slider.d.ts +17 -0
  144. package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +17 -0
  145. package/dist/types/components.d.ts +90 -2
  146. package/dist/types/provider/store.d.ts +17 -5
  147. package/dist/types/utils/utils.d.ts +1 -1
  148. package/package.json +1 -1
  149. package/dist/cjs/index-7b49313c.js.map +0 -1
  150. package/dist/cjs/searchcraft-auto-search-form_13.cjs.entry.js.map +0 -1
  151. package/dist/cjs/store-3d577aac.js.map +0 -1
  152. package/dist/cjs/utils-39791159.js.map +0 -1
  153. package/dist/components/p-07fba086.js.map +0 -1
  154. package/dist/components/p-17c94ac1.js.map +0 -1
  155. package/dist/components/p-62f37242.js.map +0 -1
  156. package/dist/components/p-9c617862.js.map +0 -1
  157. package/dist/components/p-af65953e.js.map +0 -1
  158. package/dist/components/p-f3af2b04.js +0 -86
  159. package/dist/components/p-f3af2b04.js.map +0 -1
  160. package/dist/esm/index-e4a4f86d.js.map +0 -1
  161. package/dist/esm/searchcraft-auto-search-form_13.entry.js.map +0 -1
  162. package/dist/esm/store-03dc618f.js.map +0 -1
  163. package/dist/esm/utils-7bff0c78.js.map +0 -1
  164. package/dist/searchcraft-javascript-sdk/p-17c94ac1.js.map +0 -1
  165. package/dist/searchcraft-javascript-sdk/p-9c617862.js +0 -11
  166. package/dist/searchcraft-javascript-sdk/p-9c617862.js.map +0 -1
  167. package/dist/searchcraft-javascript-sdk/p-bc3c001e.entry.js +0 -2
  168. package/dist/searchcraft-javascript-sdk/p-bc3c001e.entry.js.map +0 -1
  169. package/dist/searchcraft-javascript-sdk/p-e6f6972c.js +0 -3
  170. package/dist/searchcraft-javascript-sdk/p-e6f6972c.js.map +0 -1
  171. /package/dist/searchcraft-javascript-sdk/{p-98eab6f9.entry.js.map → p-5ec960bd.entry.js.map} +0 -0
  172. /package/dist/searchcraft-javascript-sdk/{p-6c825f8c.entry.js.map → p-a9bac3ca.entry.js.map} +0 -0
  173. /package/dist/searchcraft-javascript-sdk/{p-6a17384e.entry.js.map → p-cc454542.entry.js.map} +0 -0
@@ -2,35 +2,42 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-7b49313c.js');
6
- const store = require('./store-3d577aac.js');
7
- const utils = require('./utils-39791159.js');
5
+ const index = require('./index-6c5282a0.js');
6
+ const store = require('./store-ccdd30e6.js');
7
+ const utils = require('./utils-bd99e8b0.js');
8
8
  const index$1 = require('./index-5b0b9d4c.js');
9
9
 
10
- 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%}";
10
+ const searchcraftAutoSearchFormModuleCss = ":root{--font-stack:Helvetica, Arial, sans-serif}.formLTR{text-align:left;width:100%}.formRTL{text-align:right;width:100%}";
11
11
  const SearchcraftAutoSearchFormStyle0 = searchcraftAutoSearchFormModuleCss;
12
12
 
13
13
  const SearchcraftAutoSearchForm = class {
14
14
  constructor(hostRef) {
15
15
  index.registerInstance(this, hostRef);
16
16
  this.querySubmit = index.createEvent(this, "querySubmit", 7);
17
+ this.inputClearedOrNoResults = index.createEvent(this, "inputClearedOrNoResults", 7);
17
18
  this.debounceTimeout = null;
18
- this.debounceDelay = 300; // 300ms debounce delay
19
+ this.debounceDelay = 0;
19
20
  this.searchStore = store.useSearchcraftStore.getState();
20
21
  this.handleInputChange = (event) => {
21
22
  this.query = event.detail;
23
+ this.searchStore.setQuery(this.query);
24
+ this.querySubmit.emit(this.query);
25
+ };
26
+ this.handleInputKeyUp = (event) => {
27
+ const target = event.detail;
28
+ this.query = target;
29
+ this.searchStore.setQuery(this.query);
22
30
  this.querySubmit.emit(this.query);
23
- // Clear the previous debounce timeout
24
31
  if (this.debounceTimeout) {
25
32
  clearTimeout(this.debounceTimeout);
26
33
  }
27
- // Set a new debounce timeout
28
34
  this.debounceTimeout = setTimeout(() => {
29
- this.runSearch();
35
+ this.query.trim() !== '' && this.runSearch();
30
36
  }, this.debounceDelay);
31
37
  };
32
38
  this.handleClearInput = () => {
33
39
  this.query = '';
40
+ this.searchStore.setQuery('');
34
41
  if (typeof this.clearInput === 'function') {
35
42
  this.clearInput();
36
43
  }
@@ -38,22 +45,22 @@ const SearchcraftAutoSearchForm = class {
38
45
  clearTimeout(this.debounceTimeout);
39
46
  }
40
47
  this.error = false;
41
- this.searchResults = '';
48
+ this.inputClearedOrNoResults.emit();
42
49
  };
43
50
  this.runSearch = async () => {
44
51
  if (this.query.trim() === '') {
45
52
  this.error = true;
46
- this.searchResults = '';
53
+ this.inputClearedOrNoResults.emit();
47
54
  }
48
55
  else {
49
56
  this.error = false;
50
57
  this.searchStore.setQuery(this.query);
51
58
  try {
52
59
  await this.searchStore.search();
53
- this.searchResults = JSON.stringify(this.searchStore.searchResults);
54
60
  }
55
61
  catch (error) {
56
62
  this.error = true;
63
+ this.inputClearedOrNoResults.emit();
57
64
  }
58
65
  }
59
66
  };
@@ -79,13 +86,14 @@ const SearchcraftAutoSearchForm = class {
79
86
  this.error = false;
80
87
  this.isRequesting = false;
81
88
  this.query = '';
82
- this.searchResults = '';
89
+ this.searchResults = null;
83
90
  }
84
91
  componentDidLoad() {
85
92
  const searchcraft = new store.g(this.config);
86
93
  this.searchStore.initialize(searchcraft, true);
87
94
  this.unsubscribe = store.useSearchcraftStore.subscribe((state) => {
88
95
  this.isRequesting = state.isRequesting;
96
+ this.searchResults = Object.assign({}, state.searchResults);
89
97
  });
90
98
  }
91
99
  disconnectedCallback() {
@@ -94,14 +102,18 @@ const SearchcraftAutoSearchForm = class {
94
102
  }
95
103
  }
96
104
  render() {
105
+ var _a, _b, _c;
97
106
  const formClass = this.rightToLeftOrientation ? 'formRTL' : 'formLTR';
98
107
  const parsedCustomStyles = utils.parseCustomStyles(this.customStylesForInput);
99
- return (index.h("form", { key: '6b735bbdba6e7ff105d176fffa32b9431d5c4e49', class: `${formClass}`, onSubmit: this.handleFormSubmit }, index.h("searchcraft-input-label", { key: 'c7284dead137677ee7cd6aedac4dbfb38fac8c4c', label: this.labelForInput }), index.h("div", { key: 'a59294d9b406a1df9beb6264808f6e6a43cedbdd', class: 'searchContainer' }, index.h("searchcraft-input", { key: 'c1faa2d11c94ec3d4d39456612209e72fd208629', customStyles: parsedCustomStyles, "input-caption-value": this.inputCaptionValue, "is-requesting": this.isRequesting, "input-icon-height": this.inputIconHeight, "input-icon-width": this.inputIconWidth, onClearInput: this.handleClearInput, onSearchInputChange: this.handleInputChange, "placeholder-value": this.placeholderValue, query: this.query, "right-to-left-orientation": this.rightToLeftOrientation })), this.error && (index.h("searchcraft-error-message", { key: 'b8b1e5b4b212a30f07f3756c8ce33c142e520420', errorMessage: 'Please enter a search query.' }))));
108
+ 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) {
109
+ this.inputClearedOrNoResults.emit();
110
+ }
111
+ return (index.h("form", { key: '49950058e612dc1017fb56235affd3b8077b6926', class: `${formClass}`, onSubmit: this.handleFormSubmit }, index.h("searchcraft-input-label", { key: 'ce2cb4d74c139fc4f010d1ca51739c49a8e9f6c2', label: this.labelForInput }), index.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 && (index.h("searchcraft-error-message", { key: 'd1c893186af4cdb927f31b086aa7d027947c1d2c', errorMessage: 'Please enter a search query.' }))));
100
112
  }
101
113
  };
102
114
  SearchcraftAutoSearchForm.style = SearchcraftAutoSearchFormStyle0;
103
115
 
104
- 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}";
116
+ 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}";
105
117
  const SearchcraftBaseSearchResultStyle0 = searchcraftBaseSearchResultModuleCss;
106
118
 
107
119
  const SearchcraftBaseSearchResult = class {
@@ -145,16 +157,16 @@ const SearchcraftBaseSearchResult = class {
145
157
  render() {
146
158
  const isLightTheme = this.themeMode === 'light';
147
159
  const styles = this.parseStyles();
148
- return (index.h("div", { key: 'e16bae2d337d064e057645cfb0ebf52346229b83', class: this.isInteractive
160
+ return (index.h("div", { key: '91cfc671b0b99082915df3eaafa053a9a7f77929', class: this.isInteractive
149
161
  ? isLightTheme
150
162
  ? 'interactiveResultContainerLight'
151
163
  : 'interactiveResultContainerDark'
152
- : 'resultContainer', style: styles.container || {}, tabindex: '0', onClick: this.handleContainerClick, onKeyDown: this.keyDownCallback }, index.h("div", { key: 'f2154ce85febbe54956a7f28292b13113e3048dd', class: 'imageContainer' }, index.h("img", { key: '8063fa3b88ba56b9cba63ded99967c8097b8b185', alt: this.imageDescription, src: this.imageSource, style: styles.image || {}, class: isLightTheme ? 'imageLight' : 'imageDark' })), index.h("div", { key: 'e04a38165dc98b0d72f215e4252f7065db3664d6', class: 'contentContainer' }, index.h("h2", { key: '33d2d3483d7c0f4e1ae7e15ba5895a8b15b45a34', style: styles.heading || {}, class: isLightTheme ? 'headingLight' : 'headingDark' }, this.headingText), index.h("h3", { key: '9587d0acea25ede251eba3e79dba932a5565f51a', style: styles.subheading || {}, class: isLightTheme ? 'subheadingLight' : 'subheadingDark' }, this.subheadingText), index.h("p", { key: '74f55a23963d5ddc8753d68b164587865da2dd13', style: styles.primaryContent || {}, class: isLightTheme ? 'primaryContentLight' : 'primaryContentDark' }, this.primaryContent), index.h("div", { key: 'db4e498b08c7075b276e90d8ed233dd48992ecdd' }, index.h("p", { key: 'c09d3164a15452c5fbfa23a54028f2080dd56550', style: styles.secondaryContent || {}, class: isLightTheme ? 'secondaryContentLight' : 'secondaryContentDark' }, this.secondaryContent), index.h("p", { key: 'ae78c4f53d9b12d62cad6b408aad5caf103303db', style: styles.tertiaryContent || {}, class: isLightTheme ? 'tertiaryContentLight' : 'tertiaryContentDark' }, this.tertiaryContent)), this.buttonText && (index.h("button", { key: '3ea036c680f3970e9d6f1b00b3505f11e338922c', onClick: this.handleButtonClick, style: styles.button || {}, type: 'button' }, this.buttonText)))));
164
+ : 'resultContainer', style: styles.container || {}, tabindex: '0', onClick: this.handleContainerClick, onKeyDown: this.keyDownCallback }, index.h("div", { key: 'ccda236ef60aee285472155889c5490c69a86415', class: 'imageContainer' }, index.h("img", { key: 'e55d743952e2997d91f6486436e3a7955ffc1dcc', alt: this.imageDescription, src: this.imageSource, style: styles.image || {}, class: isLightTheme ? 'imageLight' : 'imageDark' })), index.h("div", { key: 'b0e831c0c7bfef46b8b6da4e84536adf3ebd7158', class: 'contentContainer' }, index.h("h2", { key: '54137612623a39d711f4e3c888bf2015b6fb9500', style: styles.heading || {}, class: isLightTheme ? 'headingLight' : 'headingDark' }, this.headingText), index.h("h3", { key: 'de46df990be3d0b5d2134d272e1766e911ab094a', style: styles.subheading || {}, class: isLightTheme ? 'subheadingLight' : 'subheadingDark' }, this.subheadingText), index.h("p", { key: 'd9e7656bc739b0dd2267f86ac51b17d9ca16da6a', style: styles.primaryContent || {}, class: isLightTheme ? 'primaryContentLight' : 'primaryContentDark' }, this.primaryContent), index.h("div", { key: 'd05813b3da29b8b21c2e370db9c0cbc7b48b9556', class: 'secondaryContentContainer' }, index.h("p", { key: 'e8d2ede937705a5bd88927779ee24e35ba2efbd8', style: styles.secondaryContent || {}, class: isLightTheme ? 'secondaryContentLight' : 'secondaryContentDark' }, this.secondaryContent), index.h("p", { key: '2f9b9f603d55bcefe8347675cb31f705b1f7a0e8', style: styles.tertiaryContent || {}, class: isLightTheme ? 'tertiaryContentLight' : 'tertiaryContentDark' }, this.tertiaryContent)), this.buttonText && (index.h("button", { key: '58724046c9704974cb3ae1c34335ebb7131b91ab', onClick: this.handleButtonClick, style: styles.button || {}, type: 'button' }, this.buttonText)))));
153
165
  }
154
166
  };
155
167
  SearchcraftBaseSearchResult.style = SearchcraftBaseSearchResultStyle0;
156
168
 
157
- 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}";
169
+ 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}";
158
170
  const SearchcraftBaseSearchResultsStyle0 = searchcraftBaseSearchResultsModuleCss;
159
171
 
160
172
  const SearchcraftBaseSearchResults = class {
@@ -162,19 +174,28 @@ const SearchcraftBaseSearchResults = class {
162
174
  index.registerInstance(this, hostRef);
163
175
  this.query = '';
164
176
  this.searchResults = null;
165
- this.searchKeys = '';
177
+ this.hasSearched = false;
178
+ this.documentAttributesForDisplay = '';
166
179
  this.customStylesForResults = {};
167
180
  this.placeAdAtStart = true;
168
181
  this.placeAdAtEnd = false;
169
182
  this.adInterval = 4;
170
183
  this.formatTime = true;
184
+ this.fallbackElement = null;
171
185
  }
172
186
  componentDidLoad() {
173
- if (!this.searchKeys || this.searchKeys.length === 0) {
174
- console.warn('No searchKeys provided; using empty keys array.');
175
- this.searchKeys = '';
187
+ if (!this.documentAttributesForDisplay ||
188
+ this.documentAttributesForDisplay.length === 0) {
189
+ console.warn('No document attributes provided; using empty keys array.');
190
+ this.documentAttributesForDisplay = '';
176
191
  }
177
192
  this.unsubscribe = store.useSearchcraftStore.subscribe((state) => {
193
+ if (state.query.length > 0) {
194
+ this.hasSearched = true;
195
+ }
196
+ else {
197
+ this.hasSearched = false;
198
+ }
178
199
  this.searchResults = Object.assign({}, state.searchResults);
179
200
  this.query = state.query;
180
201
  });
@@ -208,11 +229,14 @@ const SearchcraftBaseSearchResults = class {
208
229
  }
209
230
  render() {
210
231
  var _a, _b, _c, _d, _e, _f, _g;
232
+ if (!this.hasSearched) {
233
+ return (index.h("div", { class: 'emptyState' }, index.h("slot", { name: 'empty-search' })));
234
+ }
211
235
  if (!((_a = this.searchResults) === null || _a === void 0 ? void 0 : _a.data)) {
212
236
  console.warn('No search results data available');
213
237
  return index.h("div", { class: 'emptyState' }, "No results to display.");
214
238
  }
215
- const parsedSearchKeys = utils.parseSearchKeys(this.searchKeys);
239
+ const parsedSearchKeys = utils.parseSearchKeys(this.documentAttributesForDisplay);
216
240
  const serializedStyles = typeof this.customStylesForResults === 'string'
217
241
  ? this.customStylesForResults
218
242
  : utils.serializeStyles(this.customStylesForResults);
@@ -253,7 +277,7 @@ const SearchcraftBaseSearchResults = class {
253
277
  finalComponents.push(index.h("div", { key: 'ad-section-end', class: 'adSection' }, index.h("span", null, "##"), index.h("p", null, " Ad Impressions")));
254
278
  }
255
279
  return (index.h("div", { class: 'resultsContainer' }, finalComponents, this.query.length > 0 &&
256
- ((_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 && (index.h("searchcraft-error-message", { "error-message": `No search results found for "${this.query}" query` }))));
280
+ ((_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 && (index.h("div", { class: 'errorMessageContainer' }, index.h("searchcraft-error-message", { "error-message": `No search results found for "${this.query}" query` })))));
257
281
  }
258
282
  };
259
283
  SearchcraftBaseSearchResults.style = SearchcraftBaseSearchResultsStyle0;
@@ -279,7 +303,7 @@ const SearchcraftClearIconSet = class {
279
303
  }
280
304
  };
281
305
 
282
- 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}";
306
+ 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}";
283
307
  const SearchcraftClearInputButtonStyle0 = searchcraftClearInputButtonModuleCss;
284
308
 
285
309
  const SearchcraftClearInputButton = class {
@@ -315,11 +339,104 @@ const SearchcraftErrorMessage = class {
315
339
  }
316
340
  render() {
317
341
  const errorMessageStyle = this.theme === 'light' ? 'errorMessageLight' : 'errorMessageDark';
318
- return (index.h("p", { key: 'f520ac38f2f42e9780454aef5e25576095ae5ee9', class: index$1.classNames(errorMessageStyle) }, this.errorMessage || 'Search term is required.'));
342
+ return (index.h("p", { key: '544903d700810ed5d6efdefedab646cafed2376d', class: index$1.classNames(errorMessageStyle) }, this.errorMessage || 'Search term is required.'));
319
343
  }
320
344
  };
321
345
  SearchcraftErrorMessage.style = SearchcraftErrorMessageStyle0;
322
346
 
347
+ 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:\"✔\"}";
348
+ const SearchcraftFiltersListStyle0 = searchcraftFiltersListModuleCss;
349
+
350
+ const SearchcraftFiltersList = class {
351
+ constructor(hostRef) {
352
+ index.registerInstance(this, hostRef);
353
+ this.filtersUpdated = index.createEvent(this, "filtersUpdated", 7);
354
+ this.searchStore = store.useSearchcraftStore.getState();
355
+ this.handleFilterChange = (value, checked) => {
356
+ if (checked) {
357
+ this.selectedFilters.add(value);
358
+ }
359
+ else {
360
+ this.selectedFilters.delete(value);
361
+ }
362
+ const selectedFiltersArray = Array.from(this.selectedFilters);
363
+ this.filtersUpdated.emit(selectedFiltersArray);
364
+ this.searchStore.setSelectedFilters(selectedFiltersArray);
365
+ this.searchStore.search();
366
+ };
367
+ this.filters = [];
368
+ this.dynamicFilters = [];
369
+ this.initialFilters = [];
370
+ this.isRequesting = false;
371
+ this.selectedFilters = new Set();
372
+ this.originalFilterCounts = {};
373
+ this.query = '';
374
+ this.resultsCount = 0;
375
+ }
376
+ connectedCallback() {
377
+ this.unsubscribe = store.useSearchcraftStore.subscribe((state) => {
378
+ var _a, _b, _c, _d;
379
+ this.isRequesting = state.isRequesting;
380
+ this.query = state.query || '';
381
+ 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;
382
+ const facets = (_d = state.searchResults) === null || _d === void 0 ? void 0 : _d.data.facets;
383
+ if (facets) {
384
+ this.populateFiltersFromFacets(facets);
385
+ }
386
+ });
387
+ }
388
+ disconnectedCallback() {
389
+ if (this.unsubscribe) {
390
+ this.unsubscribe();
391
+ }
392
+ }
393
+ populateFiltersFromFacets(facets) {
394
+ var _a;
395
+ const newFilters = Object.entries(((_a = facets.section) === null || _a === void 0 ? void 0 : _a.counts) || {}).map(([key, count]) => {
396
+ const filterValue = key;
397
+ this.originalFilterCounts[filterValue] = `${count}`;
398
+ return {
399
+ label: `${key.replace(/^\//, '')} (${count})`,
400
+ value: filterValue,
401
+ };
402
+ });
403
+ // Update dynamic filters while preserving the initial filters
404
+ const updatedFilters = [
405
+ ...this.initialFilters,
406
+ ...newFilters.filter((filter) => !this.initialFilters.some((initial) => initial.value === filter.value)),
407
+ ];
408
+ this.dynamicFilters = updatedFilters;
409
+ // Store the initial filters only once
410
+ if (this.initialFilters.length === 0) {
411
+ this.initialFilters = [...updatedFilters];
412
+ }
413
+ }
414
+ formatLabel(label) {
415
+ return label
416
+ .replace(/-/g, ' ') // Replace dashes with spaces
417
+ .split(' ') // Split words
418
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) // Capitalize the first letter
419
+ .join(' '); // Join words back into a single string
420
+ }
421
+ render() {
422
+ if (!this.query || this.resultsCount === 0) {
423
+ return null;
424
+ }
425
+ const filtersToRender = this.initialFilters.map((initialFilter) => {
426
+ const isChecked = this.selectedFilters.has(initialFilter.value);
427
+ const dynamicChildren = this.dynamicFilters.filter((dynamicFilter) => dynamicFilter.value.startsWith(initialFilter.value) &&
428
+ dynamicFilter.value !== initialFilter.value);
429
+ return Object.assign(Object.assign({}, initialFilter), { isChecked, children: dynamicChildren });
430
+ });
431
+ return (index.h("div", { class: 'filtersList' }, filtersToRender.map((filter) => (index.h("div", { key: filter.value }, index.h("label", { class: 'checkboxLabel' }, index.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 &&
432
+ filter.children.map((childFilter) => {
433
+ const childLabel = childFilter.label.split('/').pop(); // Get only the part after the last '/'
434
+ return (index.h("label", { class: 'childCheckboxLabel', key: childFilter.value, style: { marginLeft: '20px' } }, index.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 || '')));
435
+ }))))));
436
+ }
437
+ };
438
+ SearchcraftFiltersList.style = SearchcraftFiltersListStyle0;
439
+
323
440
  const searchcraftInputModuleCss = ":root{--font-stack:Helvetica, Arial, sans-serif}.inputContainerLTR{position:relative;width:100%}.inputContainerRTL{position:relative;width:100%;margin-left:8px}.inputLightLTR{border:none;border-radius:8px;font-family:var(--font-stack);outline:none;padding-bottom:15px;padding-top:15px;width:100%;background-color:#EDEDED;color:#292929;margin-right:8px;padding-left:36px;padding-right:16px}.inputLightLTR::placeholder{font-family:var(--font-stack);font-size:16px}.inputLightLTR::placeholder{color:#737373}.inputLightLTR:focus{outline:2px solid #000}.inputDarkLTR{border:none;border-radius:8px;font-family:var(--font-stack);outline:none;padding-bottom:15px;padding-top:15px;width:100%;background-color:#1A1A1A;color:#FFF;margin-right:8px;padding-left:36px;padding-right:16px}.inputDarkLTR::placeholder{font-family:var(--font-stack);font-size:16px}.inputDarkLTR::placeholder{color:#BFBFBF}.inputDarkLTR:focus{outline:2px solid #FFF}.inputErrorLightLTR{border:none;border-radius:8px;font-family:var(--font-stack);outline:none;padding-bottom:15px;padding-top:15px;width:100%;background-color:#EDEDED;color:#292929;outline:2px solid #c00;margin-right:8px;padding-left:36px;padding-right:16px}.inputErrorLightLTR::placeholder{font-family:var(--font-stack);font-size:16px}.inputErrorLightLTR::placeholder{color:#737373}.inputErrorLightLTR:focus{outline:2px solid #000}.inputErrorLightLTR:focus-visible{outline:2px solid #c00}.inputErrorDarkLTR{border:none;border-radius:8px;font-family:var(--font-stack);outline:none;padding-bottom:15px;padding-top:15px;width:100%;background-color:#1A1A1A;color:#FFF;outline:2px solid #FFB3B3;margin-right:8px;padding-left:36px;padding-right:16px}.inputErrorDarkLTR::placeholder{font-family:var(--font-stack);font-size:16px}.inputErrorDarkLTR::placeholder{color:#BFBFBF}.inputErrorDarkLTR:focus{outline:2px solid #FFF}.inputErrorDarkLTR:focus-visible{outline:2px solid #FFB3B3}.inputLightRTL{border:none;border-radius:8px;font-family:var(--font-stack);outline:none;padding-bottom:15px;padding-top:15px;width:100%;background-color:#EDEDED;color:#292929;margin-left:8px;padding-left:16px;padding-right:36px;text-align:right}.inputLightRTL::placeholder{font-family:var(--font-stack);font-size:16px}.inputLightRTL::placeholder{color:#737373}.inputLightRTL:focus{outline:2px solid #000}.inputDarkRTL{border:none;border-radius:8px;font-family:var(--font-stack);outline:none;padding-bottom:15px;padding-top:15px;width:100%;background-color:#1A1A1A;color:#FFF;margin-left:8px;padding-left:16px;padding-right:36px;text-align:right}.inputDarkRTL::placeholder{font-family:var(--font-stack);font-size:16px}.inputDarkRTL::placeholder{color:#BFBFBF}.inputDarkRTL:focus{outline:2px solid #FFF}.inputErrorLightRTL{border:none;border-radius:8px;font-family:var(--font-stack);outline:none;padding-bottom:15px;padding-top:15px;width:100%;background-color:#EDEDED;color:#292929;outline:2px solid #c00;margin-left:8px;padding-left:16px;padding-right:36px;text-align:right}.inputErrorLightRTL::placeholder{font-family:var(--font-stack);font-size:16px}.inputErrorLightRTL::placeholder{color:#737373}.inputErrorLightRTL:focus{outline:2px solid #000}.inputErrorLightRTL:focus-visible{outline:2px solid #c00}.inputErrorDarkRTL{border:none;border-radius:8px;font-family:var(--font-stack);outline:none;padding-bottom:15px;padding-top:15px;width:100%;background-color:#1A1A1A;color:#FFF;outline:2px solid #FFB3B3;margin-left:8px;padding-left:16px;padding-right:36px;text-align:right}.inputErrorDarkRTL::placeholder{font-family:var(--font-stack);font-size:16px}.inputErrorDarkRTL::placeholder{color:#BFBFBF}.inputErrorDarkRTL:focus{outline:2px solid #FFF}.inputErrorDarkRTL:focus-visible{outline:2px solid #FFB3B3}.inputWrapper{align-items:center;display:flex;position:relative;width:100%}";
324
441
  const SearchcraftInputStyle0 = searchcraftInputModuleCss;
325
442
 
@@ -328,6 +445,7 @@ const SearchcraftInput = class {
328
445
  index.registerInstance(this, hostRef);
329
446
  this.clearInput = index.createEvent(this, "clearInput", 7);
330
447
  this.searchInputChange = index.createEvent(this, "searchInputChange", 7);
448
+ this.inputKeyUp = index.createEvent(this, "inputKeyUp", 7);
331
449
  this.customStyles = {};
332
450
  this.error = false;
333
451
  this.formClassName = '';
@@ -349,6 +467,10 @@ const SearchcraftInput = class {
349
467
  const input = event.target;
350
468
  this.searchInputChange.emit(input.value);
351
469
  }
470
+ handleInputKeyUp(event) {
471
+ const input = event.target;
472
+ this.inputKeyUp.emit(input.value);
473
+ }
352
474
  handleClearInput() {
353
475
  if (this.clearInput) {
354
476
  this.clearInput.emit();
@@ -369,11 +491,11 @@ const SearchcraftInput = class {
369
491
  const placeholderStyle = {
370
492
  fontSize: validatedCustomStyles.placeholderFontSize || '16px',
371
493
  };
372
- return (index.h("div", { key: '41f29f98e95d5811e81dd885cd282cd8f50cb776', class: index$1.classNames(containerClassName, this.formClassName, 'searchcraft-input-form') }, this.rightToLeftOrientation ? (index.h(index.Fragment, null, index.h("input", { class: index$1.classNames(inputClassName, 'searchcraft-input'), id: 'searchcraft-input-id', onChange: this.handleInputChange.bind(this), placeholder: this.placeholderValue, type: 'text', value: this.query, style: validatedCustomStyles }), index.h("style", null, `
494
+ return (index.h("div", { key: 'ca2698b808ef606d890817f6b8c133503663570e', class: index$1.classNames(containerClassName, this.formClassName, 'searchcraft-input-form') }, this.rightToLeftOrientation ? (index.h(index.Fragment, null, index.h("input", { autoComplete: 'off', class: index$1.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 }), index.h("style", null, `
373
495
  #searchcraft-input-id::placeholder {
374
496
  font-size: ${placeholderStyle.fontSize};
375
497
  }
376
- `), this.inputCaptionValue && (index.h("searchcraft-input-caption", { inputCaptionClassName: this.inputCaptionClassName, inputCaptionValue: this.inputCaptionValue, rightToLeftOrientation: this.rightToLeftOrientation })), this.query.length > 0 && (index.h("searchcraft-clear-input-button", { isRequesting: this.isRequesting, onClearInput: this.handleClearInput, rightToLeftOrientation: this.rightToLeftOrientation })), index.h("searchcraft-input-icon", { error: this.error, height: this.inputIconHeight, rightToLeftOrientation: this.rightToLeftOrientation, width: this.inputIconWidth }))) : (index.h("div", { class: 'inputWrapper' }, index.h("searchcraft-input-icon", { error: this.error, height: this.inputIconHeight, rightToLeftOrientation: this.rightToLeftOrientation, width: this.inputIconWidth }), index.h("input", { class: index$1.classNames(inputClassName, 'searchcraft-input'), id: 'searchcraft-input-id', onChange: this.handleInputChange.bind(this), placeholder: this.placeholderValue, type: 'text', value: this.query, style: validatedCustomStyles }), index.h("style", null, `
498
+ `), this.inputCaptionValue && (index.h("searchcraft-input-caption", { inputCaptionClassName: this.inputCaptionClassName, inputCaptionValue: this.inputCaptionValue, rightToLeftOrientation: this.rightToLeftOrientation })), this.query.length > 0 && (index.h("searchcraft-clear-input-button", { isRequesting: this.isRequesting, onClearInput: this.handleClearInput, rightToLeftOrientation: this.rightToLeftOrientation })), index.h("searchcraft-input-icon", { error: this.error, height: this.inputIconHeight, rightToLeftOrientation: this.rightToLeftOrientation, width: this.inputIconWidth }))) : (index.h(index.Fragment, null, index.h("searchcraft-input-icon", { error: this.error, height: this.inputIconHeight, rightToLeftOrientation: this.rightToLeftOrientation, width: this.inputIconWidth }), index.h("input", { autoComplete: 'off', class: index$1.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 }), index.h("style", null, `
377
499
  #searchcraft-input-id::placeholder {
378
500
  font-size: ${placeholderStyle.fontSize};
379
501
  }
@@ -460,6 +582,40 @@ const SearchcraftInputLabel = class {
460
582
  };
461
583
  SearchcraftInputLabel.style = SearchcraftInputLabelStyle0;
462
584
 
585
+ 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}";
586
+ const SearchcraftResultsInfoStyle0 = searchcraftResultsInfoModuleCss;
587
+
588
+ const SearchcraftResultsInfo = class {
589
+ constructor(hostRef) {
590
+ index.registerInstance(this, hostRef);
591
+ this.isRequesting = false;
592
+ this.resultsCount = 0;
593
+ this.responseTime = '';
594
+ this.query = '';
595
+ }
596
+ connectedCallback() {
597
+ this.unsubscribe = store.useSearchcraftStore.subscribe((state) => {
598
+ var _a, _b, _c, _d;
599
+ this.isRequesting = state.isRequesting;
600
+ this.resultsCount = ((_b = (_a = state.searchResults) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.count) || 0;
601
+ 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);
602
+ this.query = state.query || ''; // Update query from store
603
+ });
604
+ }
605
+ disconnectedCallback() {
606
+ if (this.unsubscribe) {
607
+ this.unsubscribe();
608
+ }
609
+ }
610
+ render() {
611
+ if (!this.query || this.resultsCount === 0) {
612
+ return null;
613
+ }
614
+ return (index.h("div", { class: 'container' }, index.h("p", { class: 'resultsInfo' }, this.resultsCount, " results found in ", this.responseTime, "ms")));
615
+ }
616
+ };
617
+ SearchcraftResultsInfo.style = SearchcraftResultsInfoStyle0;
618
+
463
619
  const SearchcraftSearchIconSet = class {
464
620
  constructor(hostRef) {
465
621
  index.registerInstance(this, hostRef);
@@ -484,6 +640,69 @@ const SearchcraftSearchIconSet = class {
484
640
  }
485
641
  };
486
642
 
643
+ 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}";
644
+ const SearchcraftSliderStyle0 = searchcraftSliderModuleCss;
645
+
646
+ const SearchcraftSlider = class {
647
+ constructor(hostRef) {
648
+ index.registerInstance(this, hostRef);
649
+ this.searchStore = store.useSearchcraftStore.getState();
650
+ this.updateYears = async () => {
651
+ this.searchStore.setYearsRange([this.startYear, this.endYear]);
652
+ try {
653
+ if (typeof this.query === 'string' && this.query.trim() !== '') {
654
+ await this.searchStore.search();
655
+ }
656
+ else {
657
+ console.warn('Query is missing or empty, skipping search request.');
658
+ }
659
+ }
660
+ catch (error) {
661
+ console.error('Search failed:', error);
662
+ }
663
+ };
664
+ this.handleStartYearChange = (event) => {
665
+ const value = Number.parseInt(event.target.value, 10);
666
+ this.startYear = Math.min(value, this.endYear);
667
+ this.updateYears();
668
+ };
669
+ this.handleEndYearChange = (event) => {
670
+ const value = Number.parseInt(event.target.value, 10);
671
+ this.endYear = Math.max(value, this.startYear);
672
+ this.updateYears();
673
+ };
674
+ this.minYear = 2000;
675
+ this.maxYear = new Date().getFullYear();
676
+ this.endYear = this.maxYear;
677
+ this.query = '';
678
+ this.startYear = this.minYear;
679
+ this.hasSearched = false;
680
+ this.resultsCount = 0;
681
+ }
682
+ componentDidLoad() {
683
+ this.unsubscribe = store.useSearchcraftStore.subscribe((state) => {
684
+ var _a, _b, _c;
685
+ if (state.query.length > 0) {
686
+ this.hasSearched = true;
687
+ 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;
688
+ }
689
+ this.query = state.query;
690
+ });
691
+ }
692
+ disconnectedCallback() {
693
+ if (this.unsubscribe) {
694
+ this.unsubscribe();
695
+ }
696
+ }
697
+ render() {
698
+ if (!this.query || this.resultsCount === 0) {
699
+ return null;
700
+ }
701
+ return (index.h("div", { class: 'slider-container' }, index.h("div", { class: 'range-container' }, index.h("input", { class: 'range-slider', max: this.maxYear, min: this.minYear, onInput: this.handleStartYearChange, step: '1', type: 'range', value: this.startYear }), index.h("input", { class: 'range-slider', max: this.maxYear, min: this.minYear, onInput: this.handleEndYearChange, step: '1', type: 'range', value: this.endYear })), index.h("div", { class: 'year-labels' }, index.h("span", { class: 'year-label' }, this.startYear), index.h("span", { class: 'year-label' }, this.endYear))));
702
+ }
703
+ };
704
+ SearchcraftSlider.style = SearchcraftSliderStyle0;
705
+
487
706
  const searchcraftSpinnerDarkModuleCss = ".spinnerContainer{background-color:transparent;height:20px;width:20px}.spinnerDark{height:100%;width:100%;background:conic-gradient(#000 50%, #FFFFFF);clip-path:circle(50%);mask-image:radial-gradient(circle at center, rgba(0, 0, 0, 0) 6.6666666667px, rgb(0, 0, 0) 6.6666666667px);animation:spinning 1s linear infinite}.spinnerLight{height:100%;width:100%;background:conic-gradient(#737373 50%, #FFFFFF);clip-path:circle(50%);mask-image:radial-gradient(circle at center, rgba(0, 0, 0, 0) 6.6666666667px, rgb(0, 0, 0) 6.6666666667px);animation:spinning 1s linear infinite}@keyframes spinning{0%{transform:rotate(0deg)}50%{transform:rotate(180deg)}100%{transform:rotate(360deg)}}";
488
707
  const SearchcraftSpinnerDarkStyle0 = searchcraftSpinnerDarkModuleCss;
489
708
 
@@ -492,7 +711,7 @@ const SearchcraftSpinnerDark = class {
492
711
  index.registerInstance(this, hostRef);
493
712
  }
494
713
  render() {
495
- return (index.h("div", { key: '76685b09609a42adbff41ee43ecb4b4e161d4598', class: 'spinnerContainer' }, index.h("div", { key: '7e7a01010f21e5b95358b7385d41a45e90a5b3bd', class: 'spinnerDark' })));
714
+ return (index.h("div", { key: '60b629930c2e2795236f6768b40c95ce9390e882', class: 'spinnerContainer' }, index.h("div", { key: 'bfef3329f2e81ecf6538738ac0213da6259dd1c3', class: 'spinnerDark' })));
496
715
  }
497
716
  };
498
717
  SearchcraftSpinnerDark.style = SearchcraftSpinnerDarkStyle0;
@@ -505,23 +724,81 @@ const SearchcraftSpinnerLight = class {
505
724
  index.registerInstance(this, hostRef);
506
725
  }
507
726
  render() {
508
- return (index.h("div", { key: '7bd4d997ef43d35ee60033a27b6bc46c6d693c33', class: 'spinnerContainer' }, index.h("div", { key: 'f8cc9948aa6a264719ffc54d25a10af27dc0f802', class: 'spinnerLight' })));
727
+ return (index.h("div", { key: 'ad5224c97faf7e329d2a8904488c17dfd7414b9e', class: 'spinnerContainer' }, index.h("div", { key: '6336ce7737af65eedac46ee290b20291ce5b6096', class: 'spinnerLight' })));
509
728
  }
510
729
  };
511
730
  SearchcraftSpinnerLight.style = SearchcraftSpinnerLightStyle0;
512
731
 
732
+ 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)}";
733
+ const SearchcraftToggleButtonStyle0 = searchcraftToggleButtonModuleCss;
734
+
735
+ const SearchcraftToggleButton = class {
736
+ constructor(hostRef) {
737
+ index.registerInstance(this, hostRef);
738
+ this.searchStore = store.useSearchcraftStore.getState();
739
+ this.handleToggle = async () => {
740
+ this.isActive = !this.isActive;
741
+ if (this.type === 'mode') {
742
+ const mode = this.isActive ? 'normal' : 'fuzzy';
743
+ this.searchStore.setSearchParams({
744
+ mode,
745
+ });
746
+ }
747
+ else if (this.type === 'sort') {
748
+ const sort = this.isActive ? 'desc' : 'asc';
749
+ this.searchStore.setSearchParams({
750
+ sort,
751
+ });
752
+ }
753
+ try {
754
+ await this.searchStore.search();
755
+ }
756
+ catch (error) {
757
+ console.error('Search failed:', error);
758
+ }
759
+ };
760
+ this.type = 'mode';
761
+ this.isActive = false;
762
+ this.query = '';
763
+ this.resultsCount = 0;
764
+ }
765
+ componentDidLoad() {
766
+ this.unsubscribe = store.useSearchcraftStore.subscribe((state) => {
767
+ var _a, _b, _c;
768
+ this.query = state.query || '';
769
+ 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;
770
+ });
771
+ }
772
+ disconnectedCallback() {
773
+ if (this.unsubscribe) {
774
+ this.unsubscribe();
775
+ }
776
+ }
777
+ render() {
778
+ if (!this.query || this.resultsCount === 0) {
779
+ return null;
780
+ }
781
+ return (index.h("button", { class: `toggle-wrapper ${this.isActive ? 'active' : ''}`, onClick: this.handleToggle, type: 'button' }, index.h("div", { class: `toggle-switch ${this.isActive ? 'active' : ''}` })));
782
+ }
783
+ };
784
+ SearchcraftToggleButton.style = SearchcraftToggleButtonStyle0;
785
+
513
786
  exports.searchcraft_auto_search_form = SearchcraftAutoSearchForm;
514
787
  exports.searchcraft_base_search_result = SearchcraftBaseSearchResult;
515
788
  exports.searchcraft_base_search_results = SearchcraftBaseSearchResults;
516
789
  exports.searchcraft_clear_icon_set = SearchcraftClearIconSet;
517
790
  exports.searchcraft_clear_input_button = SearchcraftClearInputButton;
518
791
  exports.searchcraft_error_message = SearchcraftErrorMessage;
792
+ exports.searchcraft_filters_list = SearchcraftFiltersList;
519
793
  exports.searchcraft_input = SearchcraftInput;
520
794
  exports.searchcraft_input_caption = SearchcraftInputCaption;
521
795
  exports.searchcraft_input_icon = SearchcraftInputIcon;
522
796
  exports.searchcraft_input_label = SearchcraftInputLabel;
797
+ exports.searchcraft_results_info = SearchcraftResultsInfo;
523
798
  exports.searchcraft_search_icon_set = SearchcraftSearchIconSet;
799
+ exports.searchcraft_slider = SearchcraftSlider;
524
800
  exports.searchcraft_spinner_dark = SearchcraftSpinnerDark;
525
801
  exports.searchcraft_spinner_light = SearchcraftSpinnerLight;
802
+ exports.searchcraft_toggle_button = SearchcraftToggleButton;
526
803
 
527
- //# sourceMappingURL=searchcraft-auto-search-form_13.cjs.entry.js.map
804
+ //# sourceMappingURL=searchcraft-auto-search-form_17.cjs.entry.js.map