@nosto/search-js 2.0.0 → 2.1.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 +50 -8
- package/dist/InfiniteScrollWithObserver-BC15p357.cjs +1 -0
- package/dist/InfiniteScrollWithObserver-_SDx8g70.js +33 -0
- package/dist/core/core.d.ts +1 -1
- package/dist/core/src/search.d.ts +2 -2
- package/dist/core/src/searchWithRetries.d.ts +2 -2
- package/dist/core/src/types.d.ts +2 -2
- package/dist/isEqual-DQXR__da.cjs +1 -0
- package/dist/isEqual-DvCrFxWE.js +41 -0
- package/dist/parseNumber-FsZ8w61u.cjs +1 -0
- package/dist/parseNumber-QA48nJLp.js +11 -0
- package/dist/pick-DReBictn.js +9 -0
- package/dist/pick-rYi1lc2m.cjs +1 -0
- package/dist/preact/autocomplete.cjs.js +1 -1
- package/dist/preact/autocomplete.es.js +1 -1
- package/dist/preact/category.cjs.js +1 -1
- package/dist/preact/category.es.js +1 -1
- package/dist/preact/common.cjs.js +1 -1
- package/dist/preact/common.es.js +20 -19
- package/dist/preact/hooks.cjs.js +1 -1
- package/dist/preact/hooks.es.js +45 -52
- package/dist/preact/legacy.cjs.js +1 -1
- package/dist/preact/legacy.es.js +2 -2
- package/dist/preact/serp.cjs.js +1 -1
- package/dist/preact/serp.es.js +1 -1
- package/dist/preact/src/actions/newSearch.d.ts +2 -2
- package/dist/preact/src/actions/updateSearch.d.ts +2 -2
- package/dist/preact/src/config/base/baseConfig.d.ts +2 -2
- package/dist/preact/src/config/pages/autocomplete/config.d.ts +1 -1
- package/dist/preact/src/config/pages/category/config.d.ts +1 -1
- package/dist/preact/src/config/pages/serp/config.d.ts +1 -1
- package/dist/storeContext-DVs7r6Qm.cjs +1 -0
- package/dist/storeContext-hvRuqxMT.js +63 -0
- package/dist/unique-CGVAnKZy.cjs +1 -0
- package/dist/unique-Dwtu7vXB.js +44 -0
- package/dist/useLoadMore-SWC243j-.js +261 -0
- package/dist/useLoadMore-wwYzUkxk.cjs +1 -0
- package/dist/utils/src/deepMerge.d.ts +1 -1
- package/dist/utils/utils.cjs.js +1 -1
- package/dist/utils/utils.d.ts +9 -0
- package/dist/utils/utils.es.js +14 -18
- package/package.json +7 -7
- package/dist/InfiniteScrollWithObserver-BoKdnFuB.cjs +0 -1
- package/dist/InfiniteScrollWithObserver-CkdVKocm.js +0 -39
- package/dist/storeContext-12dN1l9r.cjs +0 -1
- package/dist/storeContext-CBqmmTUC.js +0 -99
- package/dist/useLoadMore-BBrbOkyq.cjs +0 -1
- package/dist/useLoadMore-DnvHCsYl.js +0 -281
package/README.md
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# Search JS
|
|
2
2
|
|
|
3
|
-
Search JS is
|
|
4
|
-
* Nosto currency formatting
|
|
5
|
-
* Nosto product thumbnails
|
|
6
|
-
* Retry logic
|
|
3
|
+
Nosto Search JS is an implementation of Nosto Search. In addition to the base search functionality, it also provides the following features:
|
|
7
4
|
|
|
5
|
+
* **Currency formatting**: Format prices based on Nosto settings.
|
|
6
|
+
* **Product thumbnails**: Thumbnail resizing.
|
|
7
|
+
* **Retry logic**: Retry failed search queries automatically.
|
|
8
|
+
* **Preact components**: Build modern search interfaces.
|
|
9
|
+
* **Autocomplete**: Fast and responsive autocomplete tools.
|
|
10
|
+
* **Category search**: Display and filter by categories.
|
|
11
|
+
* **SERPs**: Build search result pages with sorting and pagination.
|
|
12
|
+
* **Utilities**: Helpers for common tasks like array or object merging and equality checks.
|
|
13
|
+
* **Infinite scroll**: Loads more components upon scrolling to the end of results.
|
|
14
|
+
|
|
8
15
|
## Installation
|
|
9
|
-
|
|
10
16
|
To install the package, use your preferred package manager:
|
|
11
17
|
|
|
12
18
|
```bash
|
|
@@ -22,7 +28,43 @@ Read [Nosto Techdocs](https://docs.nosto.com/techdocs/apis/frontend/oss/search-j
|
|
|
22
28
|
[Library TypeDoc page](https://nosto.github.io/search-js/) includes detailed library helpers documentation and examples.
|
|
23
29
|
|
|
24
30
|
## Packages
|
|
25
|
-
### `preact/legacy`
|
|
26
|
-
The `preact/legacy` package is designed to provide backward compatibility for existing Search Template implementations. It serves as a bridge to support legacy functionality.
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
### `core`
|
|
33
|
+
The `core` package provides the foundational functionality for interacting with Nosto Search. It includes utilities for managing search queries, applying decorators, and handling search results.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### `currencies`
|
|
38
|
+
The `currencies` package provides utilities for formatting monetary values and decorating search results with price information.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### `preact` packages
|
|
43
|
+
|
|
44
|
+
#### `preact/autocomplete`
|
|
45
|
+
The `preact/autocomplete` package helps you add autocomplete functionality to your search interface.
|
|
46
|
+
|
|
47
|
+
#### `preact/category`
|
|
48
|
+
The `preact/category` package provides tools to show and interact with category-based search results.
|
|
49
|
+
|
|
50
|
+
#### `preact/common`
|
|
51
|
+
The `preact/common` package includes shared components that are used across other `preact` packages.
|
|
52
|
+
|
|
53
|
+
#### `preact/hooks`
|
|
54
|
+
The `preact/hooks` package offers hooks to manage state and actions in your search app.
|
|
55
|
+
|
|
56
|
+
#### `preact/serp`
|
|
57
|
+
The `preact/serp` package provides tools to create Search Engine Results Pages (SERPs) with features like pagination, sorting, and displaying results.
|
|
58
|
+
|
|
59
|
+
#### `preact/legacy`
|
|
60
|
+
The `preact/legacy` package is designed to provide backward compatibility for existing Search Template implementations.
|
|
61
|
+
|
|
62
|
+
> The components included in this package are intended solely for compatibility purposes. They are not recommended for use in new development or as active components in modern applications.
|
|
63
|
+
|
|
64
|
+
### `thumbnails`
|
|
65
|
+
The `thumbnails` package helps you resize thumbnails. It supports different formats, including Shopify and Nosto-specific ones.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
### `utils`
|
|
70
|
+
The `utils` package includes handy tools for common tasks like array or object merging, checking equality, and generating unique values.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const l=require("./jsxRuntime.module-B3sGoTIU.cjs"),p=require("./useLoadMore-wwYzUkxk.cjs"),a=require("./pick-rYi1lc2m.cjs"),d=require("preact/hooks"),b=require("preact");function f(s,i){var o,e,r;const t=((o=i.products)==null?void 0:o.total)??0,c=((e=s.products)==null?void 0:e.from)??0,n=((r=s.products)==null?void 0:r.size)??0;return t>0&&t>c+n}function h(){return!!(window.IntersectionObserver&&window.IntersectionObserverEntry&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)}function O({children:s,pageSize:i}){const t=d.useRef(null),{query:c,response:n}=p.useNostoAppState(e=>a.pick(e,"query","response")),{loadMore:o}=p.useLoadMore(i);return d.useEffect(()=>{let e,r;return f(c,n)&&(e=t.current,r=new IntersectionObserver(v=>{const u=v[0];u!=null&&u.isIntersecting&&o()}),e&&r.observe(e)),()=>{e&&r.unobserve(e)}},[n]),l.u(b.Fragment,{children:[s,l.u("div",{ref:t,style:{height:"1px"}})]})}exports.InfiniteScrollWithObserver=O;exports.hasMoreResults=f;exports.intersectionObserverSupported=h;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { u as f } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
+
import { u as a, a as l } from "./useLoadMore-SWC243j-.js";
|
|
3
|
+
import { p as d } from "./pick-DReBictn.js";
|
|
4
|
+
import { useRef as m, useEffect as v } from "preact/hooks";
|
|
5
|
+
import { Fragment as b } from "preact";
|
|
6
|
+
function w(o, i) {
|
|
7
|
+
var n, e, r;
|
|
8
|
+
const t = ((n = i.products) == null ? void 0 : n.total) ?? 0, c = ((e = o.products) == null ? void 0 : e.from) ?? 0, s = ((r = o.products) == null ? void 0 : r.size) ?? 0;
|
|
9
|
+
return t > 0 && t > c + s;
|
|
10
|
+
}
|
|
11
|
+
function E() {
|
|
12
|
+
return !!(window.IntersectionObserver && window.IntersectionObserverEntry && "intersectionRatio" in window.IntersectionObserverEntry.prototype);
|
|
13
|
+
}
|
|
14
|
+
function M({ children: o, pageSize: i }) {
|
|
15
|
+
const t = m(null), { query: c, response: s } = a((e) => d(e, "query", "response")), { loadMore: n } = l(i);
|
|
16
|
+
return v(() => {
|
|
17
|
+
let e, r;
|
|
18
|
+
return w(c, s) && (e = t.current, r = new IntersectionObserver((p) => {
|
|
19
|
+
const u = p[0];
|
|
20
|
+
u != null && u.isIntersecting && n();
|
|
21
|
+
}), e && r.observe(e)), () => {
|
|
22
|
+
e && r.unobserve(e);
|
|
23
|
+
};
|
|
24
|
+
}, [s]), /* @__PURE__ */ f(b, { children: [
|
|
25
|
+
o,
|
|
26
|
+
/* @__PURE__ */ f("div", { ref: t, style: { height: "1px" } })
|
|
27
|
+
] });
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
M as I,
|
|
31
|
+
w as h,
|
|
32
|
+
E as i
|
|
33
|
+
};
|
package/dist/core/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** @module ./ */
|
|
2
2
|
export { addToCart, type SearchHitWithSku } from './src/addToCart';
|
|
3
3
|
export { search } from './src/search';
|
|
4
|
-
export type { DecoratedProduct, DecoratedResult, HitDecorator,
|
|
4
|
+
export type { DecoratedProduct, DecoratedResult, HitDecorator, SearchOptions, ToIntersection } from './src/types';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SearchQuery } from '@nosto/nosto-js/client';
|
|
2
|
-
import { HitDecorator,
|
|
2
|
+
import { HitDecorator, SearchOptions } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Performs a search operation using the provided query and options.
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@ import { HitDecorator, Options } from './types';
|
|
|
7
7
|
* @param options - An object containing optional parameters for the search.
|
|
8
8
|
* @returns A promise that resolves to the search result.
|
|
9
9
|
*/
|
|
10
|
-
export declare function search<HD extends readonly HitDecorator[]>(query: SearchQuery, options?:
|
|
10
|
+
export declare function search<HD extends readonly HitDecorator[]>(query: SearchQuery, options?: SearchOptions<HD>): Promise<{
|
|
11
11
|
products: {
|
|
12
12
|
hits: import('./types').ToIntersection<ReturnType<HD[number]>>[];
|
|
13
13
|
categoryId?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { API, SearchQuery, SearchResult } from '@nosto/nosto-js/client';
|
|
2
|
-
import {
|
|
3
|
-
export declare function searchWithRetries(api: API, query: SearchQuery, options:
|
|
2
|
+
import { SearchOptions } from './types';
|
|
3
|
+
export declare function searchWithRetries(api: API, query: SearchQuery, options: SearchOptions<[]>): Promise<SearchResult>;
|
|
4
4
|
/**
|
|
5
5
|
* Should the error trigger a search retry
|
|
6
6
|
*/
|
package/dist/core/src/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SearchOptions, SearchProduct, SearchResult } from '@nosto/nosto-js/client';
|
|
2
|
-
export type
|
|
1
|
+
import { SearchOptions as BaseOptions, SearchProduct, SearchResult } from '@nosto/nosto-js/client';
|
|
2
|
+
export type SearchOptions<HD extends readonly HitDecorator[] = readonly HitDecorator[]> = BaseOptions & {
|
|
3
3
|
/**
|
|
4
4
|
* Hit decorators to apply to the search results.
|
|
5
5
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const c=e=>String(e)==="[object Object]";function i(e){if(!c(e))return!1;const r=e.constructor;if(r===void 0)return!0;const t=r.prototype;return!(!c(t)||!t.hasOwnProperty("isPrototypeOf"))}function l(...e){return f(...e)}function f(...e){return e.reduce((r,t)=>o(r,t))}function o(e,r){return i(e)&&i(r)?Object.entries(r).reduce((t,[n,u])=>(t[n]=o(t[n],u),t),{...e}):i(e)?e:r}function s(e,r){if(e===r)return!0;if(e instanceof Date&&r instanceof Date)return e.getTime()===r.getTime();if(Array.isArray(e)&&Array.isArray(r))return e.length!==r.length?!1:e.every((t,n)=>s(t,r[n]));if(i(e)&&i(r)){const t=Object.entries(e);return t.length!==Object.keys(r).length?!1:t.every(([n,u])=>s(u,r[n]))}return!1}exports.deepMerge=l;exports.deepMergePlain=f;exports.isEqual=s;exports.isPlainObject=i;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const s = (e) => String(e) === "[object Object]";
|
|
2
|
+
function i(e) {
|
|
3
|
+
if (!s(e))
|
|
4
|
+
return !1;
|
|
5
|
+
const r = e.constructor;
|
|
6
|
+
if (r === void 0)
|
|
7
|
+
return !0;
|
|
8
|
+
const t = r.prototype;
|
|
9
|
+
return !(!s(t) || !t.hasOwnProperty("isPrototypeOf"));
|
|
10
|
+
}
|
|
11
|
+
function a(...e) {
|
|
12
|
+
return o(...e);
|
|
13
|
+
}
|
|
14
|
+
function o(...e) {
|
|
15
|
+
return e.reduce((r, t) => c(r, t));
|
|
16
|
+
}
|
|
17
|
+
function c(e, r) {
|
|
18
|
+
return i(e) && i(r) ? Object.entries(r).reduce(
|
|
19
|
+
(t, [n, u]) => (t[n] = c(t[n], u), t),
|
|
20
|
+
{ ...e }
|
|
21
|
+
) : i(e) ? e : r;
|
|
22
|
+
}
|
|
23
|
+
function f(e, r) {
|
|
24
|
+
if (e === r)
|
|
25
|
+
return !0;
|
|
26
|
+
if (e instanceof Date && r instanceof Date)
|
|
27
|
+
return e.getTime() === r.getTime();
|
|
28
|
+
if (Array.isArray(e) && Array.isArray(r))
|
|
29
|
+
return e.length !== r.length ? !1 : e.every((t, n) => f(t, r[n]));
|
|
30
|
+
if (i(e) && i(r)) {
|
|
31
|
+
const t = Object.entries(e);
|
|
32
|
+
return t.length !== Object.keys(r).length ? !1 : t.every(([n, u]) => f(u, r[n]));
|
|
33
|
+
}
|
|
34
|
+
return !1;
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
o as a,
|
|
38
|
+
i as b,
|
|
39
|
+
a as d,
|
|
40
|
+
f as i
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function t(r){if(typeof r=="number")return r;if(typeof r!="string")return;const e=Number(r);return isNaN(e)?void 0:e}exports.parseNumber=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function r(i,...n){return n.reduce((c,e)=>(c[e]=i[e],c),{})}exports.pick=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../index.es-DlUp67LT.cjs"),a=require("preact"),u=require("../renderHeadless-xhkLegO4.cjs"),i=require("../jsxRuntime.module-B3sGoTIU.cjs"),r=require("../storeContext-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../index.es-DlUp67LT.cjs"),a=require("preact"),u=require("../renderHeadless-xhkLegO4.cjs"),i=require("../jsxRuntime.module-B3sGoTIU.cjs"),r=require("../storeContext-DVs7r6Qm.cjs"),c=require("../baseConfig-DEAGSRSp.cjs");function f(e){return e!==null&&typeof e=="object"&&"props"in e&&typeof e.type=="string"}function m({children:e,hit:n}){var o;if(!f(e))throw new Error("AutocompleteElement expects a single valid HTML element as its child (e.g., <div>, <a>). Custom components are not supported.");const t=(o=e.props)==null?void 0:o.onClick;return a.cloneElement(e,{onClick:p=>{n&&l.s(s=>s.recordSearchClick("autocomplete",n)),typeof t=="function"&&t(p)}})}function g({children:e,onSearchInput:n}){return u.renderHeadless({children:e,updateElement:t=>(!u.isHTMLInput(t)||t.props.type!=="search"||(t.props={...t.props,onInput:o=>{o.target instanceof HTMLInputElement&&n(o.target)}}),t)})}const C={...c.defaultBaseConfig};function d(e){return{pageType:"autocomplete",...C,...e}}function S({config:e,store:n,children:t}){const o=n??r.createStore();return c.useCheckClientScript(),i.u(r.ConfigContext,{value:d(e),children:i.u(r.StoreContext,{value:o,children:t})})}exports.AutocompleteElement=m;exports.AutocompletePageProvider=S;exports.SearchInput=g;
|
|
@@ -2,7 +2,7 @@ import { s as u } from "../index.es-B8mbAxS4.js";
|
|
|
2
2
|
import { cloneElement as a } from "preact";
|
|
3
3
|
import { r as s, i as c } from "../renderHeadless-BteGML1G.js";
|
|
4
4
|
import { u as n } from "../jsxRuntime.module-Bzuv3cXw.js";
|
|
5
|
-
import { c as l, S as m, C as f } from "../storeContext-
|
|
5
|
+
import { c as l, S as m, C as f } from "../storeContext-hvRuqxMT.js";
|
|
6
6
|
import { d as C, u as g } from "../baseConfig-C_tlTx1w.js";
|
|
7
7
|
function E(t) {
|
|
8
8
|
return t !== null && typeof t == "object" && "props" in t && typeof t.type == "string";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../jsxRuntime.module-B3sGoTIU.cjs"),t=require("../storeContext-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../jsxRuntime.module-B3sGoTIU.cjs"),t=require("../storeContext-DVs7r6Qm.cjs"),o=require("../baseConfig-DEAGSRSp.cjs"),u={...o.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function c(e){return{pageType:"category",...u,...e}}function s({config:e,store:a,children:n}){const i=a??t.createStore();return o.useCheckClientScript(),r.u(t.ConfigContext,{value:c(e),children:r.u(t.StoreContext,{value:i,children:n})})}exports.CategoryPageProvider=s;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as t } from "../jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { c as n, S as c, C as i } from "../storeContext-
|
|
2
|
+
import { c as n, S as c, C as i } from "../storeContext-hvRuqxMT.js";
|
|
3
3
|
import { d as s, u as f } from "../baseConfig-C_tlTx1w.js";
|
|
4
4
|
const C = {
|
|
5
5
|
...s,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../unique-CGVAnKZy.cjs"),t=require("../jsxRuntime.module-B3sGoTIU.cjs"),s=require("../useLoadMore-wwYzUkxk.cjs"),p=require("../pick-rYi1lc2m.cjs"),n=require("../InfiniteScrollWithObserver-BC15p357.cjs"),q=require("preact"),r=require("../storeContext-DVs7r6Qm.cjs");function b({pageSize:o}){const{loadMore:e}=s.useLoadMore(o);return t.u("button",{onClick:e,children:"More results"})}function u({children:o,loadMoreComponent:e,pageSize:i}){const{loading:c,query:l,response:a}=s.useNostoAppState(S=>p.pick(S,"loading","query","response")),d=!c&&n.hasMoreResults(l,a);return t.u(q.Fragment,{children:[o,d&&(e?t.u(e,{pageSize:i}):t.u(b,{pageSize:i}))]})}const M=!f.isBot()&&n.intersectionObserverSupported()?n.InfiniteScrollWithObserver:u;exports.StoreContext=r.StoreContext;exports.createExtendableStore=r.createExtendableStore;exports.createStore=r.createStore;exports.defaultState=r.defaultState;exports.InfiniteScroll=M;exports.InfiniteScrollWithLink=u;
|
package/dist/preact/common.es.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { u as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { i as l } from "../unique-Dwtu7vXB.js";
|
|
2
|
+
import { u as r } from "../jsxRuntime.module-Bzuv3cXw.js";
|
|
3
|
+
import { a as p, u as m } from "../useLoadMore-SWC243j-.js";
|
|
4
|
+
import { p as u } from "../pick-DReBictn.js";
|
|
5
|
+
import { h as d, i as f, I as S } from "../InfiniteScrollWithObserver-_SDx8g70.js";
|
|
5
6
|
import { Fragment as h } from "preact";
|
|
6
|
-
import { S as
|
|
7
|
-
function M({ pageSize:
|
|
8
|
-
const { loadMore: o } = p(
|
|
9
|
-
return /* @__PURE__ */
|
|
7
|
+
import { S as O, a as W, c as A, d as B } from "../storeContext-hvRuqxMT.js";
|
|
8
|
+
function M({ pageSize: e }) {
|
|
9
|
+
const { loadMore: o } = p(e);
|
|
10
|
+
return /* @__PURE__ */ r("button", { onClick: o, children: "More results" });
|
|
10
11
|
}
|
|
11
|
-
function b({ children:
|
|
12
|
-
const { loading: n, query: s, response: i } =
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
|
|
15
|
-
a && (o ? /* @__PURE__ */
|
|
12
|
+
function b({ children: e, loadMoreComponent: o, pageSize: t }) {
|
|
13
|
+
const { loading: n, query: s, response: i } = m((c) => u(c, "loading", "query", "response")), a = !n && d(s, i);
|
|
14
|
+
return /* @__PURE__ */ r(h, { children: [
|
|
15
|
+
e,
|
|
16
|
+
a && (o ? /* @__PURE__ */ r(o, { pageSize: t }) : /* @__PURE__ */ r(M, { pageSize: t }))
|
|
16
17
|
] });
|
|
17
18
|
}
|
|
18
|
-
const
|
|
19
|
+
const q = !l() && f() ? S : b;
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
+
q as InfiniteScroll,
|
|
21
22
|
b as InfiniteScrollWithLink,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
O as StoreContext,
|
|
24
|
+
W as createExtendableStore,
|
|
25
|
+
A as createStore,
|
|
26
|
+
B as defaultState
|
|
26
27
|
};
|
package/dist/preact/hooks.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../useLoadMore-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../useLoadMore-wwYzUkxk.cjs"),P=require("../isEqual-DQXR__da.cjs"),v=require("preact/hooks"),q=require("../index.es-DlUp67LT.cjs"),N=require("../parseNumber-FsZ8w61u.cjs");function C(e){const o=m.useNostoAppState(t=>t.response);return e&&Array.isArray(e)||e&&P.isPlainObject(e)?e:o}function z(e){var a;const o=((a=e.data)==null?void 0:a.filter(c=>c.selected).length)??0,[t,n]=v.useState(o>0),{toggleProductFilter:u}=m.useActions();return{active:t,selectedFiltersCount:o,toggleActive:()=>{n(!t)},toggleProductFilter:u}}function x(){const{loading:e,facets:o}=m.useNostoAppState(t=>{var n,u;return{loading:t.loading,facets:((u=(n=t.response)==null?void 0:n.products)==null?void 0:u.facets)??[]}});return{loading:e,facets:o}}function k(e,o){const t=o-e;return!isNaN(t)&&t>0?new Array(o-e).fill(void 0).map((n,u)=>u+e):[]}function w(e){const{query:o,products:t}=m.useNostoAppState(n=>({query:n.query,products:n.response.products}));return v.useMemo(()=>{var F;if(!t)return{totalPages:0,resultsFrom:0,resultsTo:0,pages:[]};const n=((F=o.products)==null?void 0:F.from)??0,u=(e==null?void 0:e.width)??1/0,i=Math.max(Math.floor(u-1)/2,1),a=t.size>0?Math.floor(n/t.size)+1:1,c=t.size>0?Math.ceil(t.total/t.size):0,g=A=>A>=a-i&&A<=a+i,s=n+1,l=Math.min(n+t.total,t.total),r={from:n,page:a,current:!0},p=A=>({from:(A-1)*t.size,page:A,current:A===a}),S=a>1?p(a-1):void 0,d=a<c?p(a+1):void 0,y=i===1/0||a-i-1>1?p(1):void 0,f=i===1/0||a+i+1<c?p(c):void 0,h=k(1,c+1).filter(g).map(p);return{totalPages:c,resultsFrom:s,resultsTo:l,current:r,prev:S,next:d,first:y,last:f,pages:h}},[o,t,e==null?void 0:e.width])}function T(){const[e,o]=v.useState([]),[t,n]=v.useState([]);return v.useEffect(()=>{q.s(async u=>{const{products:i,segments:a}=await u.getSearchSessionParams();o(a??[]),n((i==null?void 0:i.personalizationBoost)??[])})},[]),{segments:e,boost:t}}function B(){const{facets:e}=m.useNostoAppState(s=>{var l;return{facets:((l=s.response.products)==null?void 0:l.facets)??[]}}),{replaceFilter:o,toggleProductFilter:t}=m.useActions(),n=v.useCallback(s=>{const l=e==null?void 0:e.find(r=>r.type==="stats"&&r.field===s);if(l&&"min"in l&&"max"in l)return l},[e]),u=v.useCallback(s=>{var l;return((l=e==null?void 0:e.find(r=>r.field===s))==null?void 0:l.name)??s},[e]),i=v.useCallback(s=>"field"in s&&(s.value instanceof Array||s.range instanceof Array),[]),a=v.useCallback(s=>{var l;return{...s,range:(l=s.range)==null?void 0:l.map(r=>({gt:r.gt?Number(r.gt):r.gt,gte:r.gte?Number(r.gte):r.gte,lt:r.lt?Number(r.lt):r.lt,lte:r.lte?Number(r.lte):r.lte}))}},[]),c=v.useCallback(s=>(s.value??[]).map(r=>({value:r,field:s.field,name:u(s.field),filter:a(s),remove:()=>{t(s.field,r,!1)}})),[a,u,t]),g=v.useCallback(s=>(s.range??[]).map(r=>{var d,y;const p=r.gte??r.gt??((d=n(s.field))==null?void 0:d.min),S=r.lte??r.lt??((y=n(s.field))==null?void 0:y.max);if(p!==void 0&&S!==void 0)return{value:`${p} - ${S}`,field:s.field,name:u(s.field),filter:a(s),remove:()=>{o(s.field,void 0)}}}).filter(Boolean),[a,n,u,o]);return{selectFilters:i,toValueFilter:c,toRangeFilter:g}}function M(){const{filter:e}=m.useNostoAppState(c=>{var g;return{filter:((g=c.query.products)==null?void 0:g.filter)??[]}}),{updateSearch:o}=m.useActions(),{selectFilters:t,toValueFilter:n,toRangeFilter:u}=B(),i=v.useMemo(()=>e?e.filter(t).flatMap(c=>"value"in c?n(c):"range"in c?u(c):[]).filter(Boolean):[],[e,t,u,n]),a=v.useCallback(()=>{o({products:{filter:[]}})},[o]);return{filters:i,removeAll:a}}function R(e){var r,p,S;const{replaceFilter:o}=m.useActions(),{query:t,products:n}=m.useNostoAppState(d=>({query:d.query,products:d.response.products})),u=(r=n==null?void 0:n.facets)==null?void 0:r.find(d=>d.id===e);if(!u)return{min:0,max:0,range:[0,0],updateRange:()=>{}};const i=(S=(p=t.products)==null?void 0:p.filter)==null?void 0:S.find(d=>d.field===u.field),a=i!=null&&i.range?i.range[0]:void 0,c=typeof a=="object"&&("gte"in a||"lte"in a)?[N.parseNumber(a.gte),N.parseNumber(a.lte)]:[void 0,void 0],g="min"in u?Math.floor(u.min):0,s="max"in u?Math.ceil(u.max):0,l=([d,y])=>{const f=d!==void 0?Math.floor(d):void 0,h=y!==void 0?Math.ceil(y):void 0,F=f!==void 0,A=h!==void 0;(g===f||!F)&&(s===h||!A)?o(u.field,void 0):(g===f||!F)&&A?o(u.field,{lte:h.toString()}):(s===h||!A)&&F?o(u.field,{gte:f.toString()}):F&&A&&o(u.field,{gte:f.toString(),lte:h.toString()})};return{min:g,max:s,range:[c[0]??g,c[1]??s],updateRange:l}}function D(e,o){const{min:t,max:n,range:u,updateRange:i}=R(e),{filters:a}=M(),c=v.useMemo(()=>{var y;const r=a.find(f=>{var h;return(h=f==null?void 0:f.filter)==null?void 0:h.range});let p=null;if(r){const f=(y=r.filter.range)==null?void 0:y[0];p=[N.parseNumber(f==null?void 0:f.gte),N.parseNumber(f==null?void 0:f.lte)]}const S=[];let d=Math.floor(t/o)*o;for(;d<n;){const f=d+o,h=p&&p[0]===d&&p[1]===f;S.push({min:d,max:f,selected:h}),d=f}return S},[a,t,n,o]),g=r=>{i([r,u[1]])},s=r=>{i([u[0],r])},l=t!==u[0]||n!==u[1];return{min:t,max:n,range:u,updateRange:i,ranges:c,handleMinChange:g,handleMaxChange:s,isSelected:l}}function j(){const{products:e,keywords:o}=m.useNostoAppState(t=>t.response);return{products:e??{hits:[],total:0},keywords:o??{hits:[],total:0}}}function I(){const e=m.useNostoAppState(t=>{var n;return(n=t.query.products)==null?void 0:n.filter});return v.useMemo(()=>e?e.reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:1),0):0,[e])}function b(e){return e&&!Number.isNaN(e)?e:0}function L(e,o){const{from:t,size:n,total:u}=m.useNostoAppState(s=>{var l,r,p,S,d;return{from:b(((l=s.query.products)==null?void 0:l.from)??0),size:b(((p=(r=s.response)==null?void 0:r.products)==null?void 0:p.size)??0),total:b(((d=(S=s.response)==null?void 0:S.products)==null?void 0:d.total)??0)}}),{updateSearch:i}=m.useActions(),a=t+n,c=[...e].reverse().filter(s=>s+o<u);return{from:t,to:a,total:u,size:n,sizeOptions:c,handleSizeChange:s=>{i({products:{size:s}})}}}function O(e,o){return e.length!==o.length?!1:e.every(t=>o.find(n=>t.field===n.field&&t.order===n.order))}function V(e){var i,a;const o=m.useNostoAppState(c=>c.query),{updateSearch:t}=m.useActions();return{activeSort:((i=e.find(c=>{var g;return O(c.value.sort,((g=o.products)==null?void 0:g.sort)||[])}))==null?void 0:i.id)??((a=e[0])==null?void 0:a.id),setSort:c=>{const g=e.find(s=>s.id===c);g&&t({products:{sort:g.value.sort}})}}}exports.useActions=m.useActions;exports.useLoadMore=m.useLoadMore;exports.useNostoAppState=m.useNostoAppState;exports.useDecoratedSearchResults=C;exports.useFacet=z;exports.useFacets=x;exports.usePagination=w;exports.usePersonalization=T;exports.useProductFilters=M;exports.useRange=R;exports.useRangeSelector=D;exports.useResponse=j;exports.useSelectedFiltersCount=I;exports.useSizeOptions=L;exports.useSort=V;
|
package/dist/preact/hooks.es.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useState as
|
|
1
|
+
import { u as F, b as R } from "../useLoadMore-SWC243j-.js";
|
|
2
|
+
import { a as Y } from "../useLoadMore-SWC243j-.js";
|
|
3
|
+
import { b } from "../isEqual-DvCrFxWE.js";
|
|
4
|
+
import { useState as P, useMemo as z, useEffect as N, useCallback as M } from "preact/hooks";
|
|
5
5
|
import { s as q } from "../index.es-B8mbAxS4.js";
|
|
6
|
-
|
|
6
|
+
import { p as x } from "../parseNumber-QA48nJLp.js";
|
|
7
|
+
function E(e) {
|
|
7
8
|
const o = F((t) => t.response);
|
|
8
|
-
return e && Array.isArray(e) || e &&
|
|
9
|
+
return e && Array.isArray(e) || e && b(e) ? e : o;
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
+
function L(e) {
|
|
11
12
|
var c;
|
|
12
|
-
const o = ((c = e.data) == null ? void 0 : c.filter((u) => u.selected).length) ?? 0, [t, r] =
|
|
13
|
+
const o = ((c = e.data) == null ? void 0 : c.filter((u) => u.selected).length) ?? 0, [t, r] = P(o > 0), { toggleProductFilter: i } = R();
|
|
13
14
|
return {
|
|
14
15
|
/** Active value */
|
|
15
16
|
active: t,
|
|
@@ -23,7 +24,7 @@ function E(e) {
|
|
|
23
24
|
toggleProductFilter: i
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
+
function O() {
|
|
27
28
|
const { loading: e, facets: o } = F((t) => {
|
|
28
29
|
var r, i;
|
|
29
30
|
return {
|
|
@@ -42,12 +43,12 @@ function w(e, o) {
|
|
|
42
43
|
const t = o - e;
|
|
43
44
|
return !isNaN(t) && t > 0 ? new Array(o - e).fill(void 0).map((r, i) => i + e) : [];
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function U(e) {
|
|
46
47
|
const { query: o, products: t } = F((r) => ({
|
|
47
48
|
query: r.query,
|
|
48
49
|
products: r.response.products
|
|
49
50
|
}));
|
|
50
|
-
return
|
|
51
|
+
return z(() => {
|
|
51
52
|
var S;
|
|
52
53
|
if (!t)
|
|
53
54
|
return {
|
|
@@ -78,9 +79,9 @@ function O(e) {
|
|
|
78
79
|
};
|
|
79
80
|
}, [o, t, e == null ? void 0 : e.width]);
|
|
80
81
|
}
|
|
81
|
-
function
|
|
82
|
-
const [e, o] =
|
|
83
|
-
return
|
|
82
|
+
function _() {
|
|
83
|
+
const [e, o] = P([]), [t, r] = P([]);
|
|
84
|
+
return N(() => {
|
|
84
85
|
q(async (i) => {
|
|
85
86
|
const { products: a, segments: c } = await i.getSearchSessionParams();
|
|
86
87
|
o(c ?? []), r((a == null ? void 0 : a.personalizationBoost) ?? []);
|
|
@@ -96,7 +97,7 @@ function C() {
|
|
|
96
97
|
return {
|
|
97
98
|
facets: ((l = n.response.products) == null ? void 0 : l.facets) ?? []
|
|
98
99
|
};
|
|
99
|
-
}), { replaceFilter: o, toggleProductFilter: t } =
|
|
100
|
+
}), { replaceFilter: o, toggleProductFilter: t } = R(), r = M(
|
|
100
101
|
(n) => {
|
|
101
102
|
const l = e == null ? void 0 : e.find((s) => s.type === "stats" && s.field === n);
|
|
102
103
|
if (l && "min" in l && "max" in l)
|
|
@@ -160,7 +161,7 @@ function B() {
|
|
|
160
161
|
return {
|
|
161
162
|
filter: ((g = u.query.products) == null ? void 0 : g.filter) ?? []
|
|
162
163
|
};
|
|
163
|
-
}), { updateSearch: o } =
|
|
164
|
+
}), { updateSearch: o } = R(), { selectFilters: t, toValueFilter: r, toRangeFilter: i } = C(), a = z(() => e ? e.filter(t).flatMap((u) => "value" in u ? r(u) : "range" in u ? i(u) : []).filter(Boolean) : [], [e, t, i, r]), c = M(() => {
|
|
164
165
|
o({
|
|
165
166
|
products: {
|
|
166
167
|
filter: []
|
|
@@ -174,17 +175,9 @@ function B() {
|
|
|
174
175
|
removeAll: c
|
|
175
176
|
};
|
|
176
177
|
}
|
|
177
|
-
function R(e) {
|
|
178
|
-
if (typeof e == "number")
|
|
179
|
-
return e;
|
|
180
|
-
if (typeof e != "string")
|
|
181
|
-
return;
|
|
182
|
-
const o = Number(e);
|
|
183
|
-
return isNaN(o) ? void 0 : o;
|
|
184
|
-
}
|
|
185
178
|
function T(e) {
|
|
186
179
|
var s, m, p;
|
|
187
|
-
const { replaceFilter: o } =
|
|
180
|
+
const { replaceFilter: o } = R(), { query: t, products: r } = F((d) => ({
|
|
188
181
|
query: d.query,
|
|
189
182
|
products: d.response.products
|
|
190
183
|
})), i = (s = r == null ? void 0 : r.facets) == null ? void 0 : s.find((d) => d.id === e);
|
|
@@ -196,7 +189,7 @@ function T(e) {
|
|
|
196
189
|
updateRange: () => {
|
|
197
190
|
}
|
|
198
191
|
};
|
|
199
|
-
const a = (p = (m = t.products) == null ? void 0 : m.filter) == null ? void 0 : p.find((d) => d.field === i.field), c = a != null && a.range ? a.range[0] : void 0, u = typeof c == "object" && ("gte" in c || "lte" in c) ? [
|
|
192
|
+
const a = (p = (m = t.products) == null ? void 0 : m.filter) == null ? void 0 : p.find((d) => d.field === i.field), c = a != null && a.range ? a.range[0] : void 0, u = typeof c == "object" && ("gte" in c || "lte" in c) ? [x(c.gte), x(c.lte)] : [void 0, void 0], g = "min" in i ? Math.floor(i.min) : 0, n = "max" in i ? Math.ceil(i.max) : 0, l = ([d, y]) => {
|
|
200
193
|
const f = d !== void 0 ? Math.floor(d) : void 0, v = y !== void 0 ? Math.ceil(y) : void 0, S = f !== void 0, h = v !== void 0;
|
|
201
194
|
(g === f || !S) && (n === v || !h) ? o(i.field, void 0) : (g === f || !S) && h ? o(i.field, {
|
|
202
195
|
lte: v.toString()
|
|
@@ -218,8 +211,8 @@ function T(e) {
|
|
|
218
211
|
updateRange: l
|
|
219
212
|
};
|
|
220
213
|
}
|
|
221
|
-
function
|
|
222
|
-
const { min: t, max: r, range: i, updateRange: a } = T(e), { filters: c } = B(), u =
|
|
214
|
+
function G(e, o) {
|
|
215
|
+
const { min: t, max: r, range: i, updateRange: a } = T(e), { filters: c } = B(), u = z(() => {
|
|
223
216
|
var y;
|
|
224
217
|
const s = c.find((f) => {
|
|
225
218
|
var v;
|
|
@@ -228,7 +221,7 @@ function _(e, o) {
|
|
|
228
221
|
let m = null;
|
|
229
222
|
if (s) {
|
|
230
223
|
const f = (y = s.filter.range) == null ? void 0 : y[0];
|
|
231
|
-
m = [
|
|
224
|
+
m = [x(f == null ? void 0 : f.gte), x(f == null ? void 0 : f.lte)];
|
|
232
225
|
}
|
|
233
226
|
const p = [];
|
|
234
227
|
let d = Math.floor(t / o) * o;
|
|
@@ -265,7 +258,7 @@ function _(e, o) {
|
|
|
265
258
|
isSelected: l
|
|
266
259
|
};
|
|
267
260
|
}
|
|
268
|
-
function
|
|
261
|
+
function H() {
|
|
269
262
|
const { products: e, keywords: o } = F((t) => t.response);
|
|
270
263
|
return {
|
|
271
264
|
/** Array of products */
|
|
@@ -274,25 +267,25 @@ function G() {
|
|
|
274
267
|
keywords: o ?? { hits: [], total: 0 }
|
|
275
268
|
};
|
|
276
269
|
}
|
|
277
|
-
function
|
|
270
|
+
function J() {
|
|
278
271
|
const e = F((t) => {
|
|
279
272
|
var r;
|
|
280
273
|
return (r = t.query.products) == null ? void 0 : r.filter;
|
|
281
274
|
});
|
|
282
|
-
return
|
|
275
|
+
return z(() => e ? e.reduce((t, r) => t + (Array.isArray(r.value) ? r.value.length : 1), 0) : 0, [e]);
|
|
283
276
|
}
|
|
284
|
-
function
|
|
277
|
+
function A(e) {
|
|
285
278
|
return e && !Number.isNaN(e) ? e : 0;
|
|
286
279
|
}
|
|
287
|
-
function
|
|
280
|
+
function K(e, o) {
|
|
288
281
|
const { from: t, size: r, total: i } = F((n) => {
|
|
289
282
|
var l, s, m, p, d;
|
|
290
283
|
return {
|
|
291
|
-
from:
|
|
292
|
-
size:
|
|
293
|
-
total:
|
|
284
|
+
from: A(((l = n.query.products) == null ? void 0 : l.from) ?? 0),
|
|
285
|
+
size: A(((m = (s = n.response) == null ? void 0 : s.products) == null ? void 0 : m.size) ?? 0),
|
|
286
|
+
total: A(((d = (p = n.response) == null ? void 0 : p.products) == null ? void 0 : d.total) ?? 0)
|
|
294
287
|
};
|
|
295
|
-
}), { updateSearch: a } =
|
|
288
|
+
}), { updateSearch: a } = R(), c = t + r, u = [...e].reverse().filter((n) => n + o < i);
|
|
296
289
|
return {
|
|
297
290
|
/** from value */
|
|
298
291
|
from: t,
|
|
@@ -317,9 +310,9 @@ function J(e, o) {
|
|
|
317
310
|
function k(e, o) {
|
|
318
311
|
return e.length !== o.length ? !1 : e.every((t) => o.find((r) => t.field === r.field && t.order === r.order));
|
|
319
312
|
}
|
|
320
|
-
function
|
|
313
|
+
function Q(e) {
|
|
321
314
|
var a, c;
|
|
322
|
-
const o = F((u) => u.query), { updateSearch: t } =
|
|
315
|
+
const o = F((u) => u.query), { updateSearch: t } = R();
|
|
323
316
|
return {
|
|
324
317
|
/** Active sort */
|
|
325
318
|
activeSort: ((a = e.find((u) => {
|
|
@@ -338,19 +331,19 @@ function K(e) {
|
|
|
338
331
|
};
|
|
339
332
|
}
|
|
340
333
|
export {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
334
|
+
R as useActions,
|
|
335
|
+
E as useDecoratedSearchResults,
|
|
336
|
+
L as useFacet,
|
|
337
|
+
O as useFacets,
|
|
338
|
+
Y as useLoadMore,
|
|
346
339
|
F as useNostoAppState,
|
|
347
|
-
|
|
348
|
-
|
|
340
|
+
U as usePagination,
|
|
341
|
+
_ as usePersonalization,
|
|
349
342
|
B as useProductFilters,
|
|
350
343
|
T as useRange,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
344
|
+
G as useRangeSelector,
|
|
345
|
+
H as useResponse,
|
|
346
|
+
J as useSelectedFiltersCount,
|
|
347
|
+
K as useSizeOptions,
|
|
348
|
+
Q as useSort
|
|
356
349
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../InfiniteScrollWithObserver-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../InfiniteScrollWithObserver-BC15p357.cjs"),r=require("../useLoadMore-wwYzUkxk.cjs");exports.InfiniteScrollWithObserver=e.InfiniteScrollWithObserver;exports.intersectionObserverSupported=e.intersectionObserverSupported;exports.getNextPageQuery=r.getNextPageQuery;
|
package/dist/preact/legacy.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as t, i as o } from "../InfiniteScrollWithObserver-
|
|
2
|
-
import { g as s } from "../useLoadMore-
|
|
1
|
+
import { I as t, i as o } from "../InfiniteScrollWithObserver-_SDx8g70.js";
|
|
2
|
+
import { g as s } from "../useLoadMore-SWC243j-.js";
|
|
3
3
|
export {
|
|
4
4
|
t as InfiniteScrollWithObserver,
|
|
5
5
|
s as getNextPageQuery,
|
package/dist/preact/serp.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../index.es-DlUp67LT.cjs"),s=require("../storeContext-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../index.es-DlUp67LT.cjs"),s=require("../storeContext-DVs7r6Qm.cjs"),S=require("../renderHeadless-xhkLegO4.cjs"),i=require("../jsxRuntime.module-B3sGoTIU.cjs"),a=require("../baseConfig-DEAGSRSp.cjs"),g="nosto:search:scrollPos";function d(){window.sessionStorage.setItem(g,window.scrollY.toString())}function C({children:e,hit:r,onClick:t}){const{pageType:o}=s.useConfig(),c=o==="autocomplete"?void 0:o;return S.renderHeadless({children:e,updateElement:(n,u)=>(u.depth>0||(n.props={...n.props,onClick:l=>{r&&c&&f.s(p=>p.recordSearchClick(c,r)),d(),typeof t=="function"&&t(l)}}),n)})}const m={...a.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function P(e={}){return{pageType:"serp",...m,...e}}function h({config:e,store:r,children:t}){const o=r??s.createStore();return a.useCheckClientScript(),i.u(s.ConfigContext,{value:P(e),children:i.u(s.StoreContext,{value:o,children:t})})}exports.SearchPageProvider=h;exports.SerpElement=C;
|
package/dist/preact/serp.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as l } from "../index.es-B8mbAxS4.js";
|
|
2
|
-
import { u as f, c as u, S, C as m } from "../storeContext-
|
|
2
|
+
import { u as f, c as u, S, C as m } from "../storeContext-hvRuqxMT.js";
|
|
3
3
|
import { r as g } from "../renderHeadless-BteGML1G.js";
|
|
4
4
|
import { u as n } from "../jsxRuntime.module-Bzuv3cXw.js";
|
|
5
5
|
import { d as C, u as d } from "../baseConfig-C_tlTx1w.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchOptions } from '../../../core/src/types';
|
|
2
2
|
import { SearchQuery } from '@nosto/nosto-js/client';
|
|
3
3
|
import { ActionContext } from './types';
|
|
4
|
-
export declare function newSearch(context: ActionContext, query: SearchQuery, options?:
|
|
4
|
+
export declare function newSearch(context: ActionContext, query: SearchQuery, options?: SearchOptions): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchOptions } from '../../../core/src/types';
|
|
2
2
|
import { SearchQuery } from '@nosto/nosto-js/client';
|
|
3
3
|
import { ActionContext } from './types';
|
|
4
|
-
export declare function updateSearch(context: ActionContext, query: SearchQuery, options?:
|
|
4
|
+
export declare function updateSearch(context: ActionContext, query: SearchQuery, options?: SearchOptions): Promise<void>;
|