@searchcraft/javascript-sdk 0.2.4 → 0.2.5
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.
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/searchcraft-auto-search-form_17.cjs.entry.js +63 -43
- package/dist/cjs/searchcraft-auto-search-form_17.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-base-search-form.cjs.entry.js +1 -1
- package/dist/cjs/searchcraft-javascript-sdk.cjs.js +1 -1
- package/dist/cjs/{store-b0a26894.js → store-c44c58ab.js} +8 -7
- package/dist/cjs/{store-b0a26894.js.map → store-c44c58ab.js.map} +1 -1
- package/dist/cjs/{utils-15f85bca.js → utils-2dc6115c.js} +13 -1
- package/dist/cjs/utils-2dc6115c.js.map +1 -0
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js +24 -3
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js.map +1 -1
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.module.css +0 -2
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js +20 -1
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js.map +1 -1
- package/dist/collection/components/searchcraft-filters-list/searchcraft-filters-list.js +54 -39
- package/dist/collection/components/searchcraft-filters-list/searchcraft-filters-list.js.map +1 -1
- package/dist/collection/provider/store.js +7 -6
- package/dist/collection/provider/store.js.map +1 -1
- package/dist/collection/utils/utils.js +11 -0
- package/dist/collection/utils/utils.js.map +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/{p-33bb5c45.js → p-157e5b1a.js} +8 -7
- package/dist/components/{p-33bb5c45.js.map → p-157e5b1a.js.map} +1 -1
- package/dist/components/{p-ff6c3650.js → p-2bda632c.js} +13 -2
- package/dist/components/p-2bda632c.js.map +1 -0
- package/dist/components/{p-1204b43a.js → p-b5f97e04.js} +2 -2
- package/dist/components/{p-1204b43a.js.map → p-b5f97e04.js.map} +1 -1
- package/dist/components/{p-8c70054a.js → p-bdf281cc.js} +10 -6
- package/dist/components/p-bdf281cc.js.map +1 -0
- package/dist/components/searchcraft-auto-search-form.js +3 -3
- package/dist/components/searchcraft-base-search-form.js +2 -2
- package/dist/components/searchcraft-base-search-result.js +1 -1
- package/dist/components/searchcraft-base-search-results.js +6 -4
- package/dist/components/searchcraft-base-search-results.js.map +1 -1
- package/dist/components/searchcraft-filters-list.js +55 -40
- package/dist/components/searchcraft-filters-list.js.map +1 -1
- package/dist/components/searchcraft-input.js +1 -1
- package/dist/components/searchcraft-results-info.js +1 -1
- package/dist/components/searchcraft-slider.js +1 -1
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/searchcraft-auto-search-form_17.entry.js +63 -43
- package/dist/esm/searchcraft-auto-search-form_17.entry.js.map +1 -1
- package/dist/esm/searchcraft-base-search-form.entry.js +1 -1
- package/dist/esm/searchcraft-javascript-sdk.js +1 -1
- package/dist/esm/{store-97358312.js → store-9e0b0710.js} +8 -7
- package/dist/esm/{store-97358312.js.map → store-9e0b0710.js.map} +1 -1
- package/dist/esm/{utils-dbb6302b.js → utils-a3373179.js} +13 -2
- package/dist/esm/utils-a3373179.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/index.esm.js +1 -1
- package/dist/searchcraft-javascript-sdk/p-2bda632c.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-2bda632c.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/{p-acca6173.entry.js → p-63b3b565.entry.js} +2 -2
- package/dist/searchcraft-javascript-sdk/{p-cd489e98.js → p-901fee50.js} +2 -2
- package/dist/searchcraft-javascript-sdk/p-901fee50.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-cc9a02ef.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-cc9a02ef.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js +1 -1
- package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js.map +1 -1
- package/dist/types/components/searchcraft-base-search-result/searchcraft-base-search-result.d.ts +1 -0
- package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +1 -0
- package/dist/types/components/searchcraft-filters-list/searchcraft-filters-list.d.ts +1 -5
- package/dist/types/components.d.ts +4 -0
- package/dist/types/utils/utils.d.ts +11 -0
- package/package.json +1 -1
- package/dist/cjs/utils-15f85bca.js.map +0 -1
- package/dist/components/p-8c70054a.js.map +0 -1
- package/dist/components/p-ff6c3650.js.map +0 -1
- package/dist/esm/utils-dbb6302b.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-1a0e85ee.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-1a0e85ee.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-cd489e98.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-ff6c3650.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-ff6c3650.js.map +0 -1
- /package/dist/searchcraft-javascript-sdk/{p-acca6173.entry.js.map → p-63b3b565.entry.js.map} +0 -0
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const utils = require('./utils-
|
|
6
|
-
const store = require('./store-
|
|
5
|
+
const utils = require('./utils-2dc6115c.js');
|
|
6
|
+
const store = require('./store-c44c58ab.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
|
8
8
|
const defineCustomElements = async (win, options) => {
|
|
9
9
|
if (typeof window === 'undefined') return undefined;
|
|
10
10
|
await appGlobals.globalScripts();
|
|
11
|
-
return index.bootstrapLazy([["searchcraft-auto-search-form_17.cjs",[[1,"searchcraft-auto-search-form",{"autoSearchFormClass":[1,"auto-search-form-class"],"clearInput":[16],"config":[16],"customStylesForInput":[1,"custom-styles-for-input"],"inputCaptionValue":[1,"input-caption-value"],"inputIconHeight":[2,"input-icon-height"],"inputIconWidth":[2,"input-icon-width"],"labelForInput":[1,"label-for-input"],"placeholderValue":[1,"placeholder-value"],"rightToLeftOrientation":[4,"right-to-left-orientation"],"searchContainerClass":[1,"search-container-class"],"error":[32],"isRequesting":[32],"query":[32],"searchResults":[32]}],[1,"searchcraft-base-search-results",{"adInterval":[2,"ad-interval"],"customStylesForResults":[1,"custom-styles-for-results"],"documentAttributesForDisplay":[1,"document-attributes-for-display"],"fallbackElement":[16],"formatTime":[4,"format-time"],"placeAdAtEnd":[4,"place-ad-at-end"],"placeAdAtStart":[4,"place-ad-at-start"],"hasSearched":[32],"query":[32],"searchResults":[32]}],[1,"searchcraft-filters-list",{"filters":[16],"dynamicFilters":[32],"
|
|
11
|
+
return index.bootstrapLazy([["searchcraft-auto-search-form_17.cjs",[[1,"searchcraft-auto-search-form",{"autoSearchFormClass":[1,"auto-search-form-class"],"clearInput":[16],"config":[16],"customStylesForInput":[1,"custom-styles-for-input"],"inputCaptionValue":[1,"input-caption-value"],"inputIconHeight":[2,"input-icon-height"],"inputIconWidth":[2,"input-icon-width"],"labelForInput":[1,"label-for-input"],"placeholderValue":[1,"placeholder-value"],"rightToLeftOrientation":[4,"right-to-left-orientation"],"searchContainerClass":[1,"search-container-class"],"error":[32],"isRequesting":[32],"query":[32],"searchResults":[32]}],[1,"searchcraft-base-search-results",{"adInterval":[2,"ad-interval"],"customStylesForResults":[1,"custom-styles-for-results"],"documentAttributesForDisplay":[1,"document-attributes-for-display"],"fallbackElement":[16],"formatTime":[4,"format-time"],"placeAdAtEnd":[4,"place-ad-at-end"],"placeAdAtStart":[4,"place-ad-at-start"],"placeResultImageRight":[4,"place-result-image-right"],"hasSearched":[32],"query":[32],"searchResults":[32]}],[1,"searchcraft-filters-list",{"filters":[16],"dynamicFilters":[32],"isRequesting":[32],"query":[32],"resultsCount":[32],"selectedFilters":[32]}],[1,"searchcraft-results-info",{"isRequesting":[32],"resultsCount":[32],"responseTime":[32],"query":[32]}],[1,"searchcraft-slider",{"maxYear":[2,"max-year"],"minYear":[2,"min-year"],"endYear":[32],"hasSearched":[32],"query":[32],"resultsCount":[32],"startYear":[32]}],[1,"searchcraft-toggle-button",{"type":[1],"isActive":[32],"query":[32],"resultsCount":[32]}],[1,"searchcraft-base-search-result",{"buttonText":[1,"button-text"],"customStyles":[1,"custom-styles"],"headingText":[1,"heading-text"],"imageDescription":[1,"image-description"],"imageSource":[1,"image-source"],"isInteractive":[4,"is-interactive"],"primaryContent":[1,"primary-content"],"secondaryContent":[1,"secondary-content"],"subheadingText":[1,"subheading-text"],"tertiaryContent":[1,"tertiary-content"],"themeMode":[1,"theme-mode"],"placeImageRight":[4,"place-image-right"]}],[1,"searchcraft-input",{"customStyles":[1,"custom-styles"],"error":[4],"formClassName":[1,"form-class-name"],"inputCaptionClassName":[1,"input-caption-class-name"],"inputCaptionValue":[1,"input-caption-value"],"inputClassName":[1,"input-class-name"],"inputIconHeight":[2,"input-icon-height"],"inputIconWidth":[2,"input-icon-width"],"isRequesting":[4,"is-requesting"],"placeholderValue":[1,"placeholder-value"],"rightToLeftOrientation":[4,"right-to-left-orientation"],"query":[1],"theme":[32]}],[1,"searchcraft-input-label",{"inputLabelClassName":[1,"input-label-class-name"],"label":[1],"theme":[32]}],[1,"searchcraft-clear-input-button",{"isRequesting":[4,"is-requesting"],"rightToLeftOrientation":[4,"right-to-left-orientation"],"theme":[32]}],[1,"searchcraft-input-icon",{"error":[4],"height":[2],"rightToLeftOrientation":[4,"right-to-left-orientation"],"width":[2],"theme":[32]}],[1,"searchcraft-error-message",{"errorMessage":[1,"error-message"],"theme":[1]}],[1,"searchcraft-input-caption",{"error":[4],"inputCaptionClassName":[1,"input-caption-class-name"],"inputCaptionValue":[1,"input-caption-value"],"rightToLeftOrientation":[4,"right-to-left-orientation"],"theme":[32]}],[1,"searchcraft-clear-icon-set",{"type":[1]}],[1,"searchcraft-search-icon-set",{"type":[1],"width":[2],"height":[2]}],[1,"searchcraft-spinner-light"],[1,"searchcraft-spinner-dark"]]],["searchcraft-base-search-form.cjs",[[1,"searchcraft-base-search-form",{"config":[16],"errorMessage":[1,"error-message"],"labelForInput":[1,"label-for-input"],"rightToLeftOrientation":[4,"right-to-left-orientation"],"error":[32],"query":[32],"searchResults":[32]}]]],["searchcraft-button-icon.cjs",[[1,"searchcraft-button-icon"]]],["searchcraft-button.cjs",[[1,"searchcraft-button",{"iconElement":[16],"iconOnly":[4,"icon-only"],"iconPosition":[1,"icon-position"],"label":[1],"isRequesting":[32],"theme":[32]}]]]], options);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.setNonce = index.setNonce;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-6c5282a0.js');
|
|
6
|
-
const store = require('./store-
|
|
7
|
-
const utils = require('./utils-
|
|
6
|
+
const store = require('./store-c44c58ab.js');
|
|
7
|
+
const utils = require('./utils-2dc6115c.js');
|
|
8
8
|
const index$1 = require('./index-5b0b9d4c.js');
|
|
9
9
|
|
|
10
10
|
const searchcraftAutoSearchFormModuleCss = ":root{--font-stack:Helvetica, Arial, sans-serif}.formLTR{font-family:var(--font-stack);text-align:left;width:100%}.formRTL{font-family:var(--font-stack);text-align:right;width:100%}";
|
|
@@ -113,7 +113,7 @@ const SearchcraftAutoSearchForm = class {
|
|
|
113
113
|
};
|
|
114
114
|
SearchcraftAutoSearchForm.style = SearchcraftAutoSearchFormStyle0;
|
|
115
115
|
|
|
116
|
-
const searchcraftBaseSearchResultModuleCss = "@charset \"UTF-8\";:root{--font-stack:Helvetica, Arial, sans-serif}.interactiveResultContainerLight{align-items:flex-start;border-radius:16px;display:flex;flex-direction:column;gap:16px;padding:8px;position:relative;background-color:#FAFAFA}@media (min-width: 600px){.interactiveResultContainerLight{flex-direction:row}}.interactiveResultContainerDark{align-items:flex-start;border-radius:16px;display:flex;flex-direction:column;gap:16px;padding:8px;position:relative;background-color:#2E2E2E}@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{display:inline-block;position:absolute;right:5px;top:-2px}@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{
|
|
116
|
+
const searchcraftBaseSearchResultModuleCss = "@charset \"UTF-8\";:root{--font-stack:Helvetica, Arial, sans-serif}.interactiveResultContainerLight{align-items:flex-start;border-radius:16px;display:flex;flex-direction:column;gap:16px;padding:8px;position:relative;background-color:#FAFAFA}@media (min-width: 600px){.interactiveResultContainerLight{flex-direction:row}}.interactiveResultContainerDark{align-items:flex-start;border-radius:16px;display:flex;flex-direction:column;gap:16px;padding:8px;position:relative;background-color:#2E2E2E}@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{display:inline-block;position:absolute;right:5px;top:-2px}@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{border-radius:8px;max-height:100%;max-width:100%;border:1px solid #D9D9D9}.imageDark{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:0;position:relative;color:#292929}.headingDark{font-family:var(--font-stack);font-size:16px;font-weight:700;line-height:20px;margin-bottom:4px;margin-top:0;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}";
|
|
117
117
|
const SearchcraftBaseSearchResultStyle0 = searchcraftBaseSearchResultModuleCss;
|
|
118
118
|
|
|
119
119
|
const SearchcraftBaseSearchResult = class {
|
|
@@ -144,6 +144,7 @@ const SearchcraftBaseSearchResult = class {
|
|
|
144
144
|
this.subheadingText = '';
|
|
145
145
|
this.tertiaryContent = '';
|
|
146
146
|
this.themeMode = 'light';
|
|
147
|
+
this.placeImageRight = false;
|
|
147
148
|
}
|
|
148
149
|
parseStyles() {
|
|
149
150
|
try {
|
|
@@ -157,11 +158,13 @@ const SearchcraftBaseSearchResult = class {
|
|
|
157
158
|
render() {
|
|
158
159
|
const isLightTheme = this.themeMode === 'light';
|
|
159
160
|
const styles = this.parseStyles();
|
|
160
|
-
|
|
161
|
+
const imageContainer = (index.h("div", { key: '83bd0ac730469f4004ac4024c749cd66edfbf7c7', class: 'imageContainer' }, index.h("img", { key: 'e379c01b45808499d6ac78557294e9c408b1734f', alt: this.imageDescription, class: isLightTheme ? 'imageLight' : 'imageDark', src: this.imageSource, style: styles.image || {} })));
|
|
162
|
+
const contentContainer = (index.h("div", { key: '1847892cef75ecb2179178ec17217376c523b1b2', class: 'contentContainer' }, index.h("h2", { key: '16f6c8dac748fa2b99575eb4b8bcf217a7452ea0', class: isLightTheme ? 'headingLight' : 'headingDark', style: styles.heading || {} }, this.headingText), index.h("h3", { key: '3539e9fc9b2e567d5cb088b4ae77307f03fb47d1', class: isLightTheme ? 'subheadingLight' : 'subheadingDark', style: styles.subheading || {} }, this.subheadingText), index.h("p", { key: '20beff8ed55ca1c18cef587f4306b50829c81775', class: isLightTheme ? 'primaryContentLight' : 'primaryContentDark', style: styles.primaryContent || {} }, this.primaryContent), index.h("div", { key: 'd79107bd79de978f64906db23aa14c533132f369', class: 'secondaryContentContainer' }, index.h("p", { key: '978f7176d8fa3372a1360a516640d8334ffe9612', class: isLightTheme ? 'secondaryContentLight' : 'secondaryContentDark', style: styles.secondaryContent || {} }, this.secondaryContent), index.h("p", { key: '08e70740d73f78ef10769f882ac4ddf80545fac2', class: isLightTheme ? 'tertiaryContentLight' : 'tertiaryContentDark', style: styles.tertiaryContent || {} }, this.tertiaryContent)), this.buttonText && (index.h("button", { key: '3f3bfe27e824829e86764445ad9c0cd66bfeae92', onClick: this.handleButtonClick, style: styles.button || {}, type: 'button' }, this.buttonText))));
|
|
163
|
+
return (index.h("div", { key: 'f6dc4ad85634cef131ffc85d574ef35a862f9d77', class: this.isInteractive
|
|
161
164
|
? isLightTheme
|
|
162
165
|
? 'interactiveResultContainerLight'
|
|
163
166
|
: 'interactiveResultContainerDark'
|
|
164
|
-
: 'resultContainer', onKeyDown: this.keyDownCallback, onClick: this.handleContainerClick, style: styles.container || {}, tabindex: '0' },
|
|
167
|
+
: 'resultContainer', onKeyDown: this.keyDownCallback, onClick: this.handleContainerClick, style: styles.container || {}, tabindex: '0' }, this.placeImageRight ? (index.h(index.Fragment, null, contentContainer, imageContainer)) : (index.h(index.Fragment, null, imageContainer, contentContainer))));
|
|
165
168
|
}
|
|
166
169
|
};
|
|
167
170
|
SearchcraftBaseSearchResult.style = SearchcraftBaseSearchResultStyle0;
|
|
@@ -179,6 +182,7 @@ const SearchcraftBaseSearchResults = class {
|
|
|
179
182
|
this.formatTime = true;
|
|
180
183
|
this.placeAdAtEnd = false;
|
|
181
184
|
this.placeAdAtStart = true;
|
|
185
|
+
this.placeResultImageRight = false;
|
|
182
186
|
this.hasSearched = false;
|
|
183
187
|
this.query = '';
|
|
184
188
|
this.searchResults = null;
|
|
@@ -236,7 +240,7 @@ const SearchcraftBaseSearchResults = class {
|
|
|
236
240
|
}
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
|
-
return (index.h("searchcraft-base-search-result", { "button-callback": () => console.log('button callback'), "custom-styles": serializedStyles, "image-source": dynamicProperties[parsedSearchKeys[parsedSearchKeys.length - 1]], "is-interactive": true, key: `${document.document_id}-${index$1}`, "keydown-callback": () => console.log('keydown'), "heading-text": dynamicProperties[parsedSearchKeys[0]], "primary-content": dynamicProperties[parsedSearchKeys[2]], "result-callback": () => console.log('interactive element'), "secondary-content": dynamicProperties[parsedSearchKeys[3]], "subheading-text": dynamicProperties[parsedSearchKeys[1]], "tertiary-content": dynamicProperties[parsedSearchKeys[4]] }));
|
|
243
|
+
return (index.h("searchcraft-base-search-result", { "button-callback": () => console.log('button callback'), "custom-styles": serializedStyles, "image-source": dynamicProperties[parsedSearchKeys[parsedSearchKeys.length - 1]], "is-interactive": true, key: `${document.document_id}-${index$1}`, "keydown-callback": () => console.log('keydown'), "heading-text": dynamicProperties[parsedSearchKeys[0]], "place-image-right": this.placeResultImageRight, "primary-content": dynamicProperties[parsedSearchKeys[2]], "result-callback": () => console.log('interactive element'), "secondary-content": dynamicProperties[parsedSearchKeys[3]], "subheading-text": dynamicProperties[parsedSearchKeys[1]], "tertiary-content": dynamicProperties[parsedSearchKeys[4]] }));
|
|
240
244
|
});
|
|
241
245
|
const finalComponents = [];
|
|
242
246
|
if (this.placeAdAtStart) {
|
|
@@ -338,29 +342,42 @@ const SearchcraftFiltersList = class {
|
|
|
338
342
|
else {
|
|
339
343
|
this.selectedFilters.delete(value);
|
|
340
344
|
}
|
|
341
|
-
const
|
|
342
|
-
this.filtersUpdated.emit(
|
|
343
|
-
this.searchStore.setSelectedFilters(
|
|
345
|
+
const deduplicatedFilters = this.deduplicatePaths(Array.from(this.selectedFilters));
|
|
346
|
+
this.filtersUpdated.emit(deduplicatedFilters);
|
|
347
|
+
this.searchStore.setSelectedFilters(deduplicatedFilters);
|
|
344
348
|
this.searchStore.search();
|
|
345
349
|
};
|
|
346
350
|
this.filters = [];
|
|
347
351
|
this.dynamicFilters = [];
|
|
348
|
-
this.initialFilters = [];
|
|
349
352
|
this.isRequesting = false;
|
|
350
|
-
this.originalFilterCounts = {};
|
|
351
353
|
this.query = '';
|
|
352
354
|
this.resultsCount = 0;
|
|
353
355
|
this.selectedFilters = new Set();
|
|
354
356
|
}
|
|
355
357
|
connectedCallback() {
|
|
358
|
+
var _a;
|
|
359
|
+
const state = this.searchStore; // Fetch the initial state
|
|
360
|
+
// Initial population of facets if available
|
|
361
|
+
if ((_a = state.searchResults) === null || _a === void 0 ? void 0 : _a.data.facets) {
|
|
362
|
+
this.populateFiltersFromFacets(state.searchResults.data.facets);
|
|
363
|
+
}
|
|
356
364
|
this.unsubscribe = store.useSearchcraftStore.subscribe((state) => {
|
|
357
365
|
var _a, _b, _c, _d;
|
|
358
|
-
|
|
366
|
+
if (!state.query || state.query.trim().length === 0) {
|
|
367
|
+
if (this.selectedFilters.size > 0) {
|
|
368
|
+
this.selectedFilters.clear();
|
|
369
|
+
this.filtersUpdated.emit([]);
|
|
370
|
+
if (this.searchStore.selectedFilters.length > 0) {
|
|
371
|
+
this.searchStore.setSelectedFilters([]);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
359
375
|
this.query = state.query || '';
|
|
376
|
+
this.isRequesting = state.isRequesting;
|
|
360
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;
|
|
361
|
-
|
|
362
|
-
if (facets) {
|
|
363
|
-
this.populateFiltersFromFacets(facets);
|
|
378
|
+
// Populate filters when facets are updated
|
|
379
|
+
if ((_d = state.searchResults) === null || _d === void 0 ? void 0 : _d.data.facets) {
|
|
380
|
+
this.populateFiltersFromFacets(state.searchResults.data.facets);
|
|
364
381
|
}
|
|
365
382
|
});
|
|
366
383
|
}
|
|
@@ -371,24 +388,28 @@ const SearchcraftFiltersList = class {
|
|
|
371
388
|
}
|
|
372
389
|
populateFiltersFromFacets(facets) {
|
|
373
390
|
var _a;
|
|
374
|
-
const newFilters =
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
391
|
+
const newFilters = utils.flattenFacets(((_a = facets[0]) === null || _a === void 0 ? void 0 : _a.section) || []);
|
|
392
|
+
const filtersMap = new Map();
|
|
393
|
+
newFilters.forEach((filter) => {
|
|
394
|
+
const key = filter.value.split('/').pop() || '';
|
|
395
|
+
const existingFilter = filtersMap.get(key);
|
|
396
|
+
if (!existingFilter ||
|
|
397
|
+
filter.value.length < existingFilter.value.length) {
|
|
398
|
+
filtersMap.set(key, filter);
|
|
399
|
+
}
|
|
381
400
|
});
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
401
|
+
this.dynamicFilters = Array.from(filtersMap.values());
|
|
402
|
+
}
|
|
403
|
+
deduplicatePaths(filters) {
|
|
404
|
+
const pathMap = new Map();
|
|
405
|
+
filters.forEach((path) => {
|
|
406
|
+
const key = path.split('/').pop() || '';
|
|
407
|
+
const existingPath = pathMap.get(key);
|
|
408
|
+
if (!existingPath || path.length < existingPath.length) {
|
|
409
|
+
pathMap.set(key, path);
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
return Array.from(pathMap.values());
|
|
392
413
|
}
|
|
393
414
|
formatLabel(label) {
|
|
394
415
|
return label
|
|
@@ -401,17 +422,16 @@ const SearchcraftFiltersList = class {
|
|
|
401
422
|
if (!this.query || this.resultsCount === 0) {
|
|
402
423
|
return null;
|
|
403
424
|
}
|
|
404
|
-
const filtersToRender = this.
|
|
405
|
-
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}))))));
|
|
425
|
+
const filtersToRender = this.dynamicFilters.filter((filter) => !filter.value.includes('/', filter.value.indexOf('/') + 1));
|
|
426
|
+
return (index.h("div", { class: 'filtersList' }, filtersToRender.map((filter) => {
|
|
427
|
+
const isChecked = this.selectedFilters.has(filter.value);
|
|
428
|
+
const children = this.dynamicFilters.filter((child) => child.value.startsWith(`${filter.value}/`) &&
|
|
429
|
+
child.value !== filter.value);
|
|
430
|
+
return (index.h("div", { key: filter.value }, index.h("label", { class: 'checkboxLabel' }, index.h("input", { class: 'filterCheckbox', checked: isChecked, onChange: (event) => this.handleFilterChange(filter.value, event.target.checked), type: 'checkbox' }), this.formatLabel(filter.label)), children.map((child) => {
|
|
431
|
+
const isChildChecked = this.selectedFilters.has(child.value);
|
|
432
|
+
return (index.h("label", { class: 'childCheckboxLabel', key: child.value, style: { marginLeft: '20px' } }, index.h("input", { class: 'childFilterCheckbox', checked: isChildChecked, onChange: (event) => this.handleFilterChange(child.value, event.target.checked), type: 'checkbox' }), this.formatLabel(child.label.split('/').pop() || '')));
|
|
433
|
+
})));
|
|
434
|
+
})));
|
|
415
435
|
}
|
|
416
436
|
};
|
|
417
437
|
SearchcraftFiltersList.style = SearchcraftFiltersListStyle0;
|