@searchcraft/react-sdk 0.10.3 → 0.10.4

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.
@@ -642,7 +642,7 @@ export interface SearchcraftStateValues {
642
642
  searchMode: "fuzzy" | "exact";
643
643
  searchClientResponseItems: SearchClientResponseItem[];
644
644
  searchResponseTimeTaken: number | undefined;
645
- searchResponseFacetPrime: FacetPrime | undefined;
645
+ searchResponseFacetPrime: FacetPrime | undefined | null;
646
646
  searchResultsCount: number;
647
647
  searchResultsPage: number;
648
648
  searchResultsPerPage: number;
@@ -1478,34 +1478,35 @@ class po {
1478
1478
  */
1479
1479
  formatParamsForRequest(t) {
1480
1480
  const r = [];
1481
- t.facetPathsForIndexFields && Object.keys(t.facetPathsForIndexFields).forEach((o) => {
1482
- var n;
1483
- const c = (n = t.facetPathsForIndexFields) == null ? void 0 : n[o];
1484
- c && r.push({
1481
+ let s = "should";
1482
+ t.facetPathsForIndexFields && Object.keys(t.facetPathsForIndexFields).forEach((n) => {
1483
+ var c;
1484
+ const u = (c = t.facetPathsForIndexFields) == null ? void 0 : c[n];
1485
+ u && (s = "must", r.push({
1485
1486
  occur: "must",
1486
1487
  exact: {
1487
- ctx: Wt(c.value)
1488
+ ctx: Wt(u.value)
1488
1489
  }
1489
- });
1490
- }), t.rangeValueForIndexFields && Object.keys(t.rangeValueForIndexFields).forEach((o) => {
1491
- var n;
1492
- const c = (n = t.rangeValueForIndexFields) == null ? void 0 : n[o];
1493
- c && r.push({
1490
+ }));
1491
+ }), t.rangeValueForIndexFields && Object.keys(t.rangeValueForIndexFields).forEach((n) => {
1492
+ var c;
1493
+ const u = (c = t.rangeValueForIndexFields) == null ? void 0 : c[n];
1494
+ u && (s = "must", r.push({
1494
1495
  occur: "must",
1495
1496
  exact: {
1496
- ctx: Wt(c.value)
1497
+ ctx: Wt(u.value)
1497
1498
  }
1498
- });
1499
+ }));
1499
1500
  });
1500
- const s = Wt(t.searchTerm), a = t.mode === "fuzzy" ? { fuzzy: { ctx: s } } : {
1501
+ const a = Wt(t.searchTerm), o = t.mode === "fuzzy" ? { fuzzy: { ctx: a } } : {
1501
1502
  exact: {
1502
- ctx: `${s.startsWith('"') ? s : `"${s}"`}`
1503
+ ctx: `${a.startsWith('"') ? a : `"${a}"`}`
1503
1504
  }
1504
1505
  };
1505
1506
  return r.push({
1506
- occur: t.mode === "exact" ? "must" : "should",
1507
+ occur: t.mode === "exact" ? "must" : s,
1507
1508
  // Valid, as 'occur' is a required property in SearchClientQuery
1508
- ...a
1509
+ ...o
1509
1510
  }), r;
1510
1511
  }
1511
1512
  }
@@ -2205,7 +2206,7 @@ const ms = {
2205
2206
  c === g.searchResultsCount ? g.searchResultsPage : 1
2206
2207
  ),
2207
2208
  searchResultsCount: c,
2208
- ...n && { searchResponseFacetPrime: n }
2209
+ searchResponseFacetPrime: n
2209
2210
  }));
2210
2211
  (i = h.logger) == null || i.log(he.DEBUG, `Search results: ${JSON.stringify(o)}`), (p = h.logger) == null || p.log(he.DEBUG, `Facets from response: ${JSON.stringify(n)}`);
2211
2212
  },
@@ -3129,11 +3130,11 @@ const Yo = /* @__PURE__ */ D(class extends F {
3129
3130
  handleStateUpdate(r) {
3130
3131
  const s = r.searchResponseFacetPrime, a = r.searchResponseTimeTaken;
3131
3132
  if (this.fieldName) {
3132
- if ((r.searchTerm !== this.lastSearchTerm || r.searchMode !== this.lastSearchMode) && (this.selectedPaths = {}, this.hasNewSearchTerm = !0), a !== this.lastTimeTaken && s) {
3133
+ if (r.searchTerm || (this.facetRoot = void 0), (r.searchTerm !== this.lastSearchTerm || r.searchMode !== this.lastSearchMode) && (this.selectedPaths = {}, this.hasNewSearchTerm = !0), a !== this.lastTimeTaken && s) {
3133
3134
  this.facetRoot = void 0;
3134
3135
  const o = s.find((n) => this.fieldName === Object.keys(n)[0]);
3135
3136
  this.hasNewSearchTerm ? (this.baseFacetRoot = o, this.facetRoot = o, this.hasNewSearchTerm = !1) : this.baseFacetRoot && o && (this.facetRoot = qo(this.fieldName, this.baseFacetRoot, o));
3136
- }
3137
+ } else !s && Object.keys(this.selectedPaths).length === 0 && (this.facetRoot = void 0);
3137
3138
  this.lastSearchTerm = r.searchTerm, this.lastSearchMode = r.searchMode, this.lastSortType = r.sortType, this.lastTimeTaken = a;
3138
3139
  }
3139
3140
  }
@@ -4659,7 +4660,7 @@ const Dc = Fc, Hc = Xs, na = () => {
4659
4660
  No(), zo(), Vo(), Zo(), tc(), ac(), nc(), ic(), hc(), fc(), vc(), bc(), yc(), kc(), xc(), Ic(), Tc(), Ac(), Mc(), Dc(), Hc();
4660
4661
  };
4661
4662
  globalThis.__scDefineCustomElements__ = na;
4662
- const Nc = "@searchcraft/react-sdk", Uc = "0.10.3", vs = {
4663
+ const Nc = "@searchcraft/react-sdk", Uc = "0.10.4", vs = {
4663
4664
  name: Nc,
4664
4665
  version: Uc
4665
4666
  };