@nosto/search-js 2.12.0 → 2.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/dist/preact/autocomplete.cjs.js +1 -1
- package/dist/preact/autocomplete.es.js +29 -32
- package/dist/preact/serp.cjs.js +1 -1
- package/dist/preact/serp.es.js +25 -25
- package/dist/preact/src/components/SearchInput.d.ts +7 -4
- package/dist/preact/src/components/SerpElement.d.ts +8 -5
- package/package.json +1 -1
- package/dist/preact/src/dom/renderHeadless.d.ts +0 -18
- package/dist/preact/src/dom/utils.d.ts +0 -5
- package/dist/renderHeadless-BteGML1G.js +0 -23
- package/dist/renderHeadless-xhkLegO4.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../index.es-DlUp67LT.cjs"),a=require("preact"),i=require("../jsxRuntime.module-B3sGoTIU.cjs"),c=require("../configContext-BR7w4VlU.cjs"),p=require("../baseConfig-BFFqFSg5.cjs");function m(e){return e!==null&&typeof e=="object"&&"props"in e&&typeof e.type=="string"}function f({children:e,hit:t}){var n;if(!m(e))throw new Error("AutocompleteElement expects a single valid HTML element as its child (e.g., <div>, <a>). Custom components are not supported.");const o=(n=e.props)==null?void 0:n.onClick;return a.cloneElement(e,{onClick:r=>{t&&s.s(u=>u.recordSearchClick("autocomplete",t)),typeof o=="function"&&o(r)}})}function C({as:e,componentProps:t,onSearchInput:o,children:n}){const r={...t,onInput:l=>{o(l.target)}},u=e??"input";return e||(r.type="search"),i.u(u,{...r,children:n})}const g={...p.defaultBaseConfig};function d(e){return{pageType:"autocomplete",...g,...e}}function S({config:e,store:t,children:o}){const n=t??c.createStore();return p.useCheckClientScript(),i.u(c.ConfigContext,{value:d(e),children:i.u(c.StoreContext,{value:n,children:o})})}exports.AutocompleteElement=f;exports.AutocompletePageProvider=S;exports.SearchInput=C;
|
|
@@ -1,52 +1,49 @@
|
|
|
1
|
-
import { s as
|
|
1
|
+
import { s as c } from "../index.es-B8mbAxS4.js";
|
|
2
2
|
import { cloneElement as a } from "preact";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
function E(t) {
|
|
3
|
+
import { u as i } from "../jsxRuntime.module-Bzuv3cXw.js";
|
|
4
|
+
import { c as m, S as l, C as s } from "../configContext-GuZOIX3o.js";
|
|
5
|
+
import { d as f, u as C } from "../baseConfig-Bafl02NY.js";
|
|
6
|
+
function g(t) {
|
|
8
7
|
return t !== null && typeof t == "object" && "props" in t && typeof t.type == "string";
|
|
9
8
|
}
|
|
10
|
-
function
|
|
11
|
-
var
|
|
12
|
-
if (!
|
|
9
|
+
function x({ children: t, hit: e }) {
|
|
10
|
+
var n;
|
|
11
|
+
if (!g(t))
|
|
13
12
|
throw new Error(
|
|
14
13
|
"AutocompleteElement expects a single valid HTML element as its child (e.g., <div>, <a>). Custom components are not supported."
|
|
15
14
|
);
|
|
16
|
-
const
|
|
15
|
+
const o = (n = t.props) == null ? void 0 : n.onClick;
|
|
17
16
|
return a(t, {
|
|
18
|
-
onClick: (
|
|
19
|
-
|
|
17
|
+
onClick: (r) => {
|
|
18
|
+
e && c((p) => p.recordSearchClick("autocomplete", e)), typeof o == "function" && o(r);
|
|
20
19
|
}
|
|
21
20
|
});
|
|
22
21
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}), e)
|
|
32
|
-
});
|
|
22
|
+
function P({ as: t, componentProps: e, onSearchInput: o, children: n }) {
|
|
23
|
+
const r = {
|
|
24
|
+
...e,
|
|
25
|
+
onInput: (u) => {
|
|
26
|
+
o(u.target);
|
|
27
|
+
}
|
|
28
|
+
}, p = t ?? "input";
|
|
29
|
+
return t || (r.type = "search"), /* @__PURE__ */ i(p, { ...r, children: n });
|
|
33
30
|
}
|
|
34
|
-
const
|
|
35
|
-
...
|
|
31
|
+
const d = {
|
|
32
|
+
...f
|
|
36
33
|
};
|
|
37
|
-
function
|
|
34
|
+
function S(t) {
|
|
38
35
|
return {
|
|
39
36
|
pageType: "autocomplete",
|
|
40
|
-
...
|
|
37
|
+
...d,
|
|
41
38
|
...t
|
|
42
39
|
};
|
|
43
40
|
}
|
|
44
|
-
function
|
|
45
|
-
const
|
|
46
|
-
return
|
|
41
|
+
function T({ config: t, store: e, children: o }) {
|
|
42
|
+
const n = e ?? m();
|
|
43
|
+
return C(), /* @__PURE__ */ i(s, { value: S(t), children: /* @__PURE__ */ i(l, { value: n, children: o }) });
|
|
47
44
|
}
|
|
48
45
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
x as AutocompleteElement,
|
|
47
|
+
T as AutocompletePageProvider,
|
|
48
|
+
P as SearchInput
|
|
52
49
|
};
|
package/dist/preact/serp.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../jsxRuntime.module-B3sGoTIU.cjs"),g=require("../index.es-DlUp67LT.cjs"),t=require("../configContext-BR7w4VlU.cjs"),d=require("preact/hooks"),a=require("../baseConfig-BFFqFSg5.cjs"),k="nosto:search:scrollPos";function h(){window.sessionStorage.setItem(k,window.scrollY.toString())}function p({as:o,children:n,hit:r,componentProps:e}){const{pageType:c}=t.useConfig(),s=c==="autocomplete"?void 0:c==="search"?"serp":c,l=d.useCallback(f=>{r&&s&&g.s(S=>S.recordSearchClick(s,r)),h(),e&&"onClick"in e&&typeof e.onClick=="function"&&e.onClick(f)},[r,e,s]),u={...e,onClick:l},C=o??"a";return i.u(C,{...u,children:n})}const v={...a.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function y(o={}){return{pageType:"search",...v,...o}}function m({config:o,store:n,children:r}){const e=n??t.createStore();return a.useCheckClientScript(),i.u(t.ConfigContext,{value:y(o),children:i.u(t.StoreContext,{value:e,children:r})})}exports.SearchPageProvider=m;exports.SerpElement=p;
|
package/dist/preact/serp.es.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { s as l } from "../index.es-B8mbAxS4.js";
|
|
2
|
-
import { u as f, c as u, S, C as m } from "../configContext-GuZOIX3o.js";
|
|
3
|
-
import { r as g } from "../renderHeadless-BteGML1G.js";
|
|
4
1
|
import { u as n } from "../jsxRuntime.module-Bzuv3cXw.js";
|
|
5
|
-
import {
|
|
2
|
+
import { s as u } from "../index.es-B8mbAxS4.js";
|
|
3
|
+
import { u as C, c as S, S as g, C as p } from "../configContext-GuZOIX3o.js";
|
|
4
|
+
import { useCallback as m } from "preact/hooks";
|
|
5
|
+
import { d, u as k } from "../baseConfig-Bafl02NY.js";
|
|
6
6
|
const h = "nosto:search:scrollPos";
|
|
7
|
-
function
|
|
7
|
+
function v() {
|
|
8
8
|
window.sessionStorage.setItem(h, window.scrollY.toString());
|
|
9
9
|
}
|
|
10
|
-
function B({ children:
|
|
11
|
-
const { pageType:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
10
|
+
function B({ as: o, children: t, hit: r, componentProps: e }) {
|
|
11
|
+
const { pageType: a } = C(), c = a === "autocomplete" ? void 0 : a === "search" ? "serp" : a, s = m(
|
|
12
|
+
(l) => {
|
|
13
|
+
r && c && u((f) => f.recordSearchClick(c, r)), v(), e && "onClick" in e && typeof e.onClick == "function" && e.onClick(l);
|
|
14
|
+
},
|
|
15
|
+
[r, e, c]
|
|
16
|
+
), i = {
|
|
17
|
+
...e,
|
|
18
|
+
onClick: s
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ n(o ?? "a", { ...i, children: t });
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
...
|
|
22
|
+
const w = {
|
|
23
|
+
...d,
|
|
24
24
|
persistentSearchCache: !1,
|
|
25
25
|
preservePageScroll: !1
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function y(o = {}) {
|
|
28
28
|
return {
|
|
29
29
|
pageType: "search",
|
|
30
|
-
...
|
|
31
|
-
...
|
|
30
|
+
...w,
|
|
31
|
+
...o
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
const
|
|
36
|
-
return
|
|
34
|
+
function E({ config: o, store: t, children: r }) {
|
|
35
|
+
const e = t ?? S();
|
|
36
|
+
return k(), /* @__PURE__ */ n(p, { value: y(o), children: /* @__PURE__ */ n(g, { value: e, children: r }) });
|
|
37
37
|
}
|
|
38
38
|
export {
|
|
39
|
-
|
|
39
|
+
E as SearchPageProvider,
|
|
40
40
|
B as SerpElement
|
|
41
41
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { ComponentChildren } from 'preact';
|
|
2
|
-
type
|
|
3
|
-
|
|
1
|
+
import { ComponentChildren, ComponentProps, ComponentType, JSX } from 'preact';
|
|
2
|
+
type AsComponent = keyof JSX.IntrinsicElements | ComponentType<any>;
|
|
3
|
+
type Props<C extends AsComponent> = {
|
|
4
|
+
as?: C;
|
|
4
5
|
onSearchInput: (target: HTMLInputElement) => void;
|
|
6
|
+
children?: ComponentChildren;
|
|
7
|
+
componentProps?: JSX.LibraryManagedAttributes<C, ComponentProps<C>>;
|
|
5
8
|
};
|
|
6
|
-
export declare function SearchInput({
|
|
9
|
+
export declare function SearchInput<C extends AsComponent>({ as, componentProps, onSearchInput, children }: Props<C>): JSX.Element;
|
|
7
10
|
export {};
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { ComponentChildren } from 'preact';
|
|
1
|
+
import { ComponentChildren, ComponentProps, ComponentType, JSX } from 'preact';
|
|
2
|
+
type AsComponent = keyof JSX.IntrinsicElements | ComponentType<any>;
|
|
2
3
|
/**
|
|
3
4
|
* @group Components
|
|
4
5
|
*/
|
|
5
|
-
export type SerpElementProps = {
|
|
6
|
-
children: ComponentChildren;
|
|
6
|
+
export type SerpElementProps<C extends AsComponent> = {
|
|
7
7
|
hit: {
|
|
8
8
|
productId: string;
|
|
9
9
|
url?: string;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
as?: C;
|
|
12
|
+
componentProps?: JSX.LibraryManagedAttributes<C, ComponentProps<C>>;
|
|
13
|
+
children?: ComponentChildren;
|
|
12
14
|
};
|
|
13
15
|
/**
|
|
14
16
|
* Wrapper component that can be used to wrap any element in the search result list.
|
|
15
17
|
*
|
|
16
18
|
* @group Components
|
|
17
19
|
*/
|
|
18
|
-
export declare function SerpElement({ children, hit,
|
|
20
|
+
export declare function SerpElement<C extends AsComponent>({ as, children, hit, componentProps }: SerpElementProps<C>): JSX.Element;
|
|
21
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ComponentChildren, VNode } from 'preact';
|
|
2
|
-
type Props = {
|
|
3
|
-
children: ComponentChildren;
|
|
4
|
-
/**
|
|
5
|
-
* Update the element with custom logic. Each vnode (valid JSX element) will be passed to this function recursively.
|
|
6
|
-
* You may either mutate the existing node, or create a new one.
|
|
7
|
-
*
|
|
8
|
-
* @param vnode Current target node
|
|
9
|
-
* @returns {VNode} if the vnode should be updated
|
|
10
|
-
* @returns {null} if the vnode should be removed
|
|
11
|
-
*/
|
|
12
|
-
updateElement: <P extends object>(vnode: VNode<P>, context: Context) => VNode<P> | null;
|
|
13
|
-
};
|
|
14
|
-
type Context = {
|
|
15
|
-
depth: number;
|
|
16
|
-
};
|
|
17
|
-
export declare function renderHeadless(props: Props, ctx?: Context): ComponentChildren;
|
|
18
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { VNode } from 'preact';
|
|
2
|
-
import { JSX } from 'preact/jsx-runtime';
|
|
3
|
-
export type UnknownVnode = VNode<any>;
|
|
4
|
-
export declare function isHTMLInput(vnode: UnknownVnode): vnode is VNode<JSX.IntrinsicElements["input"]>;
|
|
5
|
-
export declare function isVNode(child: unknown): child is VNode;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { toChildArray as o } from "preact";
|
|
2
|
-
function d(e) {
|
|
3
|
-
return e.type === "input";
|
|
4
|
-
}
|
|
5
|
-
function u(e) {
|
|
6
|
-
return !!e && typeof e == "object" && "type" in e && "props" in e;
|
|
7
|
-
}
|
|
8
|
-
function i(e, t = { depth: 0 }) {
|
|
9
|
-
const { children: p } = e;
|
|
10
|
-
return o(p).map((r) => {
|
|
11
|
-
if (!u(r))
|
|
12
|
-
return r;
|
|
13
|
-
const n = e.updateElement(r, t);
|
|
14
|
-
return n === null ? null : (n.props = {
|
|
15
|
-
...n.props,
|
|
16
|
-
children: i({ ...e, children: n.props.children }, { depth: t.depth + 1 })
|
|
17
|
-
}, n);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
d as i,
|
|
22
|
-
i as r
|
|
23
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("preact");function i(e){return e.type==="input"}function o(e){return!!e&&typeof e=="object"&&"type"in e&&"props"in e}function u(e,t={depth:0}){const{children:p}=e;return s.toChildArray(p).map(r=>{if(!o(r))return r;const n=e.updateElement(r,t);return n===null?null:(n.props={...n.props,children:u({...e,children:n.props.children},{depth:t.depth+1})},n)})}exports.isHTMLInput=i;exports.renderHeadless=u;
|