@searchcraft/javascript-sdk 0.12.0 → 0.12.2
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/README.md +1 -1
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +136 -17
- package/dist/components/index.js.map +1 -1
- package/dist/components/{p-b7e99386.js → p-870f81fd.js} +38 -6
- package/dist/components/p-870f81fd.js.map +1 -0
- package/dist/components/{p-0c495408.js → p-e8d97093.js} +110 -37
- package/dist/components/p-e8d97093.js.map +1 -0
- package/dist/components/searchcraft-facet-list.js +1 -1
- package/dist/components/searchcraft-filter-panel.js +3 -3
- package/dist/components/searchcraft-filter-panel.js.map +1 -1
- package/dist/components/searchcraft-input-form.js +1 -1
- package/dist/components/searchcraft-pagination.js +8 -2
- package/dist/components/searchcraft-pagination.js.map +1 -1
- package/dist/components/searchcraft-popover-form.js +1 -1
- package/dist/components/searchcraft-results-info.js +9 -1
- package/dist/components/searchcraft-results-info.js.map +1 -1
- package/dist/components/searchcraft-search-results-per-page.js +8 -2
- package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
- package/dist/hydrate/index.js +229 -105
- package/dist/hydrate/index.mjs +229 -105
- package/dist/types/classes/SearchcraftCore.d.ts +1 -1
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +5 -1
- package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +1 -1
- package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +5 -0
- package/dist/types/components/searchcraft-pagination/searchcraft-pagination.d.ts +1 -0
- package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +1 -0
- package/dist/types/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.d.ts +1 -0
- package/dist/types/components.d.ts +16 -0
- package/dist/types/store/SearchcraftStore.types.d.ts +6 -1
- package/dist/types/types/sdk-types/searchcraft-filter-panel.types.d.ts +1 -0
- package/dist/types/utils/facets.d.ts +5 -1
- package/package.json +4 -3
- package/dist/components/p-0c495408.js.map +0 -1
- package/dist/components/p-b7e99386.js.map +0 -1
|
@@ -43,6 +43,10 @@ const SearchcraftInputForm = /*@__PURE__*/ proxyCustomElement(class SearchcraftI
|
|
|
43
43
|
* 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
|
|
44
44
|
*/
|
|
45
45
|
placeholderBehavior;
|
|
46
|
+
/**
|
|
47
|
+
* The value to display in the input field.
|
|
48
|
+
*/
|
|
49
|
+
value;
|
|
46
50
|
/**
|
|
47
51
|
* When the input becomes focused.
|
|
48
52
|
*/
|
|
@@ -63,18 +67,41 @@ const SearchcraftInputForm = /*@__PURE__*/ proxyCustomElement(class SearchcraftI
|
|
|
63
67
|
cleanupCore;
|
|
64
68
|
init() {
|
|
65
69
|
if (this.core) {
|
|
70
|
+
// Initialize inputValue from prop if provided
|
|
71
|
+
if (this.value !== undefined && this.value.trim().length > 0) {
|
|
72
|
+
this.inputValue = this.value;
|
|
73
|
+
this.core.store.getState().setSearchTerm(this.value);
|
|
74
|
+
// Trigger search if autoSearch is enabled
|
|
75
|
+
if (this.autoSearch) {
|
|
76
|
+
this.core.store.getState().search();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
66
79
|
this.inputInit?.emit();
|
|
67
80
|
}
|
|
68
81
|
}
|
|
69
82
|
onCoreChange() {
|
|
70
83
|
this.init();
|
|
71
84
|
}
|
|
85
|
+
onValueChange(newValue) {
|
|
86
|
+
if (newValue !== undefined && newValue !== this.inputValue) {
|
|
87
|
+
this.inputValue = newValue;
|
|
88
|
+
this.core?.store.getState().setSearchTerm(newValue);
|
|
89
|
+
// Trigger search if autoSearch is enabled and value is not empty
|
|
90
|
+
if (this.autoSearch && newValue.trim().length > 0) {
|
|
91
|
+
this.core?.store.getState().search();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
72
95
|
onCoreAvailable(core) {
|
|
73
96
|
this.core = core;
|
|
74
97
|
this.init();
|
|
75
98
|
this.unsubscribe = core.store.subscribe((state) => {
|
|
76
99
|
this.searchTerm = state.searchTerm;
|
|
77
|
-
|
|
100
|
+
// Only update inputValue from store if value prop is not set
|
|
101
|
+
// OR if the store was cleared (empty string)
|
|
102
|
+
if (this.value === undefined || state.searchTerm === '') {
|
|
103
|
+
this.inputValue = state.searchTerm;
|
|
104
|
+
}
|
|
78
105
|
});
|
|
79
106
|
}
|
|
80
107
|
connectedCallback() {
|
|
@@ -103,6 +130,8 @@ const SearchcraftInputForm = /*@__PURE__*/ proxyCustomElement(class SearchcraftI
|
|
|
103
130
|
}
|
|
104
131
|
};
|
|
105
132
|
handleClearInput = () => {
|
|
133
|
+
// Clear the input value even if controlled by prop
|
|
134
|
+
this.inputValue = '';
|
|
106
135
|
this.core?.store.getState().resetSearchValues();
|
|
107
136
|
this.error = false;
|
|
108
137
|
};
|
|
@@ -121,14 +150,15 @@ const SearchcraftInputForm = /*@__PURE__*/ proxyCustomElement(class SearchcraftI
|
|
|
121
150
|
const inputGridStyles = {
|
|
122
151
|
gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',
|
|
123
152
|
};
|
|
124
|
-
return (h("form", { key: '
|
|
153
|
+
return (h("form", { key: 'd214ace44e9209154d215e803de088aefa58a285', class: 'searchcraft-input-form', onSubmit: this.handleFormSubmit }, h("div", { key: '5699f5dca28caf5e9584401f1883d2e08d26e3ec', class: inputGridClassNames, style: inputGridStyles }, h("div", { key: 'ef792a946414a680e9c99c145246d00b9b8f2ffb', class: 'searchcraft-input-form-button' }, h("searchcraft-button", { key: 'ba5a8cb98889bb486781af4915a21c94a0b1498a', onButtonClick: this.handleFormSubmit, label: this.buttonLabel })), this.inputLabel && (h("div", { key: 'a9e770ef967f7ab1c6ddf8f87f23cea509894536', class: 'searchcraft-input-form-label' }, h("searchcraft-input-label", { key: '93b29e630e71a3c7724921aa9586aab76e592f4f', label: this.inputLabel }))), this.error && (h("div", { key: '641ef4f468d527c24a1635d49dcbbba03030686f', class: 'searchcraft-input-form-error-message' }, h("searchcraft-error-message", { key: '2d839d17b702fe1b41d7e49aacfc52fb53315766' }, "Something went wrong."))), h("div", { key: 'af0c73478de21447c992bd0037ba007d54f53a86', class: 'searchcraft-input-form-input-wrapper' }, h("input", { key: '3de1be1aa71c143b58cd6080d422410bd400e4e5', autoComplete: 'off', class: classNames('searchcraft-input-form-input', {
|
|
125
154
|
'searchcraft-placeholder-hide-on-focus': this.placeholderBehavior === 'hide-on-focus',
|
|
126
155
|
}), onFocus: () => this.inputFocus?.emit(), onBlur: () => this.inputBlur?.emit(), onInput: (event) => {
|
|
127
156
|
this.handleInput(event);
|
|
128
|
-
}, placeholder: this.placeholderValue, type: 'text', value: this.inputValue }), h("div", { key: '
|
|
157
|
+
}, placeholder: this.placeholderValue, type: 'text', value: this.inputValue }), h("div", { key: 'fe9043c046e3b1b91129299f0860919ba8a8416b', class: 'searchcraft-input-form-input-icon' }, h("svg", { key: '31ae1553cd214d5e2f97c9e3699862dff51a0916', class: 'searchcraft-input-form-input-search-icon', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'searchcraft-title' }, h("title", { key: '9db677da65283ff15b0d4e79b5d9daf89637b33f' }, "Search icon"), h("path", { key: '2a002eae6ed3725a432e7c3e4649c0bd2ffff7a0', d: 'M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))), isShowingClearButton && (h("button", { key: 'b7e92b22c3234eb31d85b0aa98d7c682b2fc0021', type: 'button', class: 'searchcraft-input-form-clear-button', onClick: this.handleClearInput }, h("svg", { key: 'bfbeb742f197da0cac6dd5df2627db9df5349207', class: 'searchcraft-input-form-clear-icon', viewBox: '0 0 22 22', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'icon-title' }, h("title", { key: 'c62b9d237b3762609fed72e0520322fb5eabe979' }, "Clear icon"), h("path", { key: '198a13760ce8b076ef8e791dec933b210ff3017a', d: 'M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))))))));
|
|
129
158
|
}
|
|
130
159
|
static get watchers() { return {
|
|
131
|
-
"core": ["onCoreChange"]
|
|
160
|
+
"core": ["onCoreChange"],
|
|
161
|
+
"value": ["onValueChange"]
|
|
132
162
|
}; }
|
|
133
163
|
}, [0, "searchcraft-input-form", {
|
|
134
164
|
"searchcraftId": [1, "searchcraft-id"],
|
|
@@ -138,11 +168,13 @@ const SearchcraftInputForm = /*@__PURE__*/ proxyCustomElement(class SearchcraftI
|
|
|
138
168
|
"inputLabel": [1, "input-label"],
|
|
139
169
|
"placeholderValue": [1, "placeholder-value"],
|
|
140
170
|
"placeholderBehavior": [1, "placeholder-behavior"],
|
|
171
|
+
"value": [1],
|
|
141
172
|
"inputValue": [32],
|
|
142
173
|
"searchTerm": [32],
|
|
143
174
|
"error": [32]
|
|
144
175
|
}, undefined, {
|
|
145
|
-
"core": ["onCoreChange"]
|
|
176
|
+
"core": ["onCoreChange"],
|
|
177
|
+
"value": ["onValueChange"]
|
|
146
178
|
}]);
|
|
147
179
|
function defineCustomElement() {
|
|
148
180
|
if (typeof customElements === "undefined") {
|
|
@@ -175,4 +207,4 @@ function defineCustomElement() {
|
|
|
175
207
|
|
|
176
208
|
export { SearchcraftInputForm as S, defineCustomElement as d };
|
|
177
209
|
|
|
178
|
-
//# sourceMappingURL=p-
|
|
210
|
+
//# sourceMappingURL=p-870f81fd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":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,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,qBAClB,YAAY,IAE5B,6EAAyB,EACzB,6DACE,CAAC,EAAC,uIAAuI,EACzI,MAAM,EAAC,cAAc,kBACR,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACC,CACV,CACG,CACF,CACD,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/searchcraft-input-form/searchcraft-input-form.tsx"],"sourcesContent":["import {\n Component,\n Event,\n type EventEmitter,\n Prop,\n State,\n Watch,\n h,\n} from '@stencil/core';\nimport classNames from 'classnames';\n\nimport type { SearchcraftCore } from '@classes';\nimport { registry } from '@classes/CoreInstanceRegistry';\nimport type { SearchcraftState } from '@store';\n\n/**\n * This web component provides a user-friendly interface for querying an indexed dataset, enabling users to easily search large collections of data.\n * It abstracts the complexities of index-based searching, making it accessible to users of all technical levels.\n *\n * @react-import\n * ```jsx\n * import { SearchcraftInputForm } from \"@searchcraft/react-sdk\";\n * ```\n *\n * @vue-import\n * ```jsx\n * import { SearchcraftInputForm } from \"@searchcraft/vue-sdk\";\n * ```\n *\n * @js-example\n * ```html\n * <searchcraft-input-form auto-search />\n * ```\n *\n * @react-example\n * ```jsx\n * <SearchcraftInputForm autoSearch />\n * ```\n *\n * @vue-example\n * ```jsx\n * <SearchcraftInputForm autoSearch />\n * ```\n */\n@Component({\n tag: 'searchcraft-input-form',\n shadow: false,\n})\nexport class SearchcraftInputForm {\n /**\n * The id of the Searchcraft instance that this component should use.\n */\n @Prop() searchcraftId?: string;\n /**\n * Whether or not to automatically submit the search term when the input changes.\n */\n @Prop() autoSearch?: boolean = true;\n /**\n * Where to place the search button.\n */\n @Prop() buttonPlacement?: 'left' | 'right' | 'none' = 'none';\n /**\n * The label for the submit button.\n */\n @Prop() buttonLabel?: string;\n /**\n * The label rendered above the input.\n */\n @Prop() inputLabel?: string;\n /**\n * The input element's placeholder value.\n */\n @Prop() placeholderValue?: string = 'Enter Search';\n /**\n * The placeholder's render behavior.\n * 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus.\n * 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.\n */\n @Prop() placeholderBehavior?: 'hide-on-focus' | 'hide-on-text-entered';\n /**\n * The value to display in the input field.\n */\n @Prop() value?: string;\n /**\n * When the input becomes focused.\n */\n @Event() inputFocus?: EventEmitter<void>;\n /**\n * When the input becomes unfocused.\n */\n @Event() inputBlur?: EventEmitter<void>;\n /**\n * Event emitted when input initializes.\n */\n @Event() inputInit?: EventEmitter<void>;\n\n @State() inputValue = '';\n @State() searchTerm = '';\n @State() error = false;\n\n private core?: SearchcraftCore;\n private unsubscribe?: () => void;\n private cleanupCore?: () => void;\n\n init() {\n if (this.core) {\n // Initialize inputValue from prop if provided\n if (this.value !== undefined && this.value.trim().length > 0) {\n this.inputValue = this.value;\n this.core.store.getState().setSearchTerm(this.value);\n // Trigger search if autoSearch is enabled\n if (this.autoSearch) {\n this.core.store.getState().search();\n }\n }\n this.inputInit?.emit();\n }\n }\n\n @Watch('core')\n onCoreChange() {\n this.init();\n }\n\n @Watch('value')\n onValueChange(newValue: string | undefined) {\n if (newValue !== undefined && newValue !== this.inputValue) {\n this.inputValue = newValue;\n this.core?.store.getState().setSearchTerm(newValue);\n // Trigger search if autoSearch is enabled and value is not empty\n if (this.autoSearch && newValue.trim().length > 0) {\n this.core?.store.getState().search();\n }\n }\n }\n\n onCoreAvailable(core: SearchcraftCore) {\n this.core = core;\n this.init();\n this.unsubscribe = core.store.subscribe((state: SearchcraftState) => {\n this.searchTerm = state.searchTerm;\n // Only update inputValue from store if value prop is not set\n // OR if the store was cleared (empty string)\n if (this.value === undefined || state.searchTerm === '') {\n this.inputValue = state.searchTerm;\n }\n });\n }\n\n connectedCallback() {\n this.cleanupCore = registry.useCoreInstance(\n this.searchcraftId,\n this.onCoreAvailable.bind(this),\n );\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n this.cleanupCore?.();\n }\n\n handleInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n this.inputValue = input.value;\n this.core?.store.getState().setSearchTerm(input.value);\n\n if (!this.autoSearch) {\n return;\n }\n\n this.performSearch();\n };\n\n private performSearch = async () => {\n this.error = false;\n\n try {\n await this.core?.store.getState().search();\n } catch (error) {\n this.error = true;\n }\n };\n\n handleClearInput = () => {\n // Clear the input value even if controlled by prop\n this.inputValue = '';\n this.core?.store.getState().resetSearchValues();\n this.error = false;\n };\n\n handleFormSubmit = async (event: Event) => {\n event.preventDefault();\n await this.performSearch();\n };\n\n render() {\n const isShowingClearButton = this.inputValue.length > 0;\n const inputGridClassNames = classNames('searchcraft-input-form-grid', {\n 'searchcraft-input-form-grid-button-left':\n this.buttonPlacement === 'left',\n 'searchcraft-input-form-grid-button-right':\n this.buttonPlacement === 'right',\n 'searchcraft-input-form-grid-button-none':\n this.buttonPlacement === 'none',\n });\n const shouldHaveVerticalGap = this.inputLabel || this.error;\n const inputGridStyles = {\n gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',\n };\n return (\n <form class='searchcraft-input-form' onSubmit={this.handleFormSubmit}>\n <div class={inputGridClassNames} style={inputGridStyles}>\n <div class='searchcraft-input-form-button'>\n <searchcraft-button\n onButtonClick={this.handleFormSubmit}\n label={this.buttonLabel}\n />\n </div>\n {this.inputLabel && (\n <div class='searchcraft-input-form-label'>\n <searchcraft-input-label label={this.inputLabel} />\n </div>\n )}\n {this.error && (\n <div class='searchcraft-input-form-error-message'>\n <searchcraft-error-message>\n Something went wrong.\n </searchcraft-error-message>\n </div>\n )}\n <div class='searchcraft-input-form-input-wrapper'>\n <input\n autoComplete='off'\n class={classNames('searchcraft-input-form-input', {\n 'searchcraft-placeholder-hide-on-focus':\n this.placeholderBehavior === 'hide-on-focus',\n })}\n onFocus={() => this.inputFocus?.emit()}\n onBlur={() => this.inputBlur?.emit()}\n onInput={(event) => {\n this.handleInput(event);\n }}\n placeholder={this.placeholderValue}\n type='text'\n value={this.inputValue}\n />\n <div class='searchcraft-input-form-input-icon'>\n <svg\n class='searchcraft-input-form-input-search-icon'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='searchcraft-title'\n >\n <title>Search icon</title>\n <path\n d='M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </div>\n {isShowingClearButton && (\n <button\n type='button'\n class='searchcraft-input-form-clear-button'\n onClick={this.handleClearInput}\n >\n <svg\n class='searchcraft-input-form-clear-icon'\n viewBox='0 0 22 22'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='icon-title'\n >\n <title>Clear icon</title>\n <path\n d='M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </button>\n )}\n </div>\n </div>\n </form>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, c as createEvent, h } from './p-5365011f.js';
|
|
2
|
-
import './p-e2a10337.js';
|
|
3
2
|
import { r as registry } from './p-e30203b1.js';
|
|
3
|
+
import './p-e2a10337.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Helper function for getting a Node (FacetWithChildrenObject)
|
|
@@ -76,8 +76,12 @@ const mergeFacetTrees = (currentTree, incomingTree) => {
|
|
|
76
76
|
* It uses the `path` of each Facet to build the tree.
|
|
77
77
|
*
|
|
78
78
|
* @param facetWithChildArray
|
|
79
|
+
* @param exclude - Optional array of facet values or paths to exclude from the tree.
|
|
80
|
+
* - Values starting with "/" are treated as full paths and exclude the path and all children
|
|
81
|
+
* (e.g., "/news" excludes "/news", "/news/local", "/news/national", etc.)
|
|
82
|
+
* - Values without "/" are treated as segment names (e.g., "local" excludes all paths containing "local")
|
|
79
83
|
*/
|
|
80
|
-
const facetWithChildrenArrayToCompleteFacetTree = (rootArray) => {
|
|
84
|
+
const facetWithChildrenArrayToCompleteFacetTree = (rootArray, exclude) => {
|
|
81
85
|
// 1) Start with an empty tree at root "/"
|
|
82
86
|
const tree = {
|
|
83
87
|
path: '/',
|
|
@@ -100,6 +104,29 @@ const facetWithChildrenArrayToCompleteFacetTree = (rootArray) => {
|
|
|
100
104
|
// 3) Insert each flat node into our tree, creating missing ancestors
|
|
101
105
|
for (const { path, count } of allFacets) {
|
|
102
106
|
const segments = path.split('/').filter(Boolean); // "/sports/outdoors" -> ["sports","outdoors"]
|
|
107
|
+
// Skip this facet if it matches any excluded value
|
|
108
|
+
if (exclude && exclude.length > 0) {
|
|
109
|
+
let shouldExclude = false;
|
|
110
|
+
for (const excludeValue of exclude) {
|
|
111
|
+
if (excludeValue.startsWith('/')) {
|
|
112
|
+
// Full path exclusion: prefix match (excludes the path and all children)
|
|
113
|
+
if (path === excludeValue || path.startsWith(`${excludeValue}/`)) {
|
|
114
|
+
shouldExclude = true;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
// Segment exclusion: check if any segment matches
|
|
120
|
+
if (segments.includes(excludeValue)) {
|
|
121
|
+
shouldExclude = true;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (shouldExclude) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
103
130
|
let cursor = tree; // start at the root
|
|
104
131
|
for (const segment of segments) {
|
|
105
132
|
// Build the full path of this level
|
|
@@ -135,6 +162,10 @@ const SearchcraftFacetList = /*@__PURE__*/ proxyCustomElement(class SearchcraftF
|
|
|
135
162
|
* The name of the field where facets are applied.
|
|
136
163
|
*/
|
|
137
164
|
fieldName = '';
|
|
165
|
+
/**
|
|
166
|
+
* Array of facet values to exclude from rendering.
|
|
167
|
+
*/
|
|
168
|
+
exclude;
|
|
138
169
|
/**
|
|
139
170
|
* Emitted when the facets are updated.
|
|
140
171
|
*/
|
|
@@ -189,7 +220,7 @@ const SearchcraftFacetList = /*@__PURE__*/ proxyCustomElement(class SearchcraftF
|
|
|
189
220
|
path: '/',
|
|
190
221
|
count: 0,
|
|
191
222
|
children: incomingFacetsWithChildrenArray || [],
|
|
192
|
-
});
|
|
223
|
+
}, this.exclude);
|
|
193
224
|
// Determine what action to take to accumulate items into the `facetTreeCollectedFromSearchResponse`.
|
|
194
225
|
// This facet tree gets accumulated in different ways depending on what action type occured.
|
|
195
226
|
switch (actionType) {
|
|
@@ -213,7 +244,7 @@ const SearchcraftFacetList = /*@__PURE__*/ proxyCustomElement(class SearchcraftF
|
|
|
213
244
|
path: '/',
|
|
214
245
|
count: 0,
|
|
215
246
|
children: supplementalFacetsWithChildrenArray || [],
|
|
216
|
-
});
|
|
247
|
+
}, this.exclude);
|
|
217
248
|
this.facetTreeCollectedFromSearchResponse = mergeFacetTrees(supplementalFacetTree, incomingFacetTree);
|
|
218
249
|
}
|
|
219
250
|
else {
|
|
@@ -255,7 +286,7 @@ const SearchcraftFacetList = /*@__PURE__*/ proxyCustomElement(class SearchcraftF
|
|
|
255
286
|
}
|
|
256
287
|
}
|
|
257
288
|
this.facetTreeFromFacetPathsNotInSearchResponse =
|
|
258
|
-
facetWithChildrenArrayToCompleteFacetTree(collectedFacetArray);
|
|
289
|
+
facetWithChildrenArrayToCompleteFacetTree(collectedFacetArray, this.exclude);
|
|
259
290
|
// Merges facetTreeCollectedFromSearchResponse with selectedFacetPathsNotInCurrentFacetTree.
|
|
260
291
|
// This results in a single, final facet tree that gets rendered in as Checkboxes
|
|
261
292
|
this.renderedFacetTree = deepMergeWithSpread(this.facetTreeFromFacetPathsNotInSearchResponse, this.facetTreeCollectedFromSearchResponse);
|
|
@@ -263,45 +294,86 @@ const SearchcraftFacetList = /*@__PURE__*/ proxyCustomElement(class SearchcraftF
|
|
|
263
294
|
handleStateUpdate(_state) {
|
|
264
295
|
const state = { ..._state };
|
|
265
296
|
// Determine what action to take based on the current State
|
|
266
|
-
if (
|
|
297
|
+
// Check if this is an initialQuery case (string requestProperties with empty searchTerm)
|
|
298
|
+
const isInitialQuery = typeof state.searchClientRequestProperties === 'string' &&
|
|
299
|
+
state.searchTerm.trim() === '';
|
|
300
|
+
if (state.searchTerm.trim() === '' && !isInitialQuery) {
|
|
267
301
|
this.handleIncomingSearchResponse(state, 'SEARCH_TERM_EMPTY');
|
|
268
302
|
this.lastSearchTerm = '';
|
|
269
303
|
}
|
|
270
304
|
else if (this.lastTimeTaken !== state.searchResponseTimeTaken &&
|
|
271
|
-
state.searchClientRequestProperties
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (this.
|
|
277
|
-
|
|
305
|
+
state.searchClientRequestProperties) {
|
|
306
|
+
// Handle both object and string requestProperties (string is used for initialQuery)
|
|
307
|
+
if (typeof state.searchClientRequestProperties === 'object') {
|
|
308
|
+
const requestProperties = state.searchClientRequestProperties;
|
|
309
|
+
let actionType = 'UNKNOWN';
|
|
310
|
+
if (this.lastSearchTerm !== requestProperties.searchTerm) {
|
|
311
|
+
if (this.areAnyFacetPathsSelected) {
|
|
312
|
+
actionType = 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE';
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
316
|
+
}
|
|
278
317
|
}
|
|
279
|
-
else
|
|
280
|
-
|
|
318
|
+
else if (this.lastRangeValues !==
|
|
319
|
+
JSON.stringify(requestProperties.rangeValueForIndexFields)) {
|
|
320
|
+
actionType = 'RANGE_VALUE_UPDATE';
|
|
281
321
|
}
|
|
322
|
+
else if (this.lastFacetValues !==
|
|
323
|
+
JSON.stringify(requestProperties.facetPathsForIndexFields)) {
|
|
324
|
+
actionType = 'FACET_UPDATE';
|
|
325
|
+
}
|
|
326
|
+
else if (this.lastSortType !== requestProperties.order_by) {
|
|
327
|
+
actionType = 'SORT_ORDER_UPDATE';
|
|
328
|
+
}
|
|
329
|
+
else if (this.lastSearchMode !== requestProperties.mode) {
|
|
330
|
+
actionType = 'EXACT_MATCH_UPDATE';
|
|
331
|
+
}
|
|
332
|
+
this.lastRangeValues = JSON.stringify(requestProperties.rangeValueForIndexFields);
|
|
333
|
+
this.lastFacetValues = JSON.stringify(requestProperties.facetPathsForIndexFields);
|
|
334
|
+
this.lastSortType = requestProperties.order_by;
|
|
335
|
+
this.lastSearchMode = requestProperties.mode;
|
|
336
|
+
this.lastSearchTerm = requestProperties.searchTerm;
|
|
337
|
+
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
338
|
+
// Handle the incoming response, using the action we have determined.
|
|
339
|
+
this.handleIncomingSearchResponse(state, actionType);
|
|
282
340
|
}
|
|
283
|
-
else if (
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
JSON.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
341
|
+
else if (typeof state.searchClientRequestProperties === 'string') {
|
|
342
|
+
// Handle initialQuery case where requestProperties is a string
|
|
343
|
+
// For initialQuery, searchTerm will be empty but we still want to show facets
|
|
344
|
+
let actionType = 'NEW_SEARCH_TERM';
|
|
345
|
+
// Parse the request to get facet and range filters from the query array
|
|
346
|
+
const requestObj = JSON.parse(state.searchClientRequestProperties);
|
|
347
|
+
const queryArray = Array.isArray(requestObj.query)
|
|
348
|
+
? requestObj.query
|
|
349
|
+
: [requestObj.query];
|
|
350
|
+
// Extract filter queries (those with occur: 'must')
|
|
351
|
+
const filterQueries = queryArray.filter((q) => q.occur === 'must');
|
|
352
|
+
const currentFilters = JSON.stringify(filterQueries);
|
|
353
|
+
// Determine the action type based on what changed
|
|
354
|
+
if (this.lastFacetValues !== undefined && this.lastFacetValues !== currentFilters) {
|
|
355
|
+
// Filters have changed (not initial load)
|
|
356
|
+
actionType = 'FACET_UPDATE';
|
|
357
|
+
}
|
|
358
|
+
else if (state.searchTerm.trim() === '' && this.lastSearchTerm === '') {
|
|
359
|
+
// Initial load or no changes with empty search term
|
|
360
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
361
|
+
}
|
|
362
|
+
else if (this.lastSearchTerm !== state.searchTerm) {
|
|
363
|
+
// User has typed a new search term after initialQuery
|
|
364
|
+
if (this.areAnyFacetPathsSelected) {
|
|
365
|
+
actionType = 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE';
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
this.lastFacetValues = currentFilters;
|
|
372
|
+
this.lastSearchTerm = state.searchTerm;
|
|
373
|
+
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
374
|
+
// Handle the incoming response, using the action we have determined.
|
|
375
|
+
this.handleIncomingSearchResponse(state, actionType);
|
|
296
376
|
}
|
|
297
|
-
this.lastRangeValues = JSON.stringify(requestProperties.rangeValueForIndexFields);
|
|
298
|
-
this.lastFacetValues = JSON.stringify(requestProperties.facetPathsForIndexFields);
|
|
299
|
-
this.lastSortType = requestProperties.order_by;
|
|
300
|
-
this.lastSearchMode = requestProperties.mode;
|
|
301
|
-
this.lastSearchTerm = requestProperties.searchTerm;
|
|
302
|
-
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
303
|
-
// Handle the incoming response, using the action we have determined.
|
|
304
|
-
this.handleIncomingSearchResponse(state, actionType);
|
|
305
377
|
}
|
|
306
378
|
}
|
|
307
379
|
onCoreAvailable(core) {
|
|
@@ -393,6 +465,7 @@ const SearchcraftFacetList = /*@__PURE__*/ proxyCustomElement(class SearchcraftF
|
|
|
393
465
|
}, [0, "searchcraft-facet-list", {
|
|
394
466
|
"searchcraftId": [1, "searchcraft-id"],
|
|
395
467
|
"fieldName": [1, "field-name"],
|
|
468
|
+
"exclude": [16],
|
|
396
469
|
"selectedPaths": [32],
|
|
397
470
|
"facetTreeCollectedFromSearchResponse": [32],
|
|
398
471
|
"renderedFacetTree": [32]
|
|
@@ -413,4 +486,4 @@ function defineCustomElement() {
|
|
|
413
486
|
|
|
414
487
|
export { SearchcraftFacetList as S, defineCustomElement as d };
|
|
415
488
|
|
|
416
|
-
//# sourceMappingURL=p-
|
|
489
|
+
//# sourceMappingURL=p-e8d97093.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-e8d97093.js","mappings":";;;;AAOA;;;;AAIO,MAAM,sBAAsB,GAAG,CACpC,IAAe,EACf,SAAmB;IAEnB,IAAI,MAAM,GAAwC,IAAI,CAAC;IACvD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACrC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;AAIO,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,IAAI;IAC5C,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAE3B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;;QAEtB,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;YAC5B,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,MAAM,EAAE;gBAC9D,MAAM,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,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CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG;YACnC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBACvB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;aACnD;SACF,CAAC,CACE,CACP,CACG,EACN;KACH;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,OAAO;SACR;QAED,IACE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,oCAAoC,CAAC,QAAQ,CAAC,CAAC,MAAM;YACpE,CAAC;YACH,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAC/C;YACA,OAAO;SACR;QAED,IACE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,oCAAoC,CAAC,QAAQ,CAAC,CAAC,MAAM;YACpE,CAAC;YACH,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAC7C;YACA,QACE,SAAG,KAAK,EAAC,gCAAgC,qDAErC,EACJ;SACH;QAED,QACE,WAAK,KAAK,EAAC,wBAAwB,IAChC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAC/C,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/utils/facets.ts","src/components/searchcraft-facet-list/searchcraft-facet-list.tsx"],"sourcesContent":["import type {\n Facet,\n FacetTree,\n FacetWithChildrenArray,\n FacetWithChildrenObject,\n} from '@types';\n\n/**\n * Helper function for getting a Node (FacetWithChildrenObject)\n * at a given path. Traverses the node tree to get the node.\n */\nexport const getFacetTreeNodeAtPath = (\n tree: FacetTree,\n nodePaths: string[],\n): FacetWithChildrenObject | undefined => {\n let cursor: FacetWithChildrenObject | undefined = tree;\n for (const nodePath of nodePaths) {\n cursor = cursor?.children[nodePath];\n }\n\n return cursor;\n};\n\n/**\n * Helper function to perform a deep merge.\n * Used for merging two branches of a facet tree together.\n */\nexport const deepMergeWithSpread = (obj1, obj2) => {\n const result = { ...obj1 };\n\n for (const key in obj2) {\n // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>\n if (obj2.hasOwnProperty(key)) {\n if (obj2[key] instanceof Object && obj1[key] instanceof Object) {\n result[key] = deepMergeWithSpread(obj1[key], obj2[key]);\n } else {\n result[key] = obj2[key];\n }\n }\n }\n\n return result;\n};\n\n/**\n * Given an array of facet paths, removes parent facet paths so that only the\n * Leaf facets are sent with the search request.\n */\nexport function removeSubstringMatches(arr: string[]): string[] {\n return arr.filter(\n (entry, index, array) =>\n !array.some(\n (otherEntry, otherIndex) =>\n otherIndex !== index && otherEntry.includes(entry),\n ),\n );\n}\n\n/**\n * Merges a current facet tree with an incoming facet tree.\n *\n * At each branch, the incoming facet tree's facets override current facet tree\n *\n * @param currentTree\n * @param incomingTree\n */\nexport const mergeFacetTrees = (\n currentTree: FacetTree,\n incomingTree: FacetTree,\n): FacetTree => {\n const mergedTree: FacetTree = structuredClone(currentTree);\n\n const merge = (\n currentBranch: FacetWithChildrenObject,\n nodePath: string[],\n ): FacetWithChildrenObject => {\n const mergedBranch = structuredClone(currentBranch);\n const incomingBranch = getFacetTreeNodeAtPath(incomingTree, nodePath);\n\n if (!incomingBranch) {\n return mergedBranch;\n }\n\n for (const nodeName of Object.keys(currentBranch.children)) {\n if (incomingBranch.children[nodeName]) {\n mergedBranch.children[nodeName] = {\n ...deepMergeWithSpread(\n currentBranch.children[nodeName],\n incomingBranch.children[nodeName],\n ),\n count: mergedBranch.children[nodeName]?.count || 0,\n };\n } else if (mergedBranch.children[nodeName]) {\n mergedBranch.children[nodeName] = merge(\n mergedBranch.children[nodeName],\n [...nodePath, nodeName],\n );\n }\n }\n\n return mergedBranch;\n };\n\n return merge(mergedTree, []);\n};\n\n/**\n * A function that converts a FacetWithChidrenArray to a complete FacetTree object.\n *\n * It uses the `path` of each Facet to build the tree.\n *\n * @param facetWithChildArray\n * @param exclude - Optional array of facet values or paths to exclude from the tree.\n * - Values starting with \"/\" are treated as full paths and exclude the path and all children\n * (e.g., \"/news\" excludes \"/news\", \"/news/local\", \"/news/national\", etc.)\n * - Values without \"/\" are treated as segment names (e.g., \"local\" excludes all paths containing \"local\")\n */\nexport const facetWithChildrenArrayToCompleteFacetTree = (\n rootArray: FacetWithChildrenArray,\n exclude?: string[],\n): FacetTree => {\n // 1) Start with an empty tree at root \"/\"\n const tree: FacetTree = {\n path: '/',\n count: 0,\n children: {},\n };\n\n // 2) Recursively collect all nodes except the implicit \"/\" itself\n const allFacets: Facet[] = [];\n const collect = (node: FacetWithChildrenArray) => {\n if (node.path !== '/') {\n allFacets.push({ path: node.path, count: node.count });\n }\n if (node.children) {\n for (const child of node.children) {\n collect(child);\n }\n }\n };\n collect(rootArray);\n\n // 3) Insert each flat node into our tree, creating missing ancestors\n for (const { path, count } of allFacets) {\n const segments = path.split('/').filter(Boolean); // \"/sports/outdoors\" -> [\"sports\",\"outdoors\"]\n\n // Skip this facet if it matches any excluded value\n if (exclude && exclude.length > 0) {\n let shouldExclude = false;\n\n for (const excludeValue of exclude) {\n if (excludeValue.startsWith('/')) {\n // Full path exclusion: prefix match (excludes the path and all children)\n if (path === excludeValue || path.startsWith(`${excludeValue}/`)) {\n shouldExclude = true;\n break;\n }\n } else {\n // Segment exclusion: check if any segment matches\n if (segments.includes(excludeValue)) {\n shouldExclude = true;\n break;\n }\n }\n }\n\n if (shouldExclude) {\n continue;\n }\n }\n\n let cursor: FacetWithChildrenObject = tree; // start at the root\n for (const segment of segments) {\n // Build the full path of this level\n const prefixPath =\n cursor.path === '/' ? `/${segment}` : `${cursor.path}/${segment}`;\n\n // If this segment doesn't exist yet, create it\n if (!cursor.children[segment]) {\n cursor.children[segment] = {\n path: prefixPath,\n count: count,\n children: {},\n };\n }\n\n // Descend to the next level deeper\n cursor = cursor.children[segment];\n }\n\n // 4) Now `cursor` is the node matching `path` assign its real count\n cursor.count = count;\n }\n\n return tree;\n};\n","import {\n Component,\n Event,\n type EventEmitter,\n Prop,\n State,\n h,\n} from '@stencil/core';\n\nimport type {\n FacetRoot,\n FacetWithChildrenArray,\n FacetWithChildrenObject,\n SearchClientQuery,\n} from '@types';\n\nimport type { SearchcraftCore } from '@classes';\nimport { registry } from '@classes/CoreInstanceRegistry';\nimport type { SearchcraftState } from '@store';\nimport {\n deepMergeWithSpread,\n facetWithChildrenArrayToCompleteFacetTree,\n getFacetTreeNodeAtPath,\n mergeFacetTrees,\n removeSubstringMatches,\n} from '@utils';\n\ntype HandlerActionType =\n | 'SEARCH_TERM_EMPTY'\n | 'NEW_SEARCH_TERM'\n | 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE'\n | 'RANGE_VALUE_UPDATE'\n | 'EXACT_MATCH_UPDATE'\n | 'SORT_ORDER_UPDATE'\n | 'FACET_UPDATE'\n | 'UNKNOWN';\n\n/**\n * This web component is designed to display facets in a search interface, allowing users to refine their search results by applying filters based on various attributes.\n * It is consumed within the `searchcraft-filter-panel`.\n *\n * @js-example\n * ```html\n * <!-- index.html -->\n * <searchcraft-facet-list field-name=\"title\" />\n * ```\n *\n * ```js\n * // index.js\n * const facetList = document.querySelector('searchcraft-facet-list');\n *\n * facetList.addEventListener('facetSelectionUpdated', () => {\n * console.log('Facet selection updated');\n * });\n * ```\n *\n * @internal\n */\n@Component({\n tag: 'searchcraft-facet-list',\n shadow: false,\n})\nexport class SearchcraftFacetList {\n /**\n * The id of the Searchcraft instance that this component should use.\n */\n @Prop() searchcraftId?: string;\n /**\n * The name of the field where facets are applied.\n */\n @Prop() fieldName = '';\n /**\n * Array of facet values to exclude from rendering.\n */\n @Prop() exclude?: string[];\n\n /**\n * Emitted when the facets are updated.\n */\n @Event() facetSelectionUpdated?: EventEmitter<{ paths: string[] }>;\n\n /**\n * The currently selected facet paths.\n */\n @State() selectedPaths: Record<string, boolean> = {};\n\n /**\n * A Tree representing all of the facets collected from search responses.\n */\n @State() facetTreeCollectedFromSearchResponse: FacetWithChildrenObject = {\n path: '/',\n count: 0,\n children: {},\n };\n\n /**\n * A Tree representing the facet paths that are selected, but were not included\n * in any search response.\n */\n facetTreeFromFacetPathsNotInSearchResponse: FacetWithChildrenObject = {\n path: '/',\n count: 0,\n children: {},\n };\n\n /**\n * The facet tree that ultimately gets rendered.\n * This is a mergin of the facetTreeCollectedFromSearchResponse and the facetTreeFromFacetPathsNotInSearchResponse tree\n */\n @State() renderedFacetTree: FacetWithChildrenObject = {\n path: '/',\n count: 0,\n children: {},\n };\n\n // Internal vars used to track when to perform various facet actions.\n private lastTimeTaken?: number;\n private lastSearchTerm?: string;\n private lastSearchMode?: string;\n private lastSortType?: string | null;\n private lastRangeValues?: string;\n private lastFacetValues?: string;\n\n private unsubscribe?: () => void;\n private cleanupCore?: () => void;\n\n get areAnyFacetPathsSelected(): boolean {\n return Object.keys(this.selectedPaths).some(\n (key) => this.selectedPaths[key],\n );\n }\n\n handleIncomingSearchResponse(\n state: SearchcraftState,\n actionType: HandlerActionType,\n ) {\n // Look at the incoming facet root from the search response, and convert it to a FacetTree\n const incomingFacetRoot: FacetRoot | undefined =\n state.searchResponseFacetPrime?.find(\n (facet) => this.fieldName === Object.keys(facet)[0],\n );\n const incomingFacetsWithChildrenArray = incomingFacetRoot?.[this.fieldName];\n const incomingFacetTree = facetWithChildrenArrayToCompleteFacetTree(\n {\n path: '/',\n count: 0,\n children: incomingFacetsWithChildrenArray || [],\n },\n this.exclude,\n );\n\n // Determine what action to take to accumulate items into the `facetTreeCollectedFromSearchResponse`.\n // This facet tree gets accumulated in different ways depending on what action type occured.\n switch (actionType) {\n case 'SEARCH_TERM_EMPTY':\n this.facetTreeCollectedFromSearchResponse = {\n path: '/',\n count: 0,\n children: {},\n };\n break;\n case 'NEW_SEARCH_TERM':\n this.facetTreeCollectedFromSearchResponse = incomingFacetTree;\n break;\n case 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE':\n case 'EXACT_MATCH_UPDATE':\n case 'RANGE_VALUE_UPDATE': {\n if (state.supplementalFacetPrime) {\n const supplementalFacetRoot: FacetRoot | undefined =\n state.supplementalFacetPrime?.find(\n (facet) => this.fieldName === Object.keys(facet)[0],\n );\n const supplementalFacetsWithChildrenArray =\n supplementalFacetRoot?.[this.fieldName];\n const supplementalFacetTree =\n facetWithChildrenArrayToCompleteFacetTree(\n {\n path: '/',\n count: 0,\n children: supplementalFacetsWithChildrenArray || [],\n },\n this.exclude,\n );\n\n this.facetTreeCollectedFromSearchResponse = mergeFacetTrees(\n supplementalFacetTree,\n incomingFacetTree,\n );\n } else {\n this.facetTreeCollectedFromSearchResponse = incomingFacetTree;\n }\n break;\n }\n case 'FACET_UPDATE':\n case 'SORT_ORDER_UPDATE':\n this.facetTreeCollectedFromSearchResponse = mergeFacetTrees(\n this.facetTreeCollectedFromSearchResponse,\n incomingFacetTree,\n );\n break;\n default:\n return;\n }\n\n // Determine if there are any selected facet paths not in the current tree.\n // If there are, we add them to \"facetTreeFromFacetPathsNotInSearchResponse\"\n this.facetTreeFromFacetPathsNotInSearchResponse = {\n path: '/',\n count: 0,\n children: {},\n };\n const collectedFacetArray: FacetWithChildrenArray = {\n path: '/',\n count: 0,\n children: [],\n };\n for (const pathName of Object.keys(this.selectedPaths).filter(\n (path) => this.selectedPaths[path],\n )) {\n const nodePaths = pathName.startsWith('/')\n ? pathName.substring(1).split('/')\n : pathName.split('/');\n\n const wasFoundInFacetTree = !!getFacetTreeNodeAtPath(\n this.facetTreeCollectedFromSearchResponse,\n nodePaths,\n );\n\n const pathKeyName = nodePaths.at(-1);\n if (!wasFoundInFacetTree && pathKeyName) {\n collectedFacetArray.children?.push({\n children: [],\n count: 0,\n path: pathName,\n });\n }\n }\n this.facetTreeFromFacetPathsNotInSearchResponse =\n facetWithChildrenArrayToCompleteFacetTree(collectedFacetArray, this.exclude);\n\n // Merges facetTreeCollectedFromSearchResponse with selectedFacetPathsNotInCurrentFacetTree.\n // This results in a single, final facet tree that gets rendered in as Checkboxes\n this.renderedFacetTree = deepMergeWithSpread(\n this.facetTreeFromFacetPathsNotInSearchResponse,\n this.facetTreeCollectedFromSearchResponse,\n );\n }\n\n handleStateUpdate(_state: SearchcraftState) {\n const state = { ..._state };\n // Determine what action to take based on the current State\n\n // Check if this is an initialQuery case (string requestProperties with empty searchTerm)\n const isInitialQuery =\n typeof state.searchClientRequestProperties === 'string' &&\n state.searchTerm.trim() === '';\n\n if (state.searchTerm.trim() === '' && !isInitialQuery) {\n this.handleIncomingSearchResponse(state, 'SEARCH_TERM_EMPTY');\n this.lastSearchTerm = '';\n } else if (\n this.lastTimeTaken !== state.searchResponseTimeTaken &&\n state.searchClientRequestProperties\n ) {\n // Handle both object and string requestProperties (string is used for initialQuery)\n if (typeof state.searchClientRequestProperties === 'object') {\n const requestProperties = state.searchClientRequestProperties;\n let actionType: HandlerActionType = 'UNKNOWN';\n\n if (this.lastSearchTerm !== requestProperties.searchTerm) {\n if (this.areAnyFacetPathsSelected) {\n actionType = 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE';\n } else {\n actionType = 'NEW_SEARCH_TERM';\n }\n } else if (\n this.lastRangeValues !==\n JSON.stringify(requestProperties.rangeValueForIndexFields)\n ) {\n actionType = 'RANGE_VALUE_UPDATE';\n } else if (\n this.lastFacetValues !==\n JSON.stringify(requestProperties.facetPathsForIndexFields)\n ) {\n actionType = 'FACET_UPDATE';\n } else if (this.lastSortType !== requestProperties.order_by) {\n actionType = 'SORT_ORDER_UPDATE';\n } else if (this.lastSearchMode !== requestProperties.mode) {\n actionType = 'EXACT_MATCH_UPDATE';\n }\n\n this.lastRangeValues = JSON.stringify(\n requestProperties.rangeValueForIndexFields,\n );\n this.lastFacetValues = JSON.stringify(\n requestProperties.facetPathsForIndexFields,\n );\n this.lastSortType = requestProperties.order_by;\n this.lastSearchMode = requestProperties.mode;\n this.lastSearchTerm = requestProperties.searchTerm;\n this.lastTimeTaken = state.searchResponseTimeTaken;\n // Handle the incoming response, using the action we have determined.\n this.handleIncomingSearchResponse(state, actionType);\n } else if (typeof state.searchClientRequestProperties === 'string') {\n // Handle initialQuery case where requestProperties is a string\n // For initialQuery, searchTerm will be empty but we still want to show facets\n let actionType: HandlerActionType = 'NEW_SEARCH_TERM';\n\n // Parse the request to get facet and range filters from the query array\n const requestObj = JSON.parse(state.searchClientRequestProperties);\n const queryArray = Array.isArray(requestObj.query)\n ? requestObj.query\n : [requestObj.query];\n\n // Extract filter queries (those with occur: 'must')\n const filterQueries = queryArray.filter((q: SearchClientQuery) => q.occur === 'must');\n const currentFilters = JSON.stringify(filterQueries);\n\n // Determine the action type based on what changed\n if (this.lastFacetValues !== undefined && this.lastFacetValues !== currentFilters) {\n // Filters have changed (not initial load)\n actionType = 'FACET_UPDATE';\n } else if (state.searchTerm.trim() === '' && this.lastSearchTerm === '') {\n // Initial load or no changes with empty search term\n actionType = 'NEW_SEARCH_TERM';\n } else if (this.lastSearchTerm !== state.searchTerm) {\n // User has typed a new search term after initialQuery\n if (this.areAnyFacetPathsSelected) {\n actionType = 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE';\n } else {\n actionType = 'NEW_SEARCH_TERM';\n }\n }\n\n this.lastFacetValues = currentFilters;\n this.lastSearchTerm = state.searchTerm;\n this.lastTimeTaken = state.searchResponseTimeTaken;\n // Handle the incoming response, using the action we have determined.\n this.handleIncomingSearchResponse(state, actionType);\n }\n }\n }\n\n onCoreAvailable(core: SearchcraftCore) {\n this.handleStateUpdate(core.store.getState());\n\n this.unsubscribe = core.store.subscribe((state) => {\n this.handleStateUpdate(state);\n });\n }\n\n connectedCallback() {\n this.cleanupCore = registry.useCoreInstance(\n this.searchcraftId,\n this.onCoreAvailable.bind(this),\n );\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n this.cleanupCore?.();\n }\n\n handleCheckboxChange(path: string) {\n const isCheckboxChecked = !this.selectedPaths[path];\n\n if (isCheckboxChecked) {\n /**\n * Checkbox Checked: Add to the selectedPaths record\n * Uses spread operator here so UI updates.\n */\n this.selectedPaths = {\n ...this.selectedPaths,\n [path]: true,\n };\n } else {\n /**\n * Checkbox Uncheck: Remove any paths and sub-paths\n */\n const updatedPaths = Object.keys(this.selectedPaths).filter(\n (testPath) => !testPath.includes(path),\n );\n\n this.selectedPaths = updatedPaths.reduce(\n (acc, str) => {\n acc[str] = true;\n return acc;\n },\n {} as Record<string, boolean>,\n );\n }\n\n /**\n * Emit the paths array, with parent paths removed.\n */\n const paths = Object.keys(this.selectedPaths).filter(\n (path) => this.selectedPaths[path],\n );\n const pathsWithParentPathsRemoved = removeSubstringMatches(paths);\n\n this.facetSelectionUpdated?.emit({ paths: pathsWithParentPathsRemoved });\n }\n\n formatFacetName = (name: string): string => {\n const label = name.replace(/^\\//, '');\n return `${label.replace(/-/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase())}`;\n };\n\n renderFacet(keyName: string, facet: FacetWithChildrenObject) {\n let isChildSelected = false;\n for (const path of Object.keys(this.selectedPaths)) {\n if (\n this.selectedPaths[path] &&\n path.startsWith(facet.path) &&\n path.length > facet.path.length\n ) {\n isChildSelected = true;\n }\n }\n\n const isSelected = Object.keys(this.selectedPaths).includes(facet.path);\n\n const shouldRenderChildren =\n (Object.keys(facet.children).length > 0 &&\n (isSelected || isChildSelected)) ||\n keyName === '@@root';\n\n return (\n <div class='searchcraft-facet-list-item'>\n {keyName !== '@@root' && (\n <label class='searchcraft-facet-list-checkbox-label'>\n <div class='searchcraft-facet-list-checkbox-input-wrapper'>\n <input\n class='searchcraft-facet-list-checkbox-input'\n checked={this.selectedPaths[facet.path]}\n onChange={(_event: Event) => {\n this.handleCheckboxChange(facet.path);\n }}\n type='checkbox'\n />\n {isChildSelected ? (\n <div class='searchcraft-facet-list-checkbox-input-dash-icon'>\n <svg viewBox='0 0 14 3' fill='none'>\n <title>Checkbox dash</title>\n <line\n x1='1.5'\n y1='1.5'\n x2='12.5'\n y2='1.5'\n stroke='white'\n stroke-width='3'\n stroke-linecap='round'\n />\n </svg>\n </div>\n ) : (\n <div class='searchcraft-facet-list-checkbox-input-check-icon'>\n <svg width='16' height='16' viewBox='0 0 16 16' fill='none'>\n <title>Checkbox check</title>\n <path\n d='M13.9999 2L5.74988 10L1.99988 6.36364'\n stroke='white'\n stroke-width='3'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </div>\n )}\n </div>\n <span>\n {this.formatFacetName(keyName)} ({facet.count})\n </span>\n </label>\n )}\n {shouldRenderChildren && (\n <div\n class='searchcraft-facet-list'\n style={{\n paddingLeft: keyName !== '@@root' ? '24px' : '0px',\n paddingTop: keyName !== '@@root' ? '6px' : '0px',\n }}\n >\n {Object.keys(facet.children).map((key) => {\n if (facet.children[key]) {\n return this.renderFacet(key, facet.children[key]);\n }\n })}\n </div>\n )}\n </div>\n );\n }\n\n render() {\n if (!this.fieldName) {\n return;\n }\n\n if (\n Object.keys(this.facetTreeCollectedFromSearchResponse.children).length ===\n 0 &&\n (this.lastSearchTerm || '').trim().length === 0\n ) {\n return;\n }\n\n if (\n Object.keys(this.facetTreeCollectedFromSearchResponse.children).length ===\n 0 &&\n (this.lastSearchTerm || '').trim().length > 0\n ) {\n return (\n <p class='searchcraft-facet-list-message'>\n No facets are available for this search query.\n </p>\n );\n }\n\n return (\n <div class='searchcraft-facet-list'>\n {this.renderFacet('@@root', this.renderedFacetTree)}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftFacetList$1, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftFacetList$1, d as defineCustomElement$1 } from './p-e8d97093.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftFacetList = SearchcraftFacetList$1;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, h } from './p-5365011f.js';
|
|
2
2
|
import { r as registry } from './p-e30203b1.js';
|
|
3
|
-
import { d as defineCustomElement$4 } from './p-
|
|
3
|
+
import { d as defineCustomElement$4 } from './p-e8d97093.js';
|
|
4
4
|
import { d as defineCustomElement$3 } from './p-c9b65e8f.js';
|
|
5
5
|
import { d as defineCustomElement$2 } from './p-02ad136b.js';
|
|
6
6
|
|
|
@@ -102,7 +102,7 @@ const SearchcraftFilterPanel$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
102
102
|
* Iterate through `items` and render them based on `type`
|
|
103
103
|
*/
|
|
104
104
|
render() {
|
|
105
|
-
return (h("div", { key: '
|
|
105
|
+
return (h("div", { key: 'ee8974e38b296a1ba27111bc2a4244d8915f5839', class: 'searchcraft-filter-panel' }, this.items.map((filterItem) => {
|
|
106
106
|
switch (filterItem.type) {
|
|
107
107
|
case 'dateRange': {
|
|
108
108
|
const item = filterItem;
|
|
@@ -122,7 +122,7 @@ const SearchcraftFilterPanel$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
122
122
|
case 'facets': {
|
|
123
123
|
const item = filterItem;
|
|
124
124
|
// return "filters-list"
|
|
125
|
-
return (h("div", { class: 'searchcraft-filter-panel-section' }, h("p", { class: 'searchcraft-filter-panel-label' }, filterItem.label), h("searchcraft-facet-list", { fieldName: item.fieldName, onFacetSelectionUpdated: (event) => {
|
|
125
|
+
return (h("div", { class: 'searchcraft-filter-panel-section' }, h("p", { class: 'searchcraft-filter-panel-label' }, filterItem.label), h("searchcraft-facet-list", { fieldName: item.fieldName, exclude: item.options.exclude, onFacetSelectionUpdated: (event) => {
|
|
126
126
|
this.handleFacetSelectionUpdated(item.fieldName, event.detail.paths);
|
|
127
127
|
} })));
|
|
128
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"searchcraft-filter-panel.js","mappings":";;;;;;MAsDaA,wBAAsB;;;;;;;;IAIzB,aAAa,CAAU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,CAAC,KAAK,EACjB,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAC/B,eAAe,EAAE,CAAC,KAAK;4BACrB,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;yBAClD,GACD,EACF;iBACH;gBACD,KAAK,kBAAkB,EAAE;oBACvB,MAAM,IAAI,GAAG,UAAwC,CAAC;oBACtD,QACE,iCACE,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAC/B,eAAe,EAAE,CAAC,KAAK;4BACrB,IAAI,CAAC,6BAA6B,CAChC,IAAI,CAAC,SAAS,EACd,KAAK,CAAC,MAAM,CACb,CAAC;yBACH,GACD,EACF;iBACH;aACF;SACF,CAAC,CACE,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftFilterPanel"],"sources":["src/components/searchcraft-filter-panel/searchcraft-filter-panel.tsx"],"sourcesContent":["import type { SearchcraftCore } from '@classes';\nimport { registry } from '@classes/CoreInstanceRegistry';\nimport { Component, h, Prop, State } from '@stencil/core';\nimport type {\n FilterItem,\n DateRangeFilterItem,\n NumericFilterItem,\n ExactMatchToggleFilterItem,\n FacetsFilterItem,\n MostRecentToggleFilterItem,\n} from '@types';\n\n/**\n * This web component represents a series of filters that allows users to refine and control their search queries by applying various filter criteria.\n *\n * @react-import\n * ```jsx\n * import { SearchcraftFilterPanel } from \"@searchcraft/react-sdk\";\n * ```\n *\n * @vue-import\n * ```jsx\n * import { SearchcraftFilterPanel } from \"@searchcraft/vue-sdk\";\n * ```\n *\n * @js-example\n * ```html\n * <!-- index.html -->\n * <searchcraft-filter-panel />\n * ```\n *\n * ```js\n * // index.js\n * const filterPanel = document.querySelector('searchcraft-filter-panel');\n *\n * if (filterPanel) {\n * filterPanel.items = [];\n * }\n * ```\n *\n * @react-example\n * ```jsx\n * <SearchcraftFilterPanel items={[]} />\n * ```\n *\n * @vue-example\n * ```jsx\n * <SearchcraftFilterPanel :items=\"[]\" />\n * ```\n */\n@Component({\n tag: 'searchcraft-filter-panel',\n shadow: false,\n})\nexport class SearchcraftFilterPanel {\n /**\n * The id of the Searchcraft instance that this component should use.\n */\n @Prop() searchcraftId?: string;\n /**\n * The items to filter.\n */\n @Prop() items: FilterItem[] = [];\n\n @State() lastSearchTerm: string | undefined;\n\n private core?: SearchcraftCore;\n private unsubscribe?: () => void;\n private cleanupCore?: () => void;\n\n onCoreAvailable(core: SearchcraftCore) {\n this.core = core;\n this.setInitialDateRanges();\n this.unsubscribe = core.store.subscribe((state) => {\n if (this.lastSearchTerm !== state.searchTerm) {\n // A place to put actions to do when the query changes\n }\n this.lastSearchTerm = state.searchTerm || '';\n });\n }\n\n componentDidLoad() {\n this.cleanupCore = registry.useCoreInstance(\n this.searchcraftId,\n this.onCoreAvailable.bind(this),\n );\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n this.cleanupCore?.();\n }\n\n /**\n * Sets the initial min/max date range values for search queries based on the filter items provided.\n */\n setInitialDateRanges() {\n for (const item of this.items) {\n if (item.type === 'dateRange') {\n const dateItem = item as DateRangeFilterItem;\n\n const startingMinDate = dateItem.options.minDate;\n const startingMaxDate = dateItem.options.maxDate || new Date();\n\n this.core?.store.getState()?.addRangeValueForIndexField({\n fieldName: dateItem.fieldName,\n value: `${dateItem.fieldName}:[${startingMinDate.toISOString()} TO ${startingMaxDate.toISOString()}]`,\n });\n }\n }\n }\n\n handleDateRangeChanged(item: DateRangeFilterItem, min: number, max: number) {\n const start = new Date(min);\n const end = new Date(max);\n this.core?.store.getState()?.addRangeValueForIndexField({\n fieldName: item.fieldName,\n value: `${item.fieldName}:[${start.toISOString()} TO ${end.toISOString()}]`,\n });\n\n this.core?.store.getState()?.search();\n }\n\n handleNumericRangeChanged(fieldName: string, min: number, max: number) {\n this.core?.store.getState()?.addRangeValueForIndexField({\n fieldName,\n value: `${fieldName}:[${min} TO ${max}]`,\n });\n this.core?.store.getState()?.search();\n }\n\n handleFacetSelectionUpdated(fieldName: string, paths: string[]) {\n if (paths.length > 0) {\n this.core?.store.getState()?.addFacetPathsForIndexField({\n fieldName,\n value: `${fieldName}: IN [${paths.join(' ')}]`,\n });\n } else {\n this.core?.store.getState()?.removeFacetPathsForIndexField(fieldName);\n }\n this.core?.store.getState()?.search();\n }\n\n handleExactMatchToggleUpdated(isActive: boolean) {\n this.core?.store.getState()?.setSearchMode(isActive ? 'exact' : 'fuzzy');\n this.core?.store.getState()?.search();\n }\n\n handleMostRecentToggleUpdated(fieldName: string, isActive: boolean) {\n if (isActive) {\n this.core?.store.getState()?.setSortOrder({\n orderByField: fieldName,\n sortType: 'desc',\n });\n } else {\n this.core?.store.getState()?.setSortOrder({\n orderByField: null,\n sortType: null,\n });\n }\n this.core?.store.getState()?.search();\n }\n\n /**\n * Iterate through `items` and render them based on `type`\n */\n render() {\n return (\n <div class='searchcraft-filter-panel'>\n {this.items.map((filterItem) => {\n switch (filterItem.type) {\n case 'dateRange': {\n const item = filterItem as DateRangeFilterItem;\n const maxDate = item.options.maxDate || new Date();\n\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={item.options.minDate.getTime()}\n max={maxDate.getTime()}\n dataType='date'\n step={1}\n dateGranularity={item.options.granularity}\n onRangeChanged={(event) => {\n this.handleDateRangeChanged(\n item,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'numericRange': {\n const item = filterItem as NumericFilterItem;\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={item.options.min}\n max={item.options.max}\n step={item.options.granularity}\n onRangeChanged={(event) => {\n this.handleNumericRangeChanged(\n item.fieldName,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'facets': {\n const item = filterItem as FacetsFilterItem;\n // return \"filters-list\"\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-facet-list\n fieldName={item.fieldName}\n onFacetSelectionUpdated={(event) => {\n this.handleFacetSelectionUpdated(\n item.fieldName,\n event.detail.paths,\n );\n }}\n />\n </div>\n );\n }\n case 'exactMatchToggle': {\n const item = filterItem as ExactMatchToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleExactMatchToggleUpdated(event.detail);\n }}\n />\n );\n }\n case 'mostRecentToggle': {\n const item = filterItem as MostRecentToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleMostRecentToggleUpdated(\n item.fieldName,\n event.detail,\n );\n }}\n />\n );\n }\n }\n })}\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"searchcraft-filter-panel.js","mappings":";;;;;;MAsDaA,wBAAsB;;;;;;;;IAIzB,aAAa,CAAU;;;;IAIvB,KAAK,GAAiB,EAAE,CAAC;IAExB,cAAc,CAAqB;IAEpC,IAAI,CAAmB;IACvB,WAAW,CAAc;IACzB,WAAW,CAAc;IAEjC,eAAe,CAAC,IAAqB;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK;YAI5C,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;SAC9C,CAAC,CAAC;KACJ;IAED,gBAAgB;QACd,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,eAAe,CACzC,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,eAAe,CAAC,IAAI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BACH,GACD,EACF;iBACH;aACF;SACF,CAAC,CACE,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftFilterPanel"],"sources":["src/components/searchcraft-filter-panel/searchcraft-filter-panel.tsx"],"sourcesContent":["import type { SearchcraftCore } from '@classes';\nimport { registry } from '@classes/CoreInstanceRegistry';\nimport { Component, Prop, State, h } from '@stencil/core';\nimport type {\n DateRangeFilterItem,\n ExactMatchToggleFilterItem,\n FacetsFilterItem,\n FilterItem,\n MostRecentToggleFilterItem,\n NumericFilterItem,\n} from '@types';\n\n/**\n * This web component represents a series of filters that allows users to refine and control their search queries by applying various filter criteria.\n *\n * @react-import\n * ```jsx\n * import { SearchcraftFilterPanel } from \"@searchcraft/react-sdk\";\n * ```\n *\n * @vue-import\n * ```jsx\n * import { SearchcraftFilterPanel } from \"@searchcraft/vue-sdk\";\n * ```\n *\n * @js-example\n * ```html\n * <!-- index.html -->\n * <searchcraft-filter-panel />\n * ```\n *\n * ```js\n * // index.js\n * const filterPanel = document.querySelector('searchcraft-filter-panel');\n *\n * if (filterPanel) {\n * filterPanel.items = [];\n * }\n * ```\n *\n * @react-example\n * ```jsx\n * <SearchcraftFilterPanel items={[]} />\n * ```\n *\n * @vue-example\n * ```jsx\n * <SearchcraftFilterPanel :items=\"[]\" />\n * ```\n */\n@Component({\n tag: 'searchcraft-filter-panel',\n shadow: false,\n})\nexport class SearchcraftFilterPanel {\n /**\n * The id of the Searchcraft instance that this component should use.\n */\n @Prop() searchcraftId?: string;\n /**\n * The items to filter.\n */\n @Prop() items: FilterItem[] = [];\n\n @State() lastSearchTerm: string | undefined;\n\n private core?: SearchcraftCore;\n private unsubscribe?: () => void;\n private cleanupCore?: () => void;\n\n onCoreAvailable(core: SearchcraftCore) {\n this.core = core;\n this.setInitialDateRanges();\n this.unsubscribe = core.store.subscribe((state) => {\n if (this.lastSearchTerm !== state.searchTerm) {\n // A place to put actions to do when the query changes\n }\n this.lastSearchTerm = state.searchTerm || '';\n });\n }\n\n componentDidLoad() {\n this.cleanupCore = registry.useCoreInstance(\n this.searchcraftId,\n this.onCoreAvailable.bind(this),\n );\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n this.cleanupCore?.();\n }\n\n /**\n * Sets the initial min/max date range values for search queries based on the filter items provided.\n */\n setInitialDateRanges() {\n for (const item of this.items) {\n if (item.type === 'dateRange') {\n const dateItem = item as DateRangeFilterItem;\n\n const startingMinDate = dateItem.options.minDate;\n const startingMaxDate = dateItem.options.maxDate || new Date();\n\n this.core?.store.getState()?.addRangeValueForIndexField({\n fieldName: dateItem.fieldName,\n value: `${dateItem.fieldName}:[${startingMinDate.toISOString()} TO ${startingMaxDate.toISOString()}]`,\n });\n }\n }\n }\n\n handleDateRangeChanged(item: DateRangeFilterItem, min: number, max: number) {\n const start = new Date(min);\n const end = new Date(max);\n this.core?.store.getState()?.addRangeValueForIndexField({\n fieldName: item.fieldName,\n value: `${item.fieldName}:[${start.toISOString()} TO ${end.toISOString()}]`,\n });\n\n this.core?.store.getState()?.search();\n }\n\n handleNumericRangeChanged(fieldName: string, min: number, max: number) {\n this.core?.store.getState()?.addRangeValueForIndexField({\n fieldName,\n value: `${fieldName}:[${min} TO ${max}]`,\n });\n this.core?.store.getState()?.search();\n }\n\n handleFacetSelectionUpdated(fieldName: string, paths: string[]) {\n if (paths.length > 0) {\n this.core?.store.getState()?.addFacetPathsForIndexField({\n fieldName,\n value: `${fieldName}: IN [${paths.join(' ')}]`,\n });\n } else {\n this.core?.store.getState()?.removeFacetPathsForIndexField(fieldName);\n }\n this.core?.store.getState()?.search();\n }\n\n handleExactMatchToggleUpdated(isActive: boolean) {\n this.core?.store.getState()?.setSearchMode(isActive ? 'exact' : 'fuzzy');\n this.core?.store.getState()?.search();\n }\n\n handleMostRecentToggleUpdated(fieldName: string, isActive: boolean) {\n if (isActive) {\n this.core?.store.getState()?.setSortOrder({\n orderByField: fieldName,\n sortType: 'desc',\n });\n } else {\n this.core?.store.getState()?.setSortOrder({\n orderByField: null,\n sortType: null,\n });\n }\n this.core?.store.getState()?.search();\n }\n\n /**\n * Iterate through `items` and render them based on `type`\n */\n render() {\n return (\n <div class='searchcraft-filter-panel'>\n {this.items.map((filterItem) => {\n switch (filterItem.type) {\n case 'dateRange': {\n const item = filterItem as DateRangeFilterItem;\n const maxDate = item.options.maxDate || new Date();\n\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={item.options.minDate.getTime()}\n max={maxDate.getTime()}\n dataType='date'\n step={1}\n dateGranularity={item.options.granularity}\n onRangeChanged={(event) => {\n this.handleDateRangeChanged(\n item,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'numericRange': {\n const item = filterItem as NumericFilterItem;\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={item.options.min}\n max={item.options.max}\n step={item.options.granularity}\n onRangeChanged={(event) => {\n this.handleNumericRangeChanged(\n item.fieldName,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'facets': {\n const item = filterItem as FacetsFilterItem;\n // return \"filters-list\"\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-facet-list\n fieldName={item.fieldName}\n exclude={item.options.exclude}\n onFacetSelectionUpdated={(event) => {\n this.handleFacetSelectionUpdated(\n item.fieldName,\n event.detail.paths,\n );\n }}\n />\n </div>\n );\n }\n case 'exactMatchToggle': {\n const item = filterItem as ExactMatchToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleExactMatchToggleUpdated(event.detail);\n }}\n />\n );\n }\n case 'mostRecentToggle': {\n const item = filterItem as MostRecentToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleMostRecentToggleUpdated(\n item.fieldName,\n event.detail,\n );\n }}\n />\n );\n }\n }\n })}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftInputForm$1, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftInputForm$1, d as defineCustomElement$1 } from './p-870f81fd.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftInputForm = SearchcraftInputForm$1;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -17,6 +17,7 @@ const SearchcraftPagination$1 = /*@__PURE__*/ proxyCustomElement(class Searchcra
|
|
|
17
17
|
searchResultsPerPage;
|
|
18
18
|
searchResultsPage;
|
|
19
19
|
searchResultsCount;
|
|
20
|
+
searchClientRequestProperties;
|
|
20
21
|
// local vars
|
|
21
22
|
searchResultsPagesCount = 1;
|
|
22
23
|
searchResultsRangeMin = 1;
|
|
@@ -32,6 +33,7 @@ const SearchcraftPagination$1 = /*@__PURE__*/ proxyCustomElement(class Searchcra
|
|
|
32
33
|
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
33
34
|
this.searchResultsPage = state.searchResultsPage;
|
|
34
35
|
this.searchResultsCount = state.searchResultsCount;
|
|
36
|
+
this.searchClientRequestProperties = state.searchClientRequestProperties;
|
|
35
37
|
// local vars
|
|
36
38
|
this.searchResultsPagesCount = Math.ceil(this.searchResultsCount / this.searchResultsPerPage);
|
|
37
39
|
this.searchResultsRangeMin =
|
|
@@ -91,8 +93,11 @@ const SearchcraftPagination$1 = /*@__PURE__*/ proxyCustomElement(class Searchcra
|
|
|
91
93
|
return (h("li", null, h("span", { class: 'searchcraft-pagination-item searchcraft-pagination-item-active' }, this.searchResultsPage)));
|
|
92
94
|
}
|
|
93
95
|
render() {
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
+
// Check if this is an initialQuery case (string requestProperties with empty searchTerm)
|
|
97
|
+
const isInitialQuery = typeof this.searchClientRequestProperties === 'string' &&
|
|
98
|
+
this.searchTerm.trim() === '';
|
|
99
|
+
// early return if there isn't a searchTerm (unless it's initialQuery) or there is 1 or fewer pages of results
|
|
100
|
+
if ((!this.searchTerm && !isInitialQuery) || this.searchResultsPagesCount <= 1) {
|
|
96
101
|
return;
|
|
97
102
|
}
|
|
98
103
|
return (h("div", { class: 'searchcraft-pagination' }, h("div", { class: 'searchcraft-pagination-control' }, h("searchcraft-button", { disabled: this.searchResultsPage === 1, hierarchy: 'tertiary', onButtonClick: () => this.handleGoToPage(Math.max(1, this.searchResultsPage - 1)), label: 'Previous', iconPosition: 'left', icon: h("svg", { class: 'searchcraft-button-icon', width: '20', height: '20', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' }, h("title", null, "Previous page icon"), h("path", { d: 'M12.5 15L7.5 10L12.5 5', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' })), iconOnly: true })), h("ul", { class: 'searchcraft-pagination-list' }, this.renderOddPaginationItem(1), this.renderEvenPaginationItem(2), this.renderMiddlePaginationItem(), this.renderEvenPaginationItem(this.searchResultsPagesCount > 4
|
|
@@ -107,6 +112,7 @@ const SearchcraftPagination$1 = /*@__PURE__*/ proxyCustomElement(class Searchcra
|
|
|
107
112
|
"searchResultsPerPage": [32],
|
|
108
113
|
"searchResultsPage": [32],
|
|
109
114
|
"searchResultsCount": [32],
|
|
115
|
+
"searchClientRequestProperties": [32],
|
|
110
116
|
"searchResultsPagesCount": [32],
|
|
111
117
|
"searchResultsRangeMin": [32],
|
|
112
118
|
"searchResultsRangeMax": [32],
|