@searchcraft/javascript-sdk 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ const SearchcraftTheme$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftThe
9
9
  this.__registerHost();
10
10
  }
11
11
  render() {
12
- return h("style", { key: '7380c677cd9edda898cdfccf8cdb3d60e8602f14' }, styles);
12
+ return h("style", { key: 'ef26626cdfa4fa98d516802d71443c49a9c6ecf9' }, styles);
13
13
  }
14
14
  }, [0, "searchcraft-theme"]);
15
15
  function defineCustomElement$1() {
@@ -1,4 +1,4 @@
1
- import { S as SearchcraftToggleButton$1, d as defineCustomElement$1 } from './p-3e41546c.js';
1
+ import { S as SearchcraftToggleButton$1, d as defineCustomElement$1 } from './p-02ad136b.js';
2
2
 
3
3
  const SearchcraftToggleButton = SearchcraftToggleButton$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -5438,6 +5438,16 @@ class SearchcraftPopoverForm {
5438
5438
  * The id of the Searchcraft instance that this component should use.
5439
5439
  */
5440
5440
  searchcraftId;
5441
+ /**
5442
+ * The input element's placeholder value.
5443
+ */
5444
+ placeholderValue = 'Enter Search';
5445
+ /**
5446
+ * The placeholder's render behavior.
5447
+ * 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus.
5448
+ * 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
5449
+ */
5450
+ placeholderBehavior;
5441
5451
  isPopoverVisibleInState = false;
5442
5452
  searchClientResponseItems = [];
5443
5453
  adClientResponseItems = [];
@@ -5548,6 +5558,12 @@ class SearchcraftPopoverForm {
5548
5558
  this.modalElement.popoverResultMappings = this.popoverResultMappings;
5549
5559
  this.modalElement.setAttribute('type', 'fullscreen');
5550
5560
  this.modalElement.setAttribute('searchcraft-id', this.searchcraftId);
5561
+ if (this.placeholderValue) {
5562
+ this.modalElement.setAttribute('placeholder-value', this.placeholderValue);
5563
+ }
5564
+ if (this.placeholderBehavior) {
5565
+ this.modalElement.setAttribute('placeholder-behavior', this.placeholderBehavior);
5566
+ }
5551
5567
  document.body.appendChild(this.modalElement);
5552
5568
  }
5553
5569
  }
@@ -5615,20 +5631,20 @@ class SearchcraftPopoverForm {
5615
5631
  const isListViewVisible = this.hasResultsToShow && this.isFocused;
5616
5632
  return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-inline', {
5617
5633
  '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 })))));
5634
+ }) }, 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
5635
  }
5620
5636
  renderModalPopover() {
5621
5637
  if (this.isPopoverVisibleInState) {
5622
5638
  return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-modal', {
5623
5639
  '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 }))));
5640
+ }) }, 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
5641
  }
5626
5642
  }
5627
5643
  renderFullscreenPopover() {
5628
5644
  if (this.isPopoverVisibleInState) {
5629
5645
  return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-fullscreen', {
5630
5646
  '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 })));
5647
+ }) }, 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
5648
  }
5633
5649
  }
5634
5650
  render() {
@@ -5650,6 +5666,8 @@ class SearchcraftPopoverForm {
5650
5666
  "hotkey": [1],
5651
5667
  "hotkeyModifier": [1, "hotkey-modifier"],
5652
5668
  "searchcraftId": [1, "searchcraft-id"],
5669
+ "placeholderValue": [1, "placeholder-value"],
5670
+ "placeholderBehavior": [1, "placeholder-behavior"],
5653
5671
  "isPopoverVisibleInState": [32],
5654
5672
  "searchClientResponseItems": [32],
5655
5673
  "adClientResponseItems": [32],
@@ -9174,19 +9192,13 @@ class SearchcraftSummaryBox {
9174
9192
  searchcraftId;
9175
9193
  summary = '';
9176
9194
  isLoading = false;
9195
+ isSummaryNotEnabled = false;
9177
9196
  get hostElement() { return getElement(this); }
9178
9197
  unsubscribe;
9179
9198
  cleanupCore;
9180
9199
  onCoreAvailable(core) {
9181
9200
  core.store.setState({ hasSummaryBox: true });
9182
- this.unsubscribe = core.store.subscribe((state) => {
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
- });
9201
+ this.unsubscribe = core.store.subscribe(this.handleStateChange.bind(this));
9190
9202
  }
9191
9203
  connectedCallback() {
9192
9204
  this.cleanupCore = registry.useCoreInstance(this.searchcraftId, this.onCoreAvailable.bind(this));
@@ -9195,8 +9207,45 @@ class SearchcraftSummaryBox {
9195
9207
  this.unsubscribe?.();
9196
9208
  this.cleanupCore?.();
9197
9209
  }
9210
+ /**
9211
+ * Handles state changes from the store and updates component state.
9212
+ */
9213
+ handleStateChange(state) {
9214
+ this.isLoading = state.isSummaryLoading;
9215
+ this.isSummaryNotEnabled = state.isSummaryNotEnabled;
9216
+ this.summary = this.sanitizeMarkdown(state.summary);
9217
+ // Update DOM directly for performance (avoids re-render)
9218
+ this.updateContentElement(state.summary);
9219
+ }
9220
+ /**
9221
+ * Sanitizes and converts markdown to HTML.
9222
+ */
9223
+ sanitizeMarkdown(markdown) {
9224
+ return DOMPurify.sanitize(marked_umd.exports.marked.parse(markdown));
9225
+ }
9226
+ /**
9227
+ * Updates the content element directly without triggering a re-render.
9228
+ */
9229
+ updateContentElement(markdown) {
9230
+ const contentElement = this.hostElement?.querySelector('.searchcraft-summary-box-content');
9231
+ if (contentElement) {
9232
+ contentElement.innerHTML = this.sanitizeMarkdown(markdown);
9233
+ }
9234
+ }
9235
+ /**
9236
+ * Renders the appropriate content based on current state.
9237
+ */
9238
+ renderContent() {
9239
+ if (this.isLoading) {
9240
+ return hAsync("searchcraft-loading", { label: 'LOADING' });
9241
+ }
9242
+ if (this.isSummaryNotEnabled) {
9243
+ return (hAsync("div", { class: 'searchcraft-summary-box-content' }, "AI summaries are not enabled"));
9244
+ }
9245
+ return hAsync("div", { class: 'searchcraft-summary-box-content' }, this.summary);
9246
+ }
9198
9247
  render() {
9199
- return (hAsync("div", { key: '71173c93d5230610c52dfda79e23ae116e55331b', class: 'searchcraft-summary-box' }, this.isLoading && hAsync("searchcraft-loading", { key: 'a9a51922a4bedc975d3a76008fad5c014e8810ad', label: 'LOADING' }), !this.isLoading && (hAsync("div", { key: 'bb2440d7e36972c85b1887a609fd19c463f44bc9', class: 'searchcraft-summary-box-content' }, this.summary))));
9248
+ return hAsync("div", { key: 'c88d0bf7e12ad0fa0c019d207854a6e92babc683', class: 'searchcraft-summary-box' }, this.renderContent());
9200
9249
  }
9201
9250
  static get cmpMeta() { return {
9202
9251
  "$flags$": 0,
@@ -9204,7 +9253,8 @@ class SearchcraftSummaryBox {
9204
9253
  "$members$": {
9205
9254
  "searchcraftId": [1, "searchcraft-id"],
9206
9255
  "summary": [32],
9207
- "isLoading": [32]
9256
+ "isLoading": [32],
9257
+ "isSummaryNotEnabled": [32]
9208
9258
  },
9209
9259
  "$listeners$": undefined,
9210
9260
  "$lazyBundleId$": "-",
@@ -9248,7 +9298,7 @@ class SearchcraftTheme {
9248
9298
  registerInstance(this, hostRef);
9249
9299
  }
9250
9300
  render() {
9251
- return hAsync("style", { key: '7380c677cd9edda898cdfccf8cdb3d60e8602f14' }, styles);
9301
+ return hAsync("style", { key: 'ef26626cdfa4fa98d516802d71443c49a9c6ecf9' }, styles);
9252
9302
  }
9253
9303
  static get cmpMeta() { return {
9254
9304
  "$flags$": 0,
@@ -9312,9 +9362,9 @@ class SearchcraftToggleButton {
9312
9362
  this.cleanupCore?.();
9313
9363
  }
9314
9364
  render() {
9315
- return (hAsync("div", { key: '22a346c471a467b0b38b4cfde59ea70e0941cc93', class: classNames('searchcraft-toggle-button', {
9365
+ return (hAsync("div", { key: 'ab1d5ee21c7aaa28af1c405edc986556858366e8', class: classNames('searchcraft-toggle-button', {
9316
9366
  'searchcraft-toggle-button-active': this.isActive,
9317
- }) }, hAsync("div", { key: '99a2ad545500218f85006a9a0f8bbf18b8f42ed7' }, hAsync("p", { key: '5e4a9e3f27af75d0d480dc6b3668963bfcb0d1a2', class: 'searchcraft-toggle-button-label' }, this.label), this.subLabel && (hAsync("p", { key: 'c9df9f08270b58a167831d59ae3f9178eb3f6175', class: 'searchcraft-toggle-button-sub-label' }, this.subLabel))), hAsync("button", { key: '6eebeb90660122d2c12ec91091ed5987478bbec4', class: 'searchcraft-toggle-button-background', onClick: this.handleToggle, type: 'button' }, hAsync("div", { key: '62f9b1397354322986a24e8fe9e8cee62bc96600', class: 'searchcraft-toggle-button-handle' }))));
9367
+ }) }, 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
9368
  }
9319
9369
  static get cmpMeta() { return {
9320
9370
  "$flags$": 0,
@@ -5434,6 +5434,16 @@ class SearchcraftPopoverForm {
5434
5434
  * The id of the Searchcraft instance that this component should use.
5435
5435
  */
5436
5436
  searchcraftId;
5437
+ /**
5438
+ * The input element's placeholder value.
5439
+ */
5440
+ placeholderValue = 'Enter Search';
5441
+ /**
5442
+ * The placeholder's render behavior.
5443
+ * 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus.
5444
+ * 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
5445
+ */
5446
+ placeholderBehavior;
5437
5447
  isPopoverVisibleInState = false;
5438
5448
  searchClientResponseItems = [];
5439
5449
  adClientResponseItems = [];
@@ -5544,6 +5554,12 @@ class SearchcraftPopoverForm {
5544
5554
  this.modalElement.popoverResultMappings = this.popoverResultMappings;
5545
5555
  this.modalElement.setAttribute('type', 'fullscreen');
5546
5556
  this.modalElement.setAttribute('searchcraft-id', this.searchcraftId);
5557
+ if (this.placeholderValue) {
5558
+ this.modalElement.setAttribute('placeholder-value', this.placeholderValue);
5559
+ }
5560
+ if (this.placeholderBehavior) {
5561
+ this.modalElement.setAttribute('placeholder-behavior', this.placeholderBehavior);
5562
+ }
5547
5563
  document.body.appendChild(this.modalElement);
5548
5564
  }
5549
5565
  }
@@ -5611,20 +5627,20 @@ class SearchcraftPopoverForm {
5611
5627
  const isListViewVisible = this.hasResultsToShow && this.isFocused;
5612
5628
  return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-inline', {
5613
5629
  '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 })))));
5630
+ }) }, 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
5631
  }
5616
5632
  renderModalPopover() {
5617
5633
  if (this.isPopoverVisibleInState) {
5618
5634
  return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-modal', {
5619
5635
  '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 }))));
5636
+ }) }, 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
5637
  }
5622
5638
  }
5623
5639
  renderFullscreenPopover() {
5624
5640
  if (this.isPopoverVisibleInState) {
5625
5641
  return (hAsync("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-fullscreen', {
5626
5642
  '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 })));
5643
+ }) }, 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
5644
  }
5629
5645
  }
5630
5646
  render() {
@@ -5646,6 +5662,8 @@ class SearchcraftPopoverForm {
5646
5662
  "hotkey": [1],
5647
5663
  "hotkeyModifier": [1, "hotkey-modifier"],
5648
5664
  "searchcraftId": [1, "searchcraft-id"],
5665
+ "placeholderValue": [1, "placeholder-value"],
5666
+ "placeholderBehavior": [1, "placeholder-behavior"],
5649
5667
  "isPopoverVisibleInState": [32],
5650
5668
  "searchClientResponseItems": [32],
5651
5669
  "adClientResponseItems": [32],
@@ -9170,19 +9188,13 @@ class SearchcraftSummaryBox {
9170
9188
  searchcraftId;
9171
9189
  summary = '';
9172
9190
  isLoading = false;
9191
+ isSummaryNotEnabled = false;
9173
9192
  get hostElement() { return getElement(this); }
9174
9193
  unsubscribe;
9175
9194
  cleanupCore;
9176
9195
  onCoreAvailable(core) {
9177
9196
  core.store.setState({ hasSummaryBox: true });
9178
- this.unsubscribe = core.store.subscribe((state) => {
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
- });
9197
+ this.unsubscribe = core.store.subscribe(this.handleStateChange.bind(this));
9186
9198
  }
9187
9199
  connectedCallback() {
9188
9200
  this.cleanupCore = registry.useCoreInstance(this.searchcraftId, this.onCoreAvailable.bind(this));
@@ -9191,8 +9203,45 @@ class SearchcraftSummaryBox {
9191
9203
  this.unsubscribe?.();
9192
9204
  this.cleanupCore?.();
9193
9205
  }
9206
+ /**
9207
+ * Handles state changes from the store and updates component state.
9208
+ */
9209
+ handleStateChange(state) {
9210
+ this.isLoading = state.isSummaryLoading;
9211
+ this.isSummaryNotEnabled = state.isSummaryNotEnabled;
9212
+ this.summary = this.sanitizeMarkdown(state.summary);
9213
+ // Update DOM directly for performance (avoids re-render)
9214
+ this.updateContentElement(state.summary);
9215
+ }
9216
+ /**
9217
+ * Sanitizes and converts markdown to HTML.
9218
+ */
9219
+ sanitizeMarkdown(markdown) {
9220
+ return DOMPurify.sanitize(marked_umd.exports.marked.parse(markdown));
9221
+ }
9222
+ /**
9223
+ * Updates the content element directly without triggering a re-render.
9224
+ */
9225
+ updateContentElement(markdown) {
9226
+ const contentElement = this.hostElement?.querySelector('.searchcraft-summary-box-content');
9227
+ if (contentElement) {
9228
+ contentElement.innerHTML = this.sanitizeMarkdown(markdown);
9229
+ }
9230
+ }
9231
+ /**
9232
+ * Renders the appropriate content based on current state.
9233
+ */
9234
+ renderContent() {
9235
+ if (this.isLoading) {
9236
+ return hAsync("searchcraft-loading", { label: 'LOADING' });
9237
+ }
9238
+ if (this.isSummaryNotEnabled) {
9239
+ return (hAsync("div", { class: 'searchcraft-summary-box-content' }, "AI summaries are not enabled"));
9240
+ }
9241
+ return hAsync("div", { class: 'searchcraft-summary-box-content' }, this.summary);
9242
+ }
9194
9243
  render() {
9195
- return (hAsync("div", { key: '71173c93d5230610c52dfda79e23ae116e55331b', class: 'searchcraft-summary-box' }, this.isLoading && hAsync("searchcraft-loading", { key: 'a9a51922a4bedc975d3a76008fad5c014e8810ad', label: 'LOADING' }), !this.isLoading && (hAsync("div", { key: 'bb2440d7e36972c85b1887a609fd19c463f44bc9', class: 'searchcraft-summary-box-content' }, this.summary))));
9244
+ return hAsync("div", { key: 'c88d0bf7e12ad0fa0c019d207854a6e92babc683', class: 'searchcraft-summary-box' }, this.renderContent());
9196
9245
  }
9197
9246
  static get cmpMeta() { return {
9198
9247
  "$flags$": 0,
@@ -9200,7 +9249,8 @@ class SearchcraftSummaryBox {
9200
9249
  "$members$": {
9201
9250
  "searchcraftId": [1, "searchcraft-id"],
9202
9251
  "summary": [32],
9203
- "isLoading": [32]
9252
+ "isLoading": [32],
9253
+ "isSummaryNotEnabled": [32]
9204
9254
  },
9205
9255
  "$listeners$": undefined,
9206
9256
  "$lazyBundleId$": "-",
@@ -9244,7 +9294,7 @@ class SearchcraftTheme {
9244
9294
  registerInstance(this, hostRef);
9245
9295
  }
9246
9296
  render() {
9247
- return hAsync("style", { key: '7380c677cd9edda898cdfccf8cdb3d60e8602f14' }, styles);
9297
+ return hAsync("style", { key: 'ef26626cdfa4fa98d516802d71443c49a9c6ecf9' }, styles);
9248
9298
  }
9249
9299
  static get cmpMeta() { return {
9250
9300
  "$flags$": 0,
@@ -9308,9 +9358,9 @@ class SearchcraftToggleButton {
9308
9358
  this.cleanupCore?.();
9309
9359
  }
9310
9360
  render() {
9311
- return (hAsync("div", { key: '22a346c471a467b0b38b4cfde59ea70e0941cc93', class: classNames('searchcraft-toggle-button', {
9361
+ return (hAsync("div", { key: 'ab1d5ee21c7aaa28af1c405edc986556858366e8', class: classNames('searchcraft-toggle-button', {
9312
9362
  'searchcraft-toggle-button-active': this.isActive,
9313
- }) }, hAsync("div", { key: '99a2ad545500218f85006a9a0f8bbf18b8f42ed7' }, hAsync("p", { key: '5e4a9e3f27af75d0d480dc6b3668963bfcb0d1a2', class: 'searchcraft-toggle-button-label' }, this.label), this.subLabel && (hAsync("p", { key: 'c9df9f08270b58a167831d59ae3f9178eb3f6175', class: 'searchcraft-toggle-button-sub-label' }, this.subLabel))), hAsync("button", { key: '6eebeb90660122d2c12ec91091ed5987478bbec4', class: 'searchcraft-toggle-button-background', onClick: this.handleToggle, type: 'button' }, hAsync("div", { key: '62f9b1397354322986a24e8fe9e8cee62bc96600', class: 'searchcraft-toggle-button-handle' }))));
9363
+ }) }, 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
9364
  }
9315
9365
  static get cmpMeta() { return {
9316
9366
  "$flags$": 0,
@@ -10,6 +10,7 @@ export declare class SearchClient {
10
10
  constructor(parent: SearchcraftCore, config: SearchcraftConfig, userId: string);
11
11
  /**
12
12
  * Getter for the base url used by the /search endpoint.
13
+ * Supports both index and federation search endpoints.
13
14
  */
14
15
  private get baseSearchUrl();
15
16
  /**
@@ -61,6 +61,16 @@ export declare class SearchcraftPopoverForm {
61
61
  * The id of the Searchcraft instance that this component should use.
62
62
  */
63
63
  searchcraftId?: string;
64
+ /**
65
+ * The input element's placeholder value.
66
+ */
67
+ placeholderValue?: string;
68
+ /**
69
+ * The placeholder's render behavior.
70
+ * 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus.
71
+ * 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
72
+ */
73
+ placeholderBehavior?: 'hide-on-focus' | 'hide-on-text-entered';
64
74
  isPopoverVisibleInState: boolean;
65
75
  searchClientResponseItems: SearchClientResponseItem[];
66
76
  adClientResponseItems: AdClientResponseItem[];
@@ -38,12 +38,29 @@ export declare class SearchcraftSummaryBox {
38
38
  searchcraftId?: string;
39
39
  summary: string;
40
40
  isLoading: boolean;
41
+ isSummaryNotEnabled: boolean;
41
42
  hostElement?: HTMLElement;
42
43
  private unsubscribe?;
43
44
  private cleanupCore?;
44
45
  onCoreAvailable(core: SearchcraftCore): void;
45
46
  connectedCallback(): void;
46
47
  disconnectedCallback(): void;
48
+ /**
49
+ * Handles state changes from the store and updates component state.
50
+ */
51
+ private handleStateChange;
52
+ /**
53
+ * Sanitizes and converts markdown to HTML.
54
+ */
55
+ private sanitizeMarkdown;
56
+ /**
57
+ * Updates the content element directly without triggering a re-render.
58
+ */
59
+ private updateContentElement;
60
+ /**
61
+ * Renders the appropriate content based on current state.
62
+ */
63
+ private renderContent;
47
64
  render(): any;
48
65
  }
49
66
  //# sourceMappingURL=searchcraft-summary-box.d.ts.map
@@ -318,6 +318,14 @@ export namespace Components {
318
318
  * The hotkey modifier that activates the popover. Used together with the `hotkey` prop.
319
319
  */
320
320
  "hotkeyModifier"?: 'ctrl' | 'meta' | 'alt' | 'option';
321
+ /**
322
+ * The placeholder's render behavior. 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus. 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
323
+ */
324
+ "placeholderBehavior"?: 'hide-on-focus' | 'hide-on-text-entered';
325
+ /**
326
+ * The input element's placeholder value.
327
+ */
328
+ "placeholderValue"?: string;
321
329
  /**
322
330
  * Formats the content rendered for each result.
323
331
  */
@@ -1569,6 +1577,14 @@ declare namespace LocalJSX {
1569
1577
  * The hotkey modifier that activates the popover. Used together with the `hotkey` prop.
1570
1578
  */
1571
1579
  "hotkeyModifier"?: 'ctrl' | 'meta' | 'alt' | 'option';
1580
+ /**
1581
+ * The placeholder's render behavior. 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus. 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.
1582
+ */
1583
+ "placeholderBehavior"?: 'hide-on-focus' | 'hide-on-text-entered';
1584
+ /**
1585
+ * The input element's placeholder value.
1586
+ */
1587
+ "placeholderValue"?: string;
1572
1588
  /**
1573
1589
  * Formats the content rendered for each result.
1574
1590
  */
@@ -11,7 +11,9 @@ export interface SearchcraftStateFunctions {
11
11
  removeFacetPathsForIndexField: (fieldName: string) => void;
12
12
  removeRangeValueForIndexField: (fieldName: string) => void;
13
13
  resetSearchValues: () => void;
14
- search: () => Promise<void>;
14
+ search: (options?: {
15
+ skipSummary?: boolean;
16
+ }) => Promise<void>;
15
17
  setPopoverVisibility: (isVisible: boolean) => void;
16
18
  setSearchResultsCount: (count: number) => void;
17
19
  setSearchResultsPage: (page: number) => void;
@@ -55,6 +57,7 @@ export interface SearchcraftStateValues {
55
57
  hasSummaryBox: boolean;
56
58
  isSummaryLoading: boolean;
57
59
  summaryClient?: SummaryClient;
60
+ isSummaryNotEnabled: boolean;
58
61
  }
59
62
  export interface SearchcraftState extends SearchcraftStateFunctions, SearchcraftStateValues {
60
63
  }
@@ -24,6 +24,7 @@ export interface MeasureRequestProperties {
24
24
  searchcraft_organization_id?: string;
25
25
  searchcraft_application_id?: string;
26
26
  searchcraft_index_names: string[];
27
+ searchcraft_federation_name?: string;
27
28
  search_term?: string;
28
29
  number_of_documents?: number;
29
30
  external_document_id?: string;
@@ -13,8 +13,16 @@ export interface SearchcraftConfig {
13
13
  endpointURL: string;
14
14
  /**
15
15
  * Name of the Searchcraft search index to search for results within. If you are using Searchcraft Cloud, this value can be found within the Vektron dashboard in the Code Snippets section when configuring a search index.
16
+ *
17
+ * Note: Either `indexName` or `federationName` must be provided, but not both.
18
+ */
19
+ indexName?: string;
20
+ /**
21
+ * Name of the Searchcraft federation to search across multiple indices. Federation search allows you to search across all indices defined in a federation with a single query.
22
+ *
23
+ * Note: Either `indexName` or `federationName` must be provided, but not both.
16
24
  */
17
- indexName: string;
25
+ federationName?: string;
18
26
  /**
19
27
  * The initial search query to call when Searchcraft is first initialized in your front-end application. This parameter can be used when you want to populate a page with an initial set of search results based on a query.
20
28
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@searchcraft/javascript-sdk",
3
3
  "private": false,
4
- "version": "0.11.0",
4
+ "version": "0.12.0",
5
5
  "description": "Searchcraft Javascript SDK",
6
6
  "author": "Searchcraft Inc.",
7
7
  "license": "Apache-2.0",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@stencil/core": "^4.7.0",
49
- "@stencil/react-output-target": "^0.8.2",
49
+ "@stencil/react-output-target": "^1.2.0",
50
50
  "@stencil/sass": "^3.0.12",
51
51
  "@stencil/vue-output-target": "^0.9.2",
52
52
  "@thumbmarkjs/thumbmarkjs": "^0.16.1",
@@ -54,5 +54,5 @@
54
54
  "nanoid": "^5.0.9",
55
55
  "zustand": "^5.0.1"
56
56
  },
57
- "gitHead": "74aa902098d26aa12b7c02cf319ed10fea5a25e3"
57
+ "gitHead": "e494e3507629138e5f5ed3d03b8630be53dffaee"
58
58
  }