@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.mjs
CHANGED
|
@@ -2555,6 +2555,65 @@ class SearchcraftErrorMessage {
|
|
|
2555
2555
|
}; }
|
|
2556
2556
|
}
|
|
2557
2557
|
|
|
2558
|
+
/**
|
|
2559
|
+
* This is the default instance id for searchcraft core instances.
|
|
2560
|
+
* When no id is specified in a component's props, use this one.
|
|
2561
|
+
*/
|
|
2562
|
+
const DEFAULT_CORE_INSTANCE_ID = 'searchcraft';
|
|
2563
|
+
/**
|
|
2564
|
+
* CoreInstanceRegistry
|
|
2565
|
+
*
|
|
2566
|
+
* This class is responsible for managing all of the instances of SearchcraftCore on a page.
|
|
2567
|
+
* It provides a means for consuming components to use the instance of SearchcraftCore that
|
|
2568
|
+
* they need to use when that instance of core gets added to the Registry.
|
|
2569
|
+
*/
|
|
2570
|
+
class CoreInstanceRegistry {
|
|
2571
|
+
coreInstances = {};
|
|
2572
|
+
subscriptions = {};
|
|
2573
|
+
/**
|
|
2574
|
+
* Adds a SearchcraftCore instance to the Registry.
|
|
2575
|
+
*
|
|
2576
|
+
* When the instance is added, iterates through the onAvailable callbacks
|
|
2577
|
+
* that have been subscribed via useCoreInstance.
|
|
2578
|
+
*
|
|
2579
|
+
* @param coreInstance The SearchcraftCore instance to add to the registry
|
|
2580
|
+
* @param searchcraftId The unique identifier for this SearchcraftCore instance.
|
|
2581
|
+
*/
|
|
2582
|
+
addCoreInstance(coreInstance, searchcraftId) {
|
|
2583
|
+
const id = searchcraftId || DEFAULT_CORE_INSTANCE_ID;
|
|
2584
|
+
this.coreInstances[id] = coreInstance;
|
|
2585
|
+
for (const callback of this.subscriptions[id] || []) {
|
|
2586
|
+
callback(coreInstance);
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
/**
|
|
2590
|
+
* Use the specified instance of SearchcraftCore. When the instance becomes available,
|
|
2591
|
+
* the onAvailable callback will be called.
|
|
2592
|
+
*
|
|
2593
|
+
* @param searchcraftId The SearchcraftCore instance to use.
|
|
2594
|
+
* @param onAvailable The callback that gets called when the core instance becomes available.
|
|
2595
|
+
*/
|
|
2596
|
+
useCoreInstance(searchcraftId, onAvailable) {
|
|
2597
|
+
const id = searchcraftId || DEFAULT_CORE_INSTANCE_ID;
|
|
2598
|
+
// If the core instance already is available, call the onAvailable callback immediately.
|
|
2599
|
+
if (this.coreInstances[id]) {
|
|
2600
|
+
onAvailable(this.coreInstances[id]);
|
|
2601
|
+
return () => { };
|
|
2602
|
+
}
|
|
2603
|
+
// Add the callback to the collection of callbacks for this searchcraft instance.
|
|
2604
|
+
if (!this.subscriptions[id]) {
|
|
2605
|
+
this.subscriptions[id] = [];
|
|
2606
|
+
}
|
|
2607
|
+
this.subscriptions[id].push(onAvailable);
|
|
2608
|
+
return () => {
|
|
2609
|
+
if (this.subscriptions[id]) {
|
|
2610
|
+
this.subscriptions[id] = this.subscriptions[id].filter((cb) => cb !== onAvailable);
|
|
2611
|
+
}
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
const registry = new CoreInstanceRegistry();
|
|
2616
|
+
|
|
2558
2617
|
/**
|
|
2559
2618
|
* Helper function for getting a Node (FacetWithChildrenObject)
|
|
2560
2619
|
* at a given path. Traverses the node tree to get the node.
|
|
@@ -4215,65 +4274,6 @@ const html = (strings, ...values) => {
|
|
|
4215
4274
|
return result || '';
|
|
4216
4275
|
};
|
|
4217
4276
|
|
|
4218
|
-
/**
|
|
4219
|
-
* This is the default instance id for searchcraft core instances.
|
|
4220
|
-
* When no id is specified in a component's props, use this one.
|
|
4221
|
-
*/
|
|
4222
|
-
const DEFAULT_CORE_INSTANCE_ID = 'searchcraft';
|
|
4223
|
-
/**
|
|
4224
|
-
* CoreInstanceRegistry
|
|
4225
|
-
*
|
|
4226
|
-
* This class is responsible for managing all of the instances of SearchcraftCore on a page.
|
|
4227
|
-
* It provides a means for consuming components to use the instance of SearchcraftCore that
|
|
4228
|
-
* they need to use when that instance of core gets added to the Registry.
|
|
4229
|
-
*/
|
|
4230
|
-
class CoreInstanceRegistry {
|
|
4231
|
-
coreInstances = {};
|
|
4232
|
-
subscriptions = {};
|
|
4233
|
-
/**
|
|
4234
|
-
* Adds a SearchcraftCore instance to the Registry.
|
|
4235
|
-
*
|
|
4236
|
-
* When the instance is added, iterates through the onAvailable callbacks
|
|
4237
|
-
* that have been subscribed via useCoreInstance.
|
|
4238
|
-
*
|
|
4239
|
-
* @param coreInstance The SearchcraftCore instance to add to the registry
|
|
4240
|
-
* @param searchcraftId The unique identifier for this SearchcraftCore instance.
|
|
4241
|
-
*/
|
|
4242
|
-
addCoreInstance(coreInstance, searchcraftId) {
|
|
4243
|
-
const id = searchcraftId || DEFAULT_CORE_INSTANCE_ID;
|
|
4244
|
-
this.coreInstances[id] = coreInstance;
|
|
4245
|
-
for (const callback of this.subscriptions[id] || []) {
|
|
4246
|
-
callback(coreInstance);
|
|
4247
|
-
}
|
|
4248
|
-
}
|
|
4249
|
-
/**
|
|
4250
|
-
* Use the specified instance of SearchcraftCore. When the instance becomes available,
|
|
4251
|
-
* the onAvailable callback will be called.
|
|
4252
|
-
*
|
|
4253
|
-
* @param searchcraftId The SearchcraftCore instance to use.
|
|
4254
|
-
* @param onAvailable The callback that gets called when the core instance becomes available.
|
|
4255
|
-
*/
|
|
4256
|
-
useCoreInstance(searchcraftId, onAvailable) {
|
|
4257
|
-
const id = searchcraftId || DEFAULT_CORE_INSTANCE_ID;
|
|
4258
|
-
// If the core instance already is available, call the onAvailable callback immediately.
|
|
4259
|
-
if (this.coreInstances[id]) {
|
|
4260
|
-
onAvailable(this.coreInstances[id]);
|
|
4261
|
-
return () => { };
|
|
4262
|
-
}
|
|
4263
|
-
// Add the callback to the collection of callbacks for this searchcraft instance.
|
|
4264
|
-
if (!this.subscriptions[id]) {
|
|
4265
|
-
this.subscriptions[id] = [];
|
|
4266
|
-
}
|
|
4267
|
-
this.subscriptions[id].push(onAvailable);
|
|
4268
|
-
return () => {
|
|
4269
|
-
if (this.subscriptions[id]) {
|
|
4270
|
-
this.subscriptions[id] = this.subscriptions[id].filter((cb) => cb !== onAvailable);
|
|
4271
|
-
}
|
|
4272
|
-
};
|
|
4273
|
-
}
|
|
4274
|
-
}
|
|
4275
|
-
const registry = new CoreInstanceRegistry();
|
|
4276
|
-
|
|
4277
4277
|
/**
|
|
4278
4278
|
* 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.
|
|
4279
4279
|
* It is consumed within the `searchcraft-filter-panel`.
|
|
@@ -4436,45 +4436,86 @@ class SearchcraftFacetList {
|
|
|
4436
4436
|
handleStateUpdate(_state) {
|
|
4437
4437
|
const state = { ..._state };
|
|
4438
4438
|
// Determine what action to take based on the current State
|
|
4439
|
-
if (
|
|
4439
|
+
// Check if this is an initialQuery case (string requestProperties with empty searchTerm)
|
|
4440
|
+
const isInitialQuery = typeof state.searchClientRequestProperties === 'string' &&
|
|
4441
|
+
state.searchTerm.trim() === '';
|
|
4442
|
+
if (state.searchTerm.trim() === '' && !isInitialQuery) {
|
|
4440
4443
|
this.handleIncomingSearchResponse(state, 'SEARCH_TERM_EMPTY');
|
|
4441
4444
|
this.lastSearchTerm = '';
|
|
4442
4445
|
}
|
|
4443
4446
|
else if (this.lastTimeTaken !== state.searchResponseTimeTaken &&
|
|
4444
|
-
state.searchClientRequestProperties
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
if (this.
|
|
4450
|
-
|
|
4447
|
+
state.searchClientRequestProperties) {
|
|
4448
|
+
// Handle both object and string requestProperties (string is used for initialQuery)
|
|
4449
|
+
if (typeof state.searchClientRequestProperties === 'object') {
|
|
4450
|
+
const requestProperties = state.searchClientRequestProperties;
|
|
4451
|
+
let actionType = 'UNKNOWN';
|
|
4452
|
+
if (this.lastSearchTerm !== requestProperties.searchTerm) {
|
|
4453
|
+
if (this.areAnyFacetPathsSelected) {
|
|
4454
|
+
actionType = 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE';
|
|
4455
|
+
}
|
|
4456
|
+
else {
|
|
4457
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
4458
|
+
}
|
|
4451
4459
|
}
|
|
4452
|
-
else
|
|
4453
|
-
|
|
4460
|
+
else if (this.lastRangeValues !==
|
|
4461
|
+
JSON.stringify(requestProperties.rangeValueForIndexFields)) {
|
|
4462
|
+
actionType = 'RANGE_VALUE_UPDATE';
|
|
4454
4463
|
}
|
|
4464
|
+
else if (this.lastFacetValues !==
|
|
4465
|
+
JSON.stringify(requestProperties.facetPathsForIndexFields)) {
|
|
4466
|
+
actionType = 'FACET_UPDATE';
|
|
4467
|
+
}
|
|
4468
|
+
else if (this.lastSortType !== requestProperties.order_by) {
|
|
4469
|
+
actionType = 'SORT_ORDER_UPDATE';
|
|
4470
|
+
}
|
|
4471
|
+
else if (this.lastSearchMode !== requestProperties.mode) {
|
|
4472
|
+
actionType = 'EXACT_MATCH_UPDATE';
|
|
4473
|
+
}
|
|
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);
|
|
4455
4482
|
}
|
|
4456
|
-
else if (
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
JSON.
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4483
|
+
else if (typeof state.searchClientRequestProperties === 'string') {
|
|
4484
|
+
// Handle initialQuery case where requestProperties is a string
|
|
4485
|
+
// For initialQuery, searchTerm will be empty but we still want to show facets
|
|
4486
|
+
let actionType = 'NEW_SEARCH_TERM';
|
|
4487
|
+
// Parse the request to get facet and range filters from the query array
|
|
4488
|
+
const requestObj = JSON.parse(state.searchClientRequestProperties);
|
|
4489
|
+
const queryArray = Array.isArray(requestObj.query)
|
|
4490
|
+
? requestObj.query
|
|
4491
|
+
: [requestObj.query];
|
|
4492
|
+
// Extract filter queries (those with occur: 'must')
|
|
4493
|
+
const filterQueries = queryArray.filter((q) => q.occur === 'must');
|
|
4494
|
+
const currentFilters = JSON.stringify(filterQueries);
|
|
4495
|
+
// Determine the action type based on what changed
|
|
4496
|
+
if (this.lastFacetValues !== undefined && this.lastFacetValues !== currentFilters) {
|
|
4497
|
+
// Filters have changed (not initial load)
|
|
4498
|
+
actionType = 'FACET_UPDATE';
|
|
4499
|
+
}
|
|
4500
|
+
else if (state.searchTerm.trim() === '' && this.lastSearchTerm === '') {
|
|
4501
|
+
// Initial load or no changes with empty search term
|
|
4502
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
4503
|
+
}
|
|
4504
|
+
else if (this.lastSearchTerm !== state.searchTerm) {
|
|
4505
|
+
// User has typed a new search term after initialQuery
|
|
4506
|
+
if (this.areAnyFacetPathsSelected) {
|
|
4507
|
+
actionType = 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE';
|
|
4508
|
+
}
|
|
4509
|
+
else {
|
|
4510
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
4511
|
+
}
|
|
4512
|
+
}
|
|
4513
|
+
this.lastFacetValues = currentFilters;
|
|
4514
|
+
this.lastSearchTerm = state.searchTerm;
|
|
4515
|
+
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
4516
|
+
// Handle the incoming response, using the action we have determined.
|
|
4517
|
+
this.handleIncomingSearchResponse(state, actionType);
|
|
4469
4518
|
}
|
|
4470
|
-
this.lastRangeValues = JSON.stringify(requestProperties.rangeValueForIndexFields);
|
|
4471
|
-
this.lastFacetValues = JSON.stringify(requestProperties.facetPathsForIndexFields);
|
|
4472
|
-
this.lastSortType = requestProperties.order_by;
|
|
4473
|
-
this.lastSearchMode = requestProperties.mode;
|
|
4474
|
-
this.lastSearchTerm = requestProperties.searchTerm;
|
|
4475
|
-
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
4476
|
-
// Handle the incoming response, using the action we have determined.
|
|
4477
|
-
this.handleIncomingSearchResponse(state, actionType);
|
|
4478
4519
|
}
|
|
4479
4520
|
}
|
|
4480
4521
|
onCoreAvailable(core) {
|
|
@@ -4714,7 +4755,7 @@ class SearchcraftFilterPanel {
|
|
|
4714
4755
|
* Iterate through `items` and render them based on `type`
|
|
4715
4756
|
*/
|
|
4716
4757
|
render() {
|
|
4717
|
-
return (hAsync("div", { key: '
|
|
4758
|
+
return (hAsync("div", { key: 'ee8974e38b296a1ba27111bc2a4244d8915f5839', class: 'searchcraft-filter-panel' }, this.items.map((filterItem) => {
|
|
4718
4759
|
switch (filterItem.type) {
|
|
4719
4760
|
case 'dateRange': {
|
|
4720
4761
|
const item = filterItem;
|
|
@@ -4833,6 +4874,10 @@ class SearchcraftInputForm {
|
|
|
4833
4874
|
* 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
|
|
4834
4875
|
*/
|
|
4835
4876
|
placeholderBehavior;
|
|
4877
|
+
/**
|
|
4878
|
+
* The value to display in the input field.
|
|
4879
|
+
*/
|
|
4880
|
+
value;
|
|
4836
4881
|
/**
|
|
4837
4882
|
* When the input becomes focused.
|
|
4838
4883
|
*/
|
|
@@ -4853,18 +4898,41 @@ class SearchcraftInputForm {
|
|
|
4853
4898
|
cleanupCore;
|
|
4854
4899
|
init() {
|
|
4855
4900
|
if (this.core) {
|
|
4901
|
+
// Initialize inputValue from prop if provided
|
|
4902
|
+
if (this.value !== undefined && this.value.trim().length > 0) {
|
|
4903
|
+
this.inputValue = this.value;
|
|
4904
|
+
this.core.store.getState().setSearchTerm(this.value);
|
|
4905
|
+
// Trigger search if autoSearch is enabled
|
|
4906
|
+
if (this.autoSearch) {
|
|
4907
|
+
this.core.store.getState().search();
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4856
4910
|
this.inputInit?.emit();
|
|
4857
4911
|
}
|
|
4858
4912
|
}
|
|
4859
4913
|
onCoreChange() {
|
|
4860
4914
|
this.init();
|
|
4861
4915
|
}
|
|
4916
|
+
onValueChange(newValue) {
|
|
4917
|
+
if (newValue !== undefined && newValue !== this.inputValue) {
|
|
4918
|
+
this.inputValue = newValue;
|
|
4919
|
+
this.core?.store.getState().setSearchTerm(newValue);
|
|
4920
|
+
// Trigger search if autoSearch is enabled and value is not empty
|
|
4921
|
+
if (this.autoSearch && newValue.trim().length > 0) {
|
|
4922
|
+
this.core?.store.getState().search();
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
}
|
|
4862
4926
|
onCoreAvailable(core) {
|
|
4863
4927
|
this.core = core;
|
|
4864
4928
|
this.init();
|
|
4865
4929
|
this.unsubscribe = core.store.subscribe((state) => {
|
|
4866
4930
|
this.searchTerm = state.searchTerm;
|
|
4867
|
-
|
|
4931
|
+
// Only update inputValue from store if value prop is not set
|
|
4932
|
+
// OR if the store was cleared (empty string)
|
|
4933
|
+
if (this.value === undefined || state.searchTerm === '') {
|
|
4934
|
+
this.inputValue = state.searchTerm;
|
|
4935
|
+
}
|
|
4868
4936
|
});
|
|
4869
4937
|
}
|
|
4870
4938
|
connectedCallback() {
|
|
@@ -4893,6 +4961,8 @@ class SearchcraftInputForm {
|
|
|
4893
4961
|
}
|
|
4894
4962
|
};
|
|
4895
4963
|
handleClearInput = () => {
|
|
4964
|
+
// Clear the input value even if controlled by prop
|
|
4965
|
+
this.inputValue = '';
|
|
4896
4966
|
this.core?.store.getState().resetSearchValues();
|
|
4897
4967
|
this.error = false;
|
|
4898
4968
|
};
|
|
@@ -4911,14 +4981,15 @@ class SearchcraftInputForm {
|
|
|
4911
4981
|
const inputGridStyles = {
|
|
4912
4982
|
gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',
|
|
4913
4983
|
};
|
|
4914
|
-
return (hAsync("form", { key: '
|
|
4984
|
+
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', {
|
|
4915
4985
|
'searchcraft-placeholder-hide-on-focus': this.placeholderBehavior === 'hide-on-focus',
|
|
4916
4986
|
}), onFocus: () => this.inputFocus?.emit(), onBlur: () => this.inputBlur?.emit(), onInput: (event) => {
|
|
4917
4987
|
this.handleInput(event);
|
|
4918
|
-
}, placeholder: this.placeholderValue, type: 'text', value: this.inputValue }), hAsync("div", { key: '
|
|
4988
|
+
}, 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' }))))))));
|
|
4919
4989
|
}
|
|
4920
4990
|
static get watchers() { return {
|
|
4921
|
-
"core": ["onCoreChange"]
|
|
4991
|
+
"core": ["onCoreChange"],
|
|
4992
|
+
"value": ["onValueChange"]
|
|
4922
4993
|
}; }
|
|
4923
4994
|
static get cmpMeta() { return {
|
|
4924
4995
|
"$flags$": 0,
|
|
@@ -4931,6 +5002,7 @@ class SearchcraftInputForm {
|
|
|
4931
5002
|
"inputLabel": [1, "input-label"],
|
|
4932
5003
|
"placeholderValue": [1, "placeholder-value"],
|
|
4933
5004
|
"placeholderBehavior": [1, "placeholder-behavior"],
|
|
5005
|
+
"value": [1],
|
|
4934
5006
|
"inputValue": [32],
|
|
4935
5007
|
"searchTerm": [32],
|
|
4936
5008
|
"error": [32]
|
|
@@ -5042,6 +5114,7 @@ class SearchcraftPagination {
|
|
|
5042
5114
|
searchResultsPerPage;
|
|
5043
5115
|
searchResultsPage;
|
|
5044
5116
|
searchResultsCount;
|
|
5117
|
+
searchClientRequestProperties;
|
|
5045
5118
|
// local vars
|
|
5046
5119
|
searchResultsPagesCount = 1;
|
|
5047
5120
|
searchResultsRangeMin = 1;
|
|
@@ -5057,6 +5130,7 @@ class SearchcraftPagination {
|
|
|
5057
5130
|
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
5058
5131
|
this.searchResultsPage = state.searchResultsPage;
|
|
5059
5132
|
this.searchResultsCount = state.searchResultsCount;
|
|
5133
|
+
this.searchClientRequestProperties = state.searchClientRequestProperties;
|
|
5060
5134
|
// local vars
|
|
5061
5135
|
this.searchResultsPagesCount = Math.ceil(this.searchResultsCount / this.searchResultsPerPage);
|
|
5062
5136
|
this.searchResultsRangeMin =
|
|
@@ -5116,8 +5190,11 @@ class SearchcraftPagination {
|
|
|
5116
5190
|
return (hAsync("li", null, hAsync("span", { class: 'searchcraft-pagination-item searchcraft-pagination-item-active' }, this.searchResultsPage)));
|
|
5117
5191
|
}
|
|
5118
5192
|
render() {
|
|
5119
|
-
//
|
|
5120
|
-
|
|
5193
|
+
// Check if this is an initialQuery case (string requestProperties with empty searchTerm)
|
|
5194
|
+
const isInitialQuery = typeof this.searchClientRequestProperties === 'string' &&
|
|
5195
|
+
this.searchTerm.trim() === '';
|
|
5196
|
+
// early return if there isn't a searchTerm (unless it's initialQuery) or there is 1 or fewer pages of results
|
|
5197
|
+
if ((!this.searchTerm && !isInitialQuery) || this.searchResultsPagesCount <= 1) {
|
|
5121
5198
|
return;
|
|
5122
5199
|
}
|
|
5123
5200
|
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
|
|
@@ -5135,6 +5212,7 @@ class SearchcraftPagination {
|
|
|
5135
5212
|
"searchResultsPerPage": [32],
|
|
5136
5213
|
"searchResultsPage": [32],
|
|
5137
5214
|
"searchResultsCount": [32],
|
|
5215
|
+
"searchClientRequestProperties": [32],
|
|
5138
5216
|
"searchResultsPagesCount": [32],
|
|
5139
5217
|
"searchResultsRangeMin": [32],
|
|
5140
5218
|
"searchResultsRangeMax": [32],
|
|
@@ -5434,6 +5512,16 @@ class SearchcraftPopoverForm {
|
|
|
5434
5512
|
* The id of the Searchcraft instance that this component should use.
|
|
5435
5513
|
*/
|
|
5436
5514
|
searchcraftId;
|
|
5515
|
+
/**
|
|
5516
|
+
* The input element's placeholder value.
|
|
5517
|
+
*/
|
|
5518
|
+
placeholderValue = 'Enter Search';
|
|
5519
|
+
/**
|
|
5520
|
+
* The placeholder's render behavior.
|
|
5521
|
+
* 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus.
|
|
5522
|
+
* 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
|
|
5523
|
+
*/
|
|
5524
|
+
placeholderBehavior;
|
|
5437
5525
|
isPopoverVisibleInState = false;
|
|
5438
5526
|
searchClientResponseItems = [];
|
|
5439
5527
|
adClientResponseItems = [];
|
|
@@ -5544,6 +5632,12 @@ class SearchcraftPopoverForm {
|
|
|
5544
5632
|
this.modalElement.popoverResultMappings = this.popoverResultMappings;
|
|
5545
5633
|
this.modalElement.setAttribute('type', 'fullscreen');
|
|
5546
5634
|
this.modalElement.setAttribute('searchcraft-id', this.searchcraftId);
|
|
5635
|
+
if (this.placeholderValue) {
|
|
5636
|
+
this.modalElement.setAttribute('placeholder-value', this.placeholderValue);
|
|
5637
|
+
}
|
|
5638
|
+
if (this.placeholderBehavior) {
|
|
5639
|
+
this.modalElement.setAttribute('placeholder-behavior', this.placeholderBehavior);
|
|
5640
|
+
}
|
|
5547
5641
|
document.body.appendChild(this.modalElement);
|
|
5548
5642
|
}
|
|
5549
5643
|
}
|
|
@@ -5611,20 +5705,20 @@ class SearchcraftPopoverForm {
|
|
|
5611
5705
|
const isListViewVisible = this.hasResultsToShow && this.isFocused;
|
|
5612
5706
|
return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-inline', {
|
|
5613
5707
|
'searchcraft-popover-form-active': isListViewVisible,
|
|
5614
|
-
}) }, 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 })))));
|
|
5708
|
+
}) }, 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 })))));
|
|
5615
5709
|
}
|
|
5616
5710
|
renderModalPopover() {
|
|
5617
5711
|
if (this.isPopoverVisibleInState) {
|
|
5618
5712
|
return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-modal', {
|
|
5619
5713
|
'searchcraft-popover-form-active': this.hasResultsToShow,
|
|
5620
|
-
}) }, 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 }))));
|
|
5714
|
+
}) }, 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 }))));
|
|
5621
5715
|
}
|
|
5622
5716
|
}
|
|
5623
5717
|
renderFullscreenPopover() {
|
|
5624
5718
|
if (this.isPopoverVisibleInState) {
|
|
5625
5719
|
return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-fullscreen', {
|
|
5626
5720
|
'searchcraft-popover-form-active': this.hasResultsToShow,
|
|
5627
|
-
}) }, 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 })));
|
|
5721
|
+
}) }, 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 })));
|
|
5628
5722
|
}
|
|
5629
5723
|
}
|
|
5630
5724
|
render() {
|
|
@@ -5646,6 +5740,8 @@ class SearchcraftPopoverForm {
|
|
|
5646
5740
|
"hotkey": [1],
|
|
5647
5741
|
"hotkeyModifier": [1, "hotkey-modifier"],
|
|
5648
5742
|
"searchcraftId": [1, "searchcraft-id"],
|
|
5743
|
+
"placeholderValue": [1, "placeholder-value"],
|
|
5744
|
+
"placeholderBehavior": [1, "placeholder-behavior"],
|
|
5649
5745
|
"isPopoverVisibleInState": [32],
|
|
5650
5746
|
"searchClientResponseItems": [32],
|
|
5651
5747
|
"adClientResponseItems": [32],
|
|
@@ -6140,6 +6236,7 @@ class SearchcraftResultsInfo {
|
|
|
6140
6236
|
searchResultsPage;
|
|
6141
6237
|
searchResultsPerPage;
|
|
6142
6238
|
searchResultsCount;
|
|
6239
|
+
searchClientRequestProperties;
|
|
6143
6240
|
// local vars
|
|
6144
6241
|
count = 0;
|
|
6145
6242
|
range = [0, 0];
|
|
@@ -6153,6 +6250,7 @@ class SearchcraftResultsInfo {
|
|
|
6153
6250
|
this.searchResultsPage = state.searchResultsPage;
|
|
6154
6251
|
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
6155
6252
|
this.searchResultsCount = state.searchResultsCount;
|
|
6253
|
+
this.searchClientRequestProperties = state.searchClientRequestProperties;
|
|
6156
6254
|
// local vars
|
|
6157
6255
|
this.count = this.searchResultsCount;
|
|
6158
6256
|
this.range[0] =
|
|
@@ -6175,7 +6273,12 @@ class SearchcraftResultsInfo {
|
|
|
6175
6273
|
this.cleanupCore?.();
|
|
6176
6274
|
}
|
|
6177
6275
|
render() {
|
|
6178
|
-
if
|
|
6276
|
+
// Check if this is an initialQuery case (string requestProperties with empty searchTerm)
|
|
6277
|
+
const isInitialQuery = typeof this.searchClientRequestProperties === 'string' &&
|
|
6278
|
+
this.searchTerm.trim() === '';
|
|
6279
|
+
// Only hide if there's no search term AND no initialQuery AND no results
|
|
6280
|
+
if ((!this.searchTerm && !isInitialQuery) ||
|
|
6281
|
+
this.searchResultsCount === 0) {
|
|
6179
6282
|
return null;
|
|
6180
6283
|
}
|
|
6181
6284
|
return (hAsync("p", { class: 'searchcraft-results-info' }, typeof this.template !== 'undefined'
|
|
@@ -6196,6 +6299,7 @@ class SearchcraftResultsInfo {
|
|
|
6196
6299
|
"searchResultsPage": [32],
|
|
6197
6300
|
"searchResultsPerPage": [32],
|
|
6198
6301
|
"searchResultsCount": [32],
|
|
6302
|
+
"searchClientRequestProperties": [32],
|
|
6199
6303
|
"count": [32],
|
|
6200
6304
|
"range": [32],
|
|
6201
6305
|
"responseTime": [32]
|
|
@@ -6570,6 +6674,7 @@ class SearchcraftSearchResultsPerPage {
|
|
|
6570
6674
|
searchResultsPerPage;
|
|
6571
6675
|
searchResultsCount;
|
|
6572
6676
|
searchResultsPagesCount;
|
|
6677
|
+
searchClientRequestProperties;
|
|
6573
6678
|
// local vars
|
|
6574
6679
|
initialSearchResultsPerPage;
|
|
6575
6680
|
// store functions
|
|
@@ -6584,6 +6689,7 @@ class SearchcraftSearchResultsPerPage {
|
|
|
6584
6689
|
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
6585
6690
|
this.searchResultsPage = state.searchResultsPage;
|
|
6586
6691
|
this.searchResultsCount = state.searchResultsCount;
|
|
6692
|
+
this.searchClientRequestProperties = state.searchClientRequestProperties;
|
|
6587
6693
|
// local vars
|
|
6588
6694
|
this.searchResultsPagesCount = Math.ceil(this.searchResultsCount / this.searchResultsPerPage);
|
|
6589
6695
|
// store functions
|
|
@@ -6601,8 +6707,11 @@ class SearchcraftSearchResultsPerPage {
|
|
|
6601
6707
|
this.cleanupCore?.();
|
|
6602
6708
|
}
|
|
6603
6709
|
render() {
|
|
6604
|
-
//
|
|
6605
|
-
|
|
6710
|
+
// Check if this is an initialQuery case (string requestProperties with empty searchTerm)
|
|
6711
|
+
const isInitialQuery = typeof this.searchClientRequestProperties === 'string' &&
|
|
6712
|
+
this.searchTerm.trim() === '';
|
|
6713
|
+
// early return if there isn't a searchTerm (unless it's initialQuery) or there is 1 or fewer pages of results
|
|
6714
|
+
if ((!this.searchTerm && !isInitialQuery) || this.searchResultsPagesCount <= 1) {
|
|
6606
6715
|
return;
|
|
6607
6716
|
}
|
|
6608
6717
|
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) => {
|
|
@@ -6628,6 +6737,7 @@ class SearchcraftSearchResultsPerPage {
|
|
|
6628
6737
|
"searchResultsPerPage": [32],
|
|
6629
6738
|
"searchResultsCount": [32],
|
|
6630
6739
|
"searchResultsPagesCount": [32],
|
|
6740
|
+
"searchClientRequestProperties": [32],
|
|
6631
6741
|
"initialSearchResultsPerPage": [32],
|
|
6632
6742
|
"setSearchResultsPerPage": [32],
|
|
6633
6743
|
"setSearchResultsPage": [32]
|
|
@@ -9170,19 +9280,13 @@ class SearchcraftSummaryBox {
|
|
|
9170
9280
|
searchcraftId;
|
|
9171
9281
|
summary = '';
|
|
9172
9282
|
isLoading = false;
|
|
9283
|
+
isSummaryNotEnabled = false;
|
|
9173
9284
|
get hostElement() { return getElement(this); }
|
|
9174
9285
|
unsubscribe;
|
|
9175
9286
|
cleanupCore;
|
|
9176
9287
|
onCoreAvailable(core) {
|
|
9177
9288
|
core.store.setState({ hasSummaryBox: true });
|
|
9178
|
-
this.unsubscribe = core.store.subscribe((
|
|
9179
|
-
this.summary = DOMPurify.sanitize(marked_umd.exports.marked.parse(state.summary));
|
|
9180
|
-
this.isLoading = state.isSummaryLoading;
|
|
9181
|
-
const div = this.hostElement?.querySelector('.searchcraft-summary-box-content');
|
|
9182
|
-
if (div) {
|
|
9183
|
-
div.innerHTML = DOMPurify.sanitize(marked_umd.exports.marked.parse(state.summary));
|
|
9184
|
-
}
|
|
9185
|
-
});
|
|
9289
|
+
this.unsubscribe = core.store.subscribe(this.handleStateChange.bind(this));
|
|
9186
9290
|
}
|
|
9187
9291
|
connectedCallback() {
|
|
9188
9292
|
this.cleanupCore = registry.useCoreInstance(this.searchcraftId, this.onCoreAvailable.bind(this));
|
|
@@ -9191,8 +9295,45 @@ class SearchcraftSummaryBox {
|
|
|
9191
9295
|
this.unsubscribe?.();
|
|
9192
9296
|
this.cleanupCore?.();
|
|
9193
9297
|
}
|
|
9298
|
+
/**
|
|
9299
|
+
* Handles state changes from the store and updates component state.
|
|
9300
|
+
*/
|
|
9301
|
+
handleStateChange(state) {
|
|
9302
|
+
this.isLoading = state.isSummaryLoading;
|
|
9303
|
+
this.isSummaryNotEnabled = state.isSummaryNotEnabled;
|
|
9304
|
+
this.summary = this.sanitizeMarkdown(state.summary);
|
|
9305
|
+
// Update DOM directly for performance (avoids re-render)
|
|
9306
|
+
this.updateContentElement(state.summary);
|
|
9307
|
+
}
|
|
9308
|
+
/**
|
|
9309
|
+
* Sanitizes and converts markdown to HTML.
|
|
9310
|
+
*/
|
|
9311
|
+
sanitizeMarkdown(markdown) {
|
|
9312
|
+
return DOMPurify.sanitize(marked_umd.exports.marked.parse(markdown));
|
|
9313
|
+
}
|
|
9314
|
+
/**
|
|
9315
|
+
* Updates the content element directly without triggering a re-render.
|
|
9316
|
+
*/
|
|
9317
|
+
updateContentElement(markdown) {
|
|
9318
|
+
const contentElement = this.hostElement?.querySelector('.searchcraft-summary-box-content');
|
|
9319
|
+
if (contentElement) {
|
|
9320
|
+
contentElement.innerHTML = this.sanitizeMarkdown(markdown);
|
|
9321
|
+
}
|
|
9322
|
+
}
|
|
9323
|
+
/**
|
|
9324
|
+
* Renders the appropriate content based on current state.
|
|
9325
|
+
*/
|
|
9326
|
+
renderContent() {
|
|
9327
|
+
if (this.isLoading) {
|
|
9328
|
+
return hAsync("searchcraft-loading", { label: 'LOADING' });
|
|
9329
|
+
}
|
|
9330
|
+
if (this.isSummaryNotEnabled) {
|
|
9331
|
+
return (hAsync("div", { class: 'searchcraft-summary-box-content' }, "AI summaries are not enabled"));
|
|
9332
|
+
}
|
|
9333
|
+
return hAsync("div", { class: 'searchcraft-summary-box-content' }, this.summary);
|
|
9334
|
+
}
|
|
9194
9335
|
render() {
|
|
9195
|
-
return
|
|
9336
|
+
return hAsync("div", { key: 'c88d0bf7e12ad0fa0c019d207854a6e92babc683', class: 'searchcraft-summary-box' }, this.renderContent());
|
|
9196
9337
|
}
|
|
9197
9338
|
static get cmpMeta() { return {
|
|
9198
9339
|
"$flags$": 0,
|
|
@@ -9200,7 +9341,8 @@ class SearchcraftSummaryBox {
|
|
|
9200
9341
|
"$members$": {
|
|
9201
9342
|
"searchcraftId": [1, "searchcraft-id"],
|
|
9202
9343
|
"summary": [32],
|
|
9203
|
-
"isLoading": [32]
|
|
9344
|
+
"isLoading": [32],
|
|
9345
|
+
"isSummaryNotEnabled": [32]
|
|
9204
9346
|
},
|
|
9205
9347
|
"$listeners$": undefined,
|
|
9206
9348
|
"$lazyBundleId$": "-",
|
|
@@ -9244,7 +9386,7 @@ class SearchcraftTheme {
|
|
|
9244
9386
|
registerInstance(this, hostRef);
|
|
9245
9387
|
}
|
|
9246
9388
|
render() {
|
|
9247
|
-
return hAsync("style", { key: '
|
|
9389
|
+
return hAsync("style", { key: 'ef26626cdfa4fa98d516802d71443c49a9c6ecf9' }, styles);
|
|
9248
9390
|
}
|
|
9249
9391
|
static get cmpMeta() { return {
|
|
9250
9392
|
"$flags$": 0,
|
|
@@ -9308,9 +9450,9 @@ class SearchcraftToggleButton {
|
|
|
9308
9450
|
this.cleanupCore?.();
|
|
9309
9451
|
}
|
|
9310
9452
|
render() {
|
|
9311
|
-
return (hAsync("div", { key: '
|
|
9453
|
+
return (hAsync("div", { key: 'ab1d5ee21c7aaa28af1c405edc986556858366e8', class: classNames('searchcraft-toggle-button', {
|
|
9312
9454
|
'searchcraft-toggle-button-active': this.isActive,
|
|
9313
|
-
}) }, hAsync("div", { key: '
|
|
9455
|
+
}) }, 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' }))));
|
|
9314
9456
|
}
|
|
9315
9457
|
static get cmpMeta() { return {
|
|
9316
9458
|
"$flags$": 0,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AdClient, MeasureClient, SearchClient } from "../clients/index";
|
|
2
|
-
import type { AdClientResponseItem, SearchcraftConfig, SearchcraftSDKInfo,
|
|
2
|
+
import type { AdClientResponseItem, SearchClientRequestProperties, SearchcraftConfig, SearchcraftSDKInfo, SubscriptionEventCallback, SubscriptionEventMap, SubscriptionEventName, UnsubscribeFunction } from "../types/index";
|
|
3
3
|
import { type SearchcraftStore } from "../store/index";
|
|
4
4
|
/**
|
|
5
5
|
* Javascript Class providing the functionality to interact with the Searchcraft BE
|