@searchcraft/javascript-sdk 0.11.1 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/dist/components/index.d.ts +44 -2
- package/dist/components/index.js +162 -95
- package/dist/components/index.js.map +1 -1
- package/dist/components/{p-3e41546c.js → p-02ad136b.js} +3 -3
- package/dist/components/{p-3e41546c.js.map → p-02ad136b.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-c8566920.js} +74 -33
- package/dist/components/p-c8566920.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 +22 -4
- package/dist/components/searchcraft-popover-form.js.map +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/components/searchcraft-summary-box.js +42 -10
- package/dist/components/searchcraft-summary-box.js.map +1 -1
- package/dist/components/searchcraft-theme.js +1 -1
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/hydrate/index.js +258 -116
- package/dist/hydrate/index.mjs +258 -116
- package/dist/types/classes/SearchcraftCore.d.ts +1 -1
- package/dist/types/clients/SearchClient.d.ts +1 -0
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +1 -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-popover-form/searchcraft-popover-form.d.ts +10 -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/searchcraft-summary-box/searchcraft-summary-box.d.ts +17 -0
- package/dist/types/components.d.ts +24 -0
- package/dist/types/store/SearchcraftStore.types.d.ts +10 -2
- package/dist/types/types/core-types/Measure.types.d.ts +1 -0
- package/dist/types/types/core-types/SearchcraftConfig.types.d.ts +9 -1
- package/package.json +5 -4
- package/dist/components/p-0c495408.js.map +0 -1
- package/dist/components/p-b7e99386.js.map +0 -1
package/dist/hydrate/index.js
CHANGED
|
@@ -2559,6 +2559,65 @@ class SearchcraftErrorMessage {
|
|
|
2559
2559
|
}; }
|
|
2560
2560
|
}
|
|
2561
2561
|
|
|
2562
|
+
/**
|
|
2563
|
+
* This is the default instance id for searchcraft core instances.
|
|
2564
|
+
* When no id is specified in a component's props, use this one.
|
|
2565
|
+
*/
|
|
2566
|
+
const DEFAULT_CORE_INSTANCE_ID = 'searchcraft';
|
|
2567
|
+
/**
|
|
2568
|
+
* CoreInstanceRegistry
|
|
2569
|
+
*
|
|
2570
|
+
* This class is responsible for managing all of the instances of SearchcraftCore on a page.
|
|
2571
|
+
* It provides a means for consuming components to use the instance of SearchcraftCore that
|
|
2572
|
+
* they need to use when that instance of core gets added to the Registry.
|
|
2573
|
+
*/
|
|
2574
|
+
class CoreInstanceRegistry {
|
|
2575
|
+
coreInstances = {};
|
|
2576
|
+
subscriptions = {};
|
|
2577
|
+
/**
|
|
2578
|
+
* Adds a SearchcraftCore instance to the Registry.
|
|
2579
|
+
*
|
|
2580
|
+
* When the instance is added, iterates through the onAvailable callbacks
|
|
2581
|
+
* that have been subscribed via useCoreInstance.
|
|
2582
|
+
*
|
|
2583
|
+
* @param coreInstance The SearchcraftCore instance to add to the registry
|
|
2584
|
+
* @param searchcraftId The unique identifier for this SearchcraftCore instance.
|
|
2585
|
+
*/
|
|
2586
|
+
addCoreInstance(coreInstance, searchcraftId) {
|
|
2587
|
+
const id = searchcraftId || DEFAULT_CORE_INSTANCE_ID;
|
|
2588
|
+
this.coreInstances[id] = coreInstance;
|
|
2589
|
+
for (const callback of this.subscriptions[id] || []) {
|
|
2590
|
+
callback(coreInstance);
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
/**
|
|
2594
|
+
* Use the specified instance of SearchcraftCore. When the instance becomes available,
|
|
2595
|
+
* the onAvailable callback will be called.
|
|
2596
|
+
*
|
|
2597
|
+
* @param searchcraftId The SearchcraftCore instance to use.
|
|
2598
|
+
* @param onAvailable The callback that gets called when the core instance becomes available.
|
|
2599
|
+
*/
|
|
2600
|
+
useCoreInstance(searchcraftId, onAvailable) {
|
|
2601
|
+
const id = searchcraftId || DEFAULT_CORE_INSTANCE_ID;
|
|
2602
|
+
// If the core instance already is available, call the onAvailable callback immediately.
|
|
2603
|
+
if (this.coreInstances[id]) {
|
|
2604
|
+
onAvailable(this.coreInstances[id]);
|
|
2605
|
+
return () => { };
|
|
2606
|
+
}
|
|
2607
|
+
// Add the callback to the collection of callbacks for this searchcraft instance.
|
|
2608
|
+
if (!this.subscriptions[id]) {
|
|
2609
|
+
this.subscriptions[id] = [];
|
|
2610
|
+
}
|
|
2611
|
+
this.subscriptions[id].push(onAvailable);
|
|
2612
|
+
return () => {
|
|
2613
|
+
if (this.subscriptions[id]) {
|
|
2614
|
+
this.subscriptions[id] = this.subscriptions[id].filter((cb) => cb !== onAvailable);
|
|
2615
|
+
}
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
const registry = new CoreInstanceRegistry();
|
|
2620
|
+
|
|
2562
2621
|
/**
|
|
2563
2622
|
* Helper function for getting a Node (FacetWithChildrenObject)
|
|
2564
2623
|
* at a given path. Traverses the node tree to get the node.
|
|
@@ -4219,65 +4278,6 @@ const html = (strings, ...values) => {
|
|
|
4219
4278
|
return result || '';
|
|
4220
4279
|
};
|
|
4221
4280
|
|
|
4222
|
-
/**
|
|
4223
|
-
* This is the default instance id for searchcraft core instances.
|
|
4224
|
-
* When no id is specified in a component's props, use this one.
|
|
4225
|
-
*/
|
|
4226
|
-
const DEFAULT_CORE_INSTANCE_ID = 'searchcraft';
|
|
4227
|
-
/**
|
|
4228
|
-
* CoreInstanceRegistry
|
|
4229
|
-
*
|
|
4230
|
-
* This class is responsible for managing all of the instances of SearchcraftCore on a page.
|
|
4231
|
-
* It provides a means for consuming components to use the instance of SearchcraftCore that
|
|
4232
|
-
* they need to use when that instance of core gets added to the Registry.
|
|
4233
|
-
*/
|
|
4234
|
-
class CoreInstanceRegistry {
|
|
4235
|
-
coreInstances = {};
|
|
4236
|
-
subscriptions = {};
|
|
4237
|
-
/**
|
|
4238
|
-
* Adds a SearchcraftCore instance to the Registry.
|
|
4239
|
-
*
|
|
4240
|
-
* When the instance is added, iterates through the onAvailable callbacks
|
|
4241
|
-
* that have been subscribed via useCoreInstance.
|
|
4242
|
-
*
|
|
4243
|
-
* @param coreInstance The SearchcraftCore instance to add to the registry
|
|
4244
|
-
* @param searchcraftId The unique identifier for this SearchcraftCore instance.
|
|
4245
|
-
*/
|
|
4246
|
-
addCoreInstance(coreInstance, searchcraftId) {
|
|
4247
|
-
const id = searchcraftId || DEFAULT_CORE_INSTANCE_ID;
|
|
4248
|
-
this.coreInstances[id] = coreInstance;
|
|
4249
|
-
for (const callback of this.subscriptions[id] || []) {
|
|
4250
|
-
callback(coreInstance);
|
|
4251
|
-
}
|
|
4252
|
-
}
|
|
4253
|
-
/**
|
|
4254
|
-
* Use the specified instance of SearchcraftCore. When the instance becomes available,
|
|
4255
|
-
* the onAvailable callback will be called.
|
|
4256
|
-
*
|
|
4257
|
-
* @param searchcraftId The SearchcraftCore instance to use.
|
|
4258
|
-
* @param onAvailable The callback that gets called when the core instance becomes available.
|
|
4259
|
-
*/
|
|
4260
|
-
useCoreInstance(searchcraftId, onAvailable) {
|
|
4261
|
-
const id = searchcraftId || DEFAULT_CORE_INSTANCE_ID;
|
|
4262
|
-
// If the core instance already is available, call the onAvailable callback immediately.
|
|
4263
|
-
if (this.coreInstances[id]) {
|
|
4264
|
-
onAvailable(this.coreInstances[id]);
|
|
4265
|
-
return () => { };
|
|
4266
|
-
}
|
|
4267
|
-
// Add the callback to the collection of callbacks for this searchcraft instance.
|
|
4268
|
-
if (!this.subscriptions[id]) {
|
|
4269
|
-
this.subscriptions[id] = [];
|
|
4270
|
-
}
|
|
4271
|
-
this.subscriptions[id].push(onAvailable);
|
|
4272
|
-
return () => {
|
|
4273
|
-
if (this.subscriptions[id]) {
|
|
4274
|
-
this.subscriptions[id] = this.subscriptions[id].filter((cb) => cb !== onAvailable);
|
|
4275
|
-
}
|
|
4276
|
-
};
|
|
4277
|
-
}
|
|
4278
|
-
}
|
|
4279
|
-
const registry = new CoreInstanceRegistry();
|
|
4280
|
-
|
|
4281
4281
|
/**
|
|
4282
4282
|
* 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.
|
|
4283
4283
|
* It is consumed within the `searchcraft-filter-panel`.
|
|
@@ -4440,45 +4440,86 @@ class SearchcraftFacetList {
|
|
|
4440
4440
|
handleStateUpdate(_state) {
|
|
4441
4441
|
const state = { ..._state };
|
|
4442
4442
|
// Determine what action to take based on the current State
|
|
4443
|
-
if (
|
|
4443
|
+
// Check if this is an initialQuery case (string requestProperties with empty searchTerm)
|
|
4444
|
+
const isInitialQuery = typeof state.searchClientRequestProperties === 'string' &&
|
|
4445
|
+
state.searchTerm.trim() === '';
|
|
4446
|
+
if (state.searchTerm.trim() === '' && !isInitialQuery) {
|
|
4444
4447
|
this.handleIncomingSearchResponse(state, 'SEARCH_TERM_EMPTY');
|
|
4445
4448
|
this.lastSearchTerm = '';
|
|
4446
4449
|
}
|
|
4447
4450
|
else if (this.lastTimeTaken !== state.searchResponseTimeTaken &&
|
|
4448
|
-
state.searchClientRequestProperties
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
if (this.
|
|
4454
|
-
|
|
4451
|
+
state.searchClientRequestProperties) {
|
|
4452
|
+
// Handle both object and string requestProperties (string is used for initialQuery)
|
|
4453
|
+
if (typeof state.searchClientRequestProperties === 'object') {
|
|
4454
|
+
const requestProperties = state.searchClientRequestProperties;
|
|
4455
|
+
let actionType = 'UNKNOWN';
|
|
4456
|
+
if (this.lastSearchTerm !== requestProperties.searchTerm) {
|
|
4457
|
+
if (this.areAnyFacetPathsSelected) {
|
|
4458
|
+
actionType = 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE';
|
|
4459
|
+
}
|
|
4460
|
+
else {
|
|
4461
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
4462
|
+
}
|
|
4455
4463
|
}
|
|
4456
|
-
else
|
|
4457
|
-
|
|
4464
|
+
else if (this.lastRangeValues !==
|
|
4465
|
+
JSON.stringify(requestProperties.rangeValueForIndexFields)) {
|
|
4466
|
+
actionType = 'RANGE_VALUE_UPDATE';
|
|
4458
4467
|
}
|
|
4468
|
+
else if (this.lastFacetValues !==
|
|
4469
|
+
JSON.stringify(requestProperties.facetPathsForIndexFields)) {
|
|
4470
|
+
actionType = 'FACET_UPDATE';
|
|
4471
|
+
}
|
|
4472
|
+
else if (this.lastSortType !== requestProperties.order_by) {
|
|
4473
|
+
actionType = 'SORT_ORDER_UPDATE';
|
|
4474
|
+
}
|
|
4475
|
+
else if (this.lastSearchMode !== requestProperties.mode) {
|
|
4476
|
+
actionType = 'EXACT_MATCH_UPDATE';
|
|
4477
|
+
}
|
|
4478
|
+
this.lastRangeValues = JSON.stringify(requestProperties.rangeValueForIndexFields);
|
|
4479
|
+
this.lastFacetValues = JSON.stringify(requestProperties.facetPathsForIndexFields);
|
|
4480
|
+
this.lastSortType = requestProperties.order_by;
|
|
4481
|
+
this.lastSearchMode = requestProperties.mode;
|
|
4482
|
+
this.lastSearchTerm = requestProperties.searchTerm;
|
|
4483
|
+
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
4484
|
+
// Handle the incoming response, using the action we have determined.
|
|
4485
|
+
this.handleIncomingSearchResponse(state, actionType);
|
|
4459
4486
|
}
|
|
4460
|
-
else if (
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
JSON.
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4487
|
+
else if (typeof state.searchClientRequestProperties === 'string') {
|
|
4488
|
+
// Handle initialQuery case where requestProperties is a string
|
|
4489
|
+
// For initialQuery, searchTerm will be empty but we still want to show facets
|
|
4490
|
+
let actionType = 'NEW_SEARCH_TERM';
|
|
4491
|
+
// Parse the request to get facet and range filters from the query array
|
|
4492
|
+
const requestObj = JSON.parse(state.searchClientRequestProperties);
|
|
4493
|
+
const queryArray = Array.isArray(requestObj.query)
|
|
4494
|
+
? requestObj.query
|
|
4495
|
+
: [requestObj.query];
|
|
4496
|
+
// Extract filter queries (those with occur: 'must')
|
|
4497
|
+
const filterQueries = queryArray.filter((q) => q.occur === 'must');
|
|
4498
|
+
const currentFilters = JSON.stringify(filterQueries);
|
|
4499
|
+
// Determine the action type based on what changed
|
|
4500
|
+
if (this.lastFacetValues !== undefined && this.lastFacetValues !== currentFilters) {
|
|
4501
|
+
// Filters have changed (not initial load)
|
|
4502
|
+
actionType = 'FACET_UPDATE';
|
|
4503
|
+
}
|
|
4504
|
+
else if (state.searchTerm.trim() === '' && this.lastSearchTerm === '') {
|
|
4505
|
+
// Initial load or no changes with empty search term
|
|
4506
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
4507
|
+
}
|
|
4508
|
+
else if (this.lastSearchTerm !== state.searchTerm) {
|
|
4509
|
+
// User has typed a new search term after initialQuery
|
|
4510
|
+
if (this.areAnyFacetPathsSelected) {
|
|
4511
|
+
actionType = 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE';
|
|
4512
|
+
}
|
|
4513
|
+
else {
|
|
4514
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
4515
|
+
}
|
|
4516
|
+
}
|
|
4517
|
+
this.lastFacetValues = currentFilters;
|
|
4518
|
+
this.lastSearchTerm = state.searchTerm;
|
|
4519
|
+
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
4520
|
+
// Handle the incoming response, using the action we have determined.
|
|
4521
|
+
this.handleIncomingSearchResponse(state, actionType);
|
|
4473
4522
|
}
|
|
4474
|
-
this.lastRangeValues = JSON.stringify(requestProperties.rangeValueForIndexFields);
|
|
4475
|
-
this.lastFacetValues = JSON.stringify(requestProperties.facetPathsForIndexFields);
|
|
4476
|
-
this.lastSortType = requestProperties.order_by;
|
|
4477
|
-
this.lastSearchMode = requestProperties.mode;
|
|
4478
|
-
this.lastSearchTerm = requestProperties.searchTerm;
|
|
4479
|
-
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
4480
|
-
// Handle the incoming response, using the action we have determined.
|
|
4481
|
-
this.handleIncomingSearchResponse(state, actionType);
|
|
4482
4523
|
}
|
|
4483
4524
|
}
|
|
4484
4525
|
onCoreAvailable(core) {
|
|
@@ -4718,7 +4759,7 @@ class SearchcraftFilterPanel {
|
|
|
4718
4759
|
* Iterate through `items` and render them based on `type`
|
|
4719
4760
|
*/
|
|
4720
4761
|
render() {
|
|
4721
|
-
return (hAsync("div", { key: '
|
|
4762
|
+
return (hAsync("div", { key: 'ee8974e38b296a1ba27111bc2a4244d8915f5839', class: 'searchcraft-filter-panel' }, this.items.map((filterItem) => {
|
|
4722
4763
|
switch (filterItem.type) {
|
|
4723
4764
|
case 'dateRange': {
|
|
4724
4765
|
const item = filterItem;
|
|
@@ -4837,6 +4878,10 @@ class SearchcraftInputForm {
|
|
|
4837
4878
|
* 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
|
|
4838
4879
|
*/
|
|
4839
4880
|
placeholderBehavior;
|
|
4881
|
+
/**
|
|
4882
|
+
* The value to display in the input field.
|
|
4883
|
+
*/
|
|
4884
|
+
value;
|
|
4840
4885
|
/**
|
|
4841
4886
|
* When the input becomes focused.
|
|
4842
4887
|
*/
|
|
@@ -4857,18 +4902,41 @@ class SearchcraftInputForm {
|
|
|
4857
4902
|
cleanupCore;
|
|
4858
4903
|
init() {
|
|
4859
4904
|
if (this.core) {
|
|
4905
|
+
// Initialize inputValue from prop if provided
|
|
4906
|
+
if (this.value !== undefined && this.value.trim().length > 0) {
|
|
4907
|
+
this.inputValue = this.value;
|
|
4908
|
+
this.core.store.getState().setSearchTerm(this.value);
|
|
4909
|
+
// Trigger search if autoSearch is enabled
|
|
4910
|
+
if (this.autoSearch) {
|
|
4911
|
+
this.core.store.getState().search();
|
|
4912
|
+
}
|
|
4913
|
+
}
|
|
4860
4914
|
this.inputInit?.emit();
|
|
4861
4915
|
}
|
|
4862
4916
|
}
|
|
4863
4917
|
onCoreChange() {
|
|
4864
4918
|
this.init();
|
|
4865
4919
|
}
|
|
4920
|
+
onValueChange(newValue) {
|
|
4921
|
+
if (newValue !== undefined && newValue !== this.inputValue) {
|
|
4922
|
+
this.inputValue = newValue;
|
|
4923
|
+
this.core?.store.getState().setSearchTerm(newValue);
|
|
4924
|
+
// Trigger search if autoSearch is enabled and value is not empty
|
|
4925
|
+
if (this.autoSearch && newValue.trim().length > 0) {
|
|
4926
|
+
this.core?.store.getState().search();
|
|
4927
|
+
}
|
|
4928
|
+
}
|
|
4929
|
+
}
|
|
4866
4930
|
onCoreAvailable(core) {
|
|
4867
4931
|
this.core = core;
|
|
4868
4932
|
this.init();
|
|
4869
4933
|
this.unsubscribe = core.store.subscribe((state) => {
|
|
4870
4934
|
this.searchTerm = state.searchTerm;
|
|
4871
|
-
|
|
4935
|
+
// Only update inputValue from store if value prop is not set
|
|
4936
|
+
// OR if the store was cleared (empty string)
|
|
4937
|
+
if (this.value === undefined || state.searchTerm === '') {
|
|
4938
|
+
this.inputValue = state.searchTerm;
|
|
4939
|
+
}
|
|
4872
4940
|
});
|
|
4873
4941
|
}
|
|
4874
4942
|
connectedCallback() {
|
|
@@ -4897,6 +4965,8 @@ class SearchcraftInputForm {
|
|
|
4897
4965
|
}
|
|
4898
4966
|
};
|
|
4899
4967
|
handleClearInput = () => {
|
|
4968
|
+
// Clear the input value even if controlled by prop
|
|
4969
|
+
this.inputValue = '';
|
|
4900
4970
|
this.core?.store.getState().resetSearchValues();
|
|
4901
4971
|
this.error = false;
|
|
4902
4972
|
};
|
|
@@ -4915,14 +4985,15 @@ class SearchcraftInputForm {
|
|
|
4915
4985
|
const inputGridStyles = {
|
|
4916
4986
|
gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',
|
|
4917
4987
|
};
|
|
4918
|
-
return (hAsync("form", { key: '
|
|
4988
|
+
return (hAsync("form", { key: 'd214ace44e9209154d215e803de088aefa58a285', class: 'searchcraft-input-form', onSubmit: this.handleFormSubmit }, hAsync("div", { key: '5699f5dca28caf5e9584401f1883d2e08d26e3ec', class: inputGridClassNames, style: inputGridStyles }, hAsync("div", { key: 'ef792a946414a680e9c99c145246d00b9b8f2ffb', class: 'searchcraft-input-form-button' }, hAsync("searchcraft-button", { key: 'ba5a8cb98889bb486781af4915a21c94a0b1498a', onButtonClick: this.handleFormSubmit, label: this.buttonLabel })), this.inputLabel && (hAsync("div", { key: 'a9e770ef967f7ab1c6ddf8f87f23cea509894536', class: 'searchcraft-input-form-label' }, hAsync("searchcraft-input-label", { key: '93b29e630e71a3c7724921aa9586aab76e592f4f', label: this.inputLabel }))), this.error && (hAsync("div", { key: '641ef4f468d527c24a1635d49dcbbba03030686f', class: 'searchcraft-input-form-error-message' }, hAsync("searchcraft-error-message", { key: '2d839d17b702fe1b41d7e49aacfc52fb53315766' }, "Something went wrong."))), hAsync("div", { key: 'af0c73478de21447c992bd0037ba007d54f53a86', class: 'searchcraft-input-form-input-wrapper' }, hAsync("input", { key: '3de1be1aa71c143b58cd6080d422410bd400e4e5', autoComplete: 'off', class: classNames('searchcraft-input-form-input', {
|
|
4919
4989
|
'searchcraft-placeholder-hide-on-focus': this.placeholderBehavior === 'hide-on-focus',
|
|
4920
4990
|
}), onFocus: () => this.inputFocus?.emit(), onBlur: () => this.inputBlur?.emit(), onInput: (event) => {
|
|
4921
4991
|
this.handleInput(event);
|
|
4922
|
-
}, placeholder: this.placeholderValue, type: 'text', value: this.inputValue }), hAsync("div", { key: '
|
|
4992
|
+
}, placeholder: this.placeholderValue, type: 'text', value: this.inputValue }), hAsync("div", { key: 'fe9043c046e3b1b91129299f0860919ba8a8416b', class: 'searchcraft-input-form-input-icon' }, hAsync("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' }, hAsync("title", { key: '9db677da65283ff15b0d4e79b5d9daf89637b33f' }, "Search icon"), hAsync("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 && (hAsync("button", { key: 'b7e92b22c3234eb31d85b0aa98d7c682b2fc0021', type: 'button', class: 'searchcraft-input-form-clear-button', onClick: this.handleClearInput }, hAsync("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' }, hAsync("title", { key: 'c62b9d237b3762609fed72e0520322fb5eabe979' }, "Clear icon"), hAsync("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' }))))))));
|
|
4923
4993
|
}
|
|
4924
4994
|
static get watchers() { return {
|
|
4925
|
-
"core": ["onCoreChange"]
|
|
4995
|
+
"core": ["onCoreChange"],
|
|
4996
|
+
"value": ["onValueChange"]
|
|
4926
4997
|
}; }
|
|
4927
4998
|
static get cmpMeta() { return {
|
|
4928
4999
|
"$flags$": 0,
|
|
@@ -4935,6 +5006,7 @@ class SearchcraftInputForm {
|
|
|
4935
5006
|
"inputLabel": [1, "input-label"],
|
|
4936
5007
|
"placeholderValue": [1, "placeholder-value"],
|
|
4937
5008
|
"placeholderBehavior": [1, "placeholder-behavior"],
|
|
5009
|
+
"value": [1],
|
|
4938
5010
|
"inputValue": [32],
|
|
4939
5011
|
"searchTerm": [32],
|
|
4940
5012
|
"error": [32]
|
|
@@ -5046,6 +5118,7 @@ class SearchcraftPagination {
|
|
|
5046
5118
|
searchResultsPerPage;
|
|
5047
5119
|
searchResultsPage;
|
|
5048
5120
|
searchResultsCount;
|
|
5121
|
+
searchClientRequestProperties;
|
|
5049
5122
|
// local vars
|
|
5050
5123
|
searchResultsPagesCount = 1;
|
|
5051
5124
|
searchResultsRangeMin = 1;
|
|
@@ -5061,6 +5134,7 @@ class SearchcraftPagination {
|
|
|
5061
5134
|
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
5062
5135
|
this.searchResultsPage = state.searchResultsPage;
|
|
5063
5136
|
this.searchResultsCount = state.searchResultsCount;
|
|
5137
|
+
this.searchClientRequestProperties = state.searchClientRequestProperties;
|
|
5064
5138
|
// local vars
|
|
5065
5139
|
this.searchResultsPagesCount = Math.ceil(this.searchResultsCount / this.searchResultsPerPage);
|
|
5066
5140
|
this.searchResultsRangeMin =
|
|
@@ -5120,8 +5194,11 @@ class SearchcraftPagination {
|
|
|
5120
5194
|
return (hAsync("li", null, hAsync("span", { class: 'searchcraft-pagination-item searchcraft-pagination-item-active' }, this.searchResultsPage)));
|
|
5121
5195
|
}
|
|
5122
5196
|
render() {
|
|
5123
|
-
//
|
|
5124
|
-
|
|
5197
|
+
// Check if this is an initialQuery case (string requestProperties with empty searchTerm)
|
|
5198
|
+
const isInitialQuery = typeof this.searchClientRequestProperties === 'string' &&
|
|
5199
|
+
this.searchTerm.trim() === '';
|
|
5200
|
+
// early return if there isn't a searchTerm (unless it's initialQuery) or there is 1 or fewer pages of results
|
|
5201
|
+
if ((!this.searchTerm && !isInitialQuery) || this.searchResultsPagesCount <= 1) {
|
|
5125
5202
|
return;
|
|
5126
5203
|
}
|
|
5127
5204
|
return (hAsync("div", { class: 'searchcraft-pagination' }, hAsync("div", { class: 'searchcraft-pagination-control' }, hAsync("searchcraft-button", { disabled: this.searchResultsPage === 1, hierarchy: 'tertiary', onButtonClick: () => this.handleGoToPage(Math.max(1, this.searchResultsPage - 1)), label: 'Previous', iconPosition: 'left', icon: hAsync("svg", { class: 'searchcraft-button-icon', width: '20', height: '20', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' }, hAsync("title", null, "Previous page icon"), hAsync("path", { d: 'M12.5 15L7.5 10L12.5 5', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' })), iconOnly: true })), hAsync("ul", { class: 'searchcraft-pagination-list' }, this.renderOddPaginationItem(1), this.renderEvenPaginationItem(2), this.renderMiddlePaginationItem(), this.renderEvenPaginationItem(this.searchResultsPagesCount > 4
|
|
@@ -5139,6 +5216,7 @@ class SearchcraftPagination {
|
|
|
5139
5216
|
"searchResultsPerPage": [32],
|
|
5140
5217
|
"searchResultsPage": [32],
|
|
5141
5218
|
"searchResultsCount": [32],
|
|
5219
|
+
"searchClientRequestProperties": [32],
|
|
5142
5220
|
"searchResultsPagesCount": [32],
|
|
5143
5221
|
"searchResultsRangeMin": [32],
|
|
5144
5222
|
"searchResultsRangeMax": [32],
|
|
@@ -5438,6 +5516,16 @@ class SearchcraftPopoverForm {
|
|
|
5438
5516
|
* The id of the Searchcraft instance that this component should use.
|
|
5439
5517
|
*/
|
|
5440
5518
|
searchcraftId;
|
|
5519
|
+
/**
|
|
5520
|
+
* The input element's placeholder value.
|
|
5521
|
+
*/
|
|
5522
|
+
placeholderValue = 'Enter Search';
|
|
5523
|
+
/**
|
|
5524
|
+
* The placeholder's render behavior.
|
|
5525
|
+
* 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus.
|
|
5526
|
+
* 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
|
|
5527
|
+
*/
|
|
5528
|
+
placeholderBehavior;
|
|
5441
5529
|
isPopoverVisibleInState = false;
|
|
5442
5530
|
searchClientResponseItems = [];
|
|
5443
5531
|
adClientResponseItems = [];
|
|
@@ -5548,6 +5636,12 @@ class SearchcraftPopoverForm {
|
|
|
5548
5636
|
this.modalElement.popoverResultMappings = this.popoverResultMappings;
|
|
5549
5637
|
this.modalElement.setAttribute('type', 'fullscreen');
|
|
5550
5638
|
this.modalElement.setAttribute('searchcraft-id', this.searchcraftId);
|
|
5639
|
+
if (this.placeholderValue) {
|
|
5640
|
+
this.modalElement.setAttribute('placeholder-value', this.placeholderValue);
|
|
5641
|
+
}
|
|
5642
|
+
if (this.placeholderBehavior) {
|
|
5643
|
+
this.modalElement.setAttribute('placeholder-behavior', this.placeholderBehavior);
|
|
5644
|
+
}
|
|
5551
5645
|
document.body.appendChild(this.modalElement);
|
|
5552
5646
|
}
|
|
5553
5647
|
}
|
|
@@ -5615,20 +5709,20 @@ class SearchcraftPopoverForm {
|
|
|
5615
5709
|
const isListViewVisible = this.hasResultsToShow && this.isFocused;
|
|
5616
5710
|
return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-inline', {
|
|
5617
5711
|
'searchcraft-popover-form-active': isListViewVisible,
|
|
5618
|
-
}) }, hAsync("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-inline-input' }, hAsync("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), searchcraftId: this.searchcraftId })), isListViewVisible && (hAsync("div", { class: 'searchcraft-popover-form-inline-wrapper' }, hAsync("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId }), hAsync("searchcraft-popover-footer", { searchcraftId: this.searchcraftId })))));
|
|
5712
|
+
}) }, hAsync("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-inline-input' }, hAsync("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), searchcraftId: this.searchcraftId, placeholderValue: this.placeholderValue, placeholderBehavior: this.placeholderBehavior })), isListViewVisible && (hAsync("div", { class: 'searchcraft-popover-form-inline-wrapper' }, hAsync("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId }), hAsync("searchcraft-popover-footer", { searchcraftId: this.searchcraftId })))));
|
|
5619
5713
|
}
|
|
5620
5714
|
renderModalPopover() {
|
|
5621
5715
|
if (this.isPopoverVisibleInState) {
|
|
5622
5716
|
return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-modal', {
|
|
5623
5717
|
'searchcraft-popover-form-active': this.hasResultsToShow,
|
|
5624
|
-
}) }, hAsync("div", { class: 'searchcraft-popover-form-modal-backdrop', onClick: this.handleModalBackdropClick }), hAsync("div", { class: 'searchcraft-popover-form-modal-wrapper' }, hAsync("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-modal-input' }, hAsync("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this), searchcraftId: this.searchcraftId }), hAsync("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button searchcraft-popover-form-modal-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), hAsync("div", { class: 'searchcraft-popover-form-modal-popover-list-view' }, this.hasResultsToShow && (hAsync("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId }))), hAsync("searchcraft-popover-footer", { searchcraftId: this.searchcraftId }))));
|
|
5718
|
+
}) }, hAsync("div", { class: 'searchcraft-popover-form-modal-backdrop', onClick: this.handleModalBackdropClick }), hAsync("div", { class: 'searchcraft-popover-form-modal-wrapper' }, hAsync("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-modal-input' }, hAsync("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this), searchcraftId: this.searchcraftId, placeholderValue: this.placeholderValue, placeholderBehavior: this.placeholderBehavior }), hAsync("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button searchcraft-popover-form-modal-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), hAsync("div", { class: 'searchcraft-popover-form-modal-popover-list-view' }, this.hasResultsToShow && (hAsync("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId }))), hAsync("searchcraft-popover-footer", { searchcraftId: this.searchcraftId }))));
|
|
5625
5719
|
}
|
|
5626
5720
|
}
|
|
5627
5721
|
renderFullscreenPopover() {
|
|
5628
5722
|
if (this.isPopoverVisibleInState) {
|
|
5629
5723
|
return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-fullscreen', {
|
|
5630
5724
|
'searchcraft-popover-form-active': this.hasResultsToShow,
|
|
5631
|
-
}) }, hAsync("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-fullscreen-input' }, hAsync("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this), searchcraftId: this.searchcraftId }), hAsync("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button searchcraft-popover-form-fullscreen-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), hAsync("div", { class: 'searchcraft-popover-form-fullscreen-popover-list-view' }, this.hasResultsToShow && (hAsync("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId }))), hAsync("searchcraft-popover-footer", { searchcraftId: this.searchcraftId })));
|
|
5725
|
+
}) }, hAsync("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-fullscreen-input' }, hAsync("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this), searchcraftId: this.searchcraftId, placeholderValue: this.placeholderValue, placeholderBehavior: this.placeholderBehavior }), hAsync("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button searchcraft-popover-form-fullscreen-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), hAsync("div", { class: 'searchcraft-popover-form-fullscreen-popover-list-view' }, this.hasResultsToShow && (hAsync("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId }))), hAsync("searchcraft-popover-footer", { searchcraftId: this.searchcraftId })));
|
|
5632
5726
|
}
|
|
5633
5727
|
}
|
|
5634
5728
|
render() {
|
|
@@ -5650,6 +5744,8 @@ class SearchcraftPopoverForm {
|
|
|
5650
5744
|
"hotkey": [1],
|
|
5651
5745
|
"hotkeyModifier": [1, "hotkey-modifier"],
|
|
5652
5746
|
"searchcraftId": [1, "searchcraft-id"],
|
|
5747
|
+
"placeholderValue": [1, "placeholder-value"],
|
|
5748
|
+
"placeholderBehavior": [1, "placeholder-behavior"],
|
|
5653
5749
|
"isPopoverVisibleInState": [32],
|
|
5654
5750
|
"searchClientResponseItems": [32],
|
|
5655
5751
|
"adClientResponseItems": [32],
|
|
@@ -6144,6 +6240,7 @@ class SearchcraftResultsInfo {
|
|
|
6144
6240
|
searchResultsPage;
|
|
6145
6241
|
searchResultsPerPage;
|
|
6146
6242
|
searchResultsCount;
|
|
6243
|
+
searchClientRequestProperties;
|
|
6147
6244
|
// local vars
|
|
6148
6245
|
count = 0;
|
|
6149
6246
|
range = [0, 0];
|
|
@@ -6157,6 +6254,7 @@ class SearchcraftResultsInfo {
|
|
|
6157
6254
|
this.searchResultsPage = state.searchResultsPage;
|
|
6158
6255
|
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
6159
6256
|
this.searchResultsCount = state.searchResultsCount;
|
|
6257
|
+
this.searchClientRequestProperties = state.searchClientRequestProperties;
|
|
6160
6258
|
// local vars
|
|
6161
6259
|
this.count = this.searchResultsCount;
|
|
6162
6260
|
this.range[0] =
|
|
@@ -6179,7 +6277,12 @@ class SearchcraftResultsInfo {
|
|
|
6179
6277
|
this.cleanupCore?.();
|
|
6180
6278
|
}
|
|
6181
6279
|
render() {
|
|
6182
|
-
if
|
|
6280
|
+
// Check if this is an initialQuery case (string requestProperties with empty searchTerm)
|
|
6281
|
+
const isInitialQuery = typeof this.searchClientRequestProperties === 'string' &&
|
|
6282
|
+
this.searchTerm.trim() === '';
|
|
6283
|
+
// Only hide if there's no search term AND no initialQuery AND no results
|
|
6284
|
+
if ((!this.searchTerm && !isInitialQuery) ||
|
|
6285
|
+
this.searchResultsCount === 0) {
|
|
6183
6286
|
return null;
|
|
6184
6287
|
}
|
|
6185
6288
|
return (hAsync("p", { class: 'searchcraft-results-info' }, typeof this.template !== 'undefined'
|
|
@@ -6200,6 +6303,7 @@ class SearchcraftResultsInfo {
|
|
|
6200
6303
|
"searchResultsPage": [32],
|
|
6201
6304
|
"searchResultsPerPage": [32],
|
|
6202
6305
|
"searchResultsCount": [32],
|
|
6306
|
+
"searchClientRequestProperties": [32],
|
|
6203
6307
|
"count": [32],
|
|
6204
6308
|
"range": [32],
|
|
6205
6309
|
"responseTime": [32]
|
|
@@ -6574,6 +6678,7 @@ class SearchcraftSearchResultsPerPage {
|
|
|
6574
6678
|
searchResultsPerPage;
|
|
6575
6679
|
searchResultsCount;
|
|
6576
6680
|
searchResultsPagesCount;
|
|
6681
|
+
searchClientRequestProperties;
|
|
6577
6682
|
// local vars
|
|
6578
6683
|
initialSearchResultsPerPage;
|
|
6579
6684
|
// store functions
|
|
@@ -6588,6 +6693,7 @@ class SearchcraftSearchResultsPerPage {
|
|
|
6588
6693
|
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
6589
6694
|
this.searchResultsPage = state.searchResultsPage;
|
|
6590
6695
|
this.searchResultsCount = state.searchResultsCount;
|
|
6696
|
+
this.searchClientRequestProperties = state.searchClientRequestProperties;
|
|
6591
6697
|
// local vars
|
|
6592
6698
|
this.searchResultsPagesCount = Math.ceil(this.searchResultsCount / this.searchResultsPerPage);
|
|
6593
6699
|
// store functions
|
|
@@ -6605,8 +6711,11 @@ class SearchcraftSearchResultsPerPage {
|
|
|
6605
6711
|
this.cleanupCore?.();
|
|
6606
6712
|
}
|
|
6607
6713
|
render() {
|
|
6608
|
-
//
|
|
6609
|
-
|
|
6714
|
+
// Check if this is an initialQuery case (string requestProperties with empty searchTerm)
|
|
6715
|
+
const isInitialQuery = typeof this.searchClientRequestProperties === 'string' &&
|
|
6716
|
+
this.searchTerm.trim() === '';
|
|
6717
|
+
// early return if there isn't a searchTerm (unless it's initialQuery) or there is 1 or fewer pages of results
|
|
6718
|
+
if ((!this.searchTerm && !isInitialQuery) || this.searchResultsPagesCount <= 1) {
|
|
6610
6719
|
return;
|
|
6611
6720
|
}
|
|
6612
6721
|
return (hAsync("div", { class: 'searchcraft-search-results-per-page' }, hAsync("div", { class: 'searchcraft-search-results-per-page-select' }, hAsync("label", { class: 'searchcraft-search-results-per-page-select-label', htmlFor: 'searchcraft-search-results-per-page-select-input' }, "Results Per Page"), hAsync("div", { class: 'searchcraft-search-results-per-page-select-input' }, hAsync("searchcraft-select", { inputId: 'searchcraft-search-results-per-page-select-input', name: 'results-per-page', options: [...Array(5)].map((_, index) => {
|
|
@@ -6632,6 +6741,7 @@ class SearchcraftSearchResultsPerPage {
|
|
|
6632
6741
|
"searchResultsPerPage": [32],
|
|
6633
6742
|
"searchResultsCount": [32],
|
|
6634
6743
|
"searchResultsPagesCount": [32],
|
|
6744
|
+
"searchClientRequestProperties": [32],
|
|
6635
6745
|
"initialSearchResultsPerPage": [32],
|
|
6636
6746
|
"setSearchResultsPerPage": [32],
|
|
6637
6747
|
"setSearchResultsPage": [32]
|
|
@@ -9174,19 +9284,13 @@ class SearchcraftSummaryBox {
|
|
|
9174
9284
|
searchcraftId;
|
|
9175
9285
|
summary = '';
|
|
9176
9286
|
isLoading = false;
|
|
9287
|
+
isSummaryNotEnabled = false;
|
|
9177
9288
|
get hostElement() { return getElement(this); }
|
|
9178
9289
|
unsubscribe;
|
|
9179
9290
|
cleanupCore;
|
|
9180
9291
|
onCoreAvailable(core) {
|
|
9181
9292
|
core.store.setState({ hasSummaryBox: true });
|
|
9182
|
-
this.unsubscribe = core.store.subscribe((
|
|
9183
|
-
this.summary = DOMPurify.sanitize(marked_umd.exports.marked.parse(state.summary));
|
|
9184
|
-
this.isLoading = state.isSummaryLoading;
|
|
9185
|
-
const div = this.hostElement?.querySelector('.searchcraft-summary-box-content');
|
|
9186
|
-
if (div) {
|
|
9187
|
-
div.innerHTML = DOMPurify.sanitize(marked_umd.exports.marked.parse(state.summary));
|
|
9188
|
-
}
|
|
9189
|
-
});
|
|
9293
|
+
this.unsubscribe = core.store.subscribe(this.handleStateChange.bind(this));
|
|
9190
9294
|
}
|
|
9191
9295
|
connectedCallback() {
|
|
9192
9296
|
this.cleanupCore = registry.useCoreInstance(this.searchcraftId, this.onCoreAvailable.bind(this));
|
|
@@ -9195,8 +9299,45 @@ class SearchcraftSummaryBox {
|
|
|
9195
9299
|
this.unsubscribe?.();
|
|
9196
9300
|
this.cleanupCore?.();
|
|
9197
9301
|
}
|
|
9302
|
+
/**
|
|
9303
|
+
* Handles state changes from the store and updates component state.
|
|
9304
|
+
*/
|
|
9305
|
+
handleStateChange(state) {
|
|
9306
|
+
this.isLoading = state.isSummaryLoading;
|
|
9307
|
+
this.isSummaryNotEnabled = state.isSummaryNotEnabled;
|
|
9308
|
+
this.summary = this.sanitizeMarkdown(state.summary);
|
|
9309
|
+
// Update DOM directly for performance (avoids re-render)
|
|
9310
|
+
this.updateContentElement(state.summary);
|
|
9311
|
+
}
|
|
9312
|
+
/**
|
|
9313
|
+
* Sanitizes and converts markdown to HTML.
|
|
9314
|
+
*/
|
|
9315
|
+
sanitizeMarkdown(markdown) {
|
|
9316
|
+
return DOMPurify.sanitize(marked_umd.exports.marked.parse(markdown));
|
|
9317
|
+
}
|
|
9318
|
+
/**
|
|
9319
|
+
* Updates the content element directly without triggering a re-render.
|
|
9320
|
+
*/
|
|
9321
|
+
updateContentElement(markdown) {
|
|
9322
|
+
const contentElement = this.hostElement?.querySelector('.searchcraft-summary-box-content');
|
|
9323
|
+
if (contentElement) {
|
|
9324
|
+
contentElement.innerHTML = this.sanitizeMarkdown(markdown);
|
|
9325
|
+
}
|
|
9326
|
+
}
|
|
9327
|
+
/**
|
|
9328
|
+
* Renders the appropriate content based on current state.
|
|
9329
|
+
*/
|
|
9330
|
+
renderContent() {
|
|
9331
|
+
if (this.isLoading) {
|
|
9332
|
+
return hAsync("searchcraft-loading", { label: 'LOADING' });
|
|
9333
|
+
}
|
|
9334
|
+
if (this.isSummaryNotEnabled) {
|
|
9335
|
+
return (hAsync("div", { class: 'searchcraft-summary-box-content' }, "AI summaries are not enabled"));
|
|
9336
|
+
}
|
|
9337
|
+
return hAsync("div", { class: 'searchcraft-summary-box-content' }, this.summary);
|
|
9338
|
+
}
|
|
9198
9339
|
render() {
|
|
9199
|
-
return
|
|
9340
|
+
return hAsync("div", { key: 'c88d0bf7e12ad0fa0c019d207854a6e92babc683', class: 'searchcraft-summary-box' }, this.renderContent());
|
|
9200
9341
|
}
|
|
9201
9342
|
static get cmpMeta() { return {
|
|
9202
9343
|
"$flags$": 0,
|
|
@@ -9204,7 +9345,8 @@ class SearchcraftSummaryBox {
|
|
|
9204
9345
|
"$members$": {
|
|
9205
9346
|
"searchcraftId": [1, "searchcraft-id"],
|
|
9206
9347
|
"summary": [32],
|
|
9207
|
-
"isLoading": [32]
|
|
9348
|
+
"isLoading": [32],
|
|
9349
|
+
"isSummaryNotEnabled": [32]
|
|
9208
9350
|
},
|
|
9209
9351
|
"$listeners$": undefined,
|
|
9210
9352
|
"$lazyBundleId$": "-",
|
|
@@ -9248,7 +9390,7 @@ class SearchcraftTheme {
|
|
|
9248
9390
|
registerInstance(this, hostRef);
|
|
9249
9391
|
}
|
|
9250
9392
|
render() {
|
|
9251
|
-
return hAsync("style", { key: '
|
|
9393
|
+
return hAsync("style", { key: 'ef26626cdfa4fa98d516802d71443c49a9c6ecf9' }, styles);
|
|
9252
9394
|
}
|
|
9253
9395
|
static get cmpMeta() { return {
|
|
9254
9396
|
"$flags$": 0,
|
|
@@ -9312,9 +9454,9 @@ class SearchcraftToggleButton {
|
|
|
9312
9454
|
this.cleanupCore?.();
|
|
9313
9455
|
}
|
|
9314
9456
|
render() {
|
|
9315
|
-
return (hAsync("div", { key: '
|
|
9457
|
+
return (hAsync("div", { key: 'ab1d5ee21c7aaa28af1c405edc986556858366e8', class: classNames('searchcraft-toggle-button', {
|
|
9316
9458
|
'searchcraft-toggle-button-active': this.isActive,
|
|
9317
|
-
}) }, hAsync("div", { key: '
|
|
9459
|
+
}) }, hAsync("div", { key: '44f86a16d796d448bdb2fb3af72d4d8e1484364b' }, hAsync("p", { key: '9fedb38795d6379cae56dc005ab8e4a944b4261b', class: 'searchcraft-toggle-button-label' }, this.label), this.subLabel && (hAsync("p", { key: '44f3d17175184032275fec89a4cfe7f8266b7014', class: 'searchcraft-toggle-button-sub-label' }, this.subLabel))), hAsync("button", { key: '15fc18906ff2fb21fe646a4e3a8a2ace4a37cae2', class: 'searchcraft-toggle-button-background', onClick: this.handleToggle, type: 'button' }, hAsync("div", { key: '716d29c65a199f63f5fd294dc3e3ad2ea4d53aa3', class: 'searchcraft-toggle-button-handle' }))));
|
|
9318
9460
|
}
|
|
9319
9461
|
static get cmpMeta() { return {
|
|
9320
9462
|
"$flags$": 0,
|