@nosto/search-js 3.7.0 → 3.8.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.
@@ -0,0 +1 @@
1
+ "use strict";const r=require("./jsxRuntime.module-B3sGoTIU.cjs"),m=require("./cl-B00bZ7jc.cjs"),C=require("preact/hooks");function k({onClick:a,as:c,children:l,componentProps:s,className:n}){const e={...s,onClick:C.useCallback(i=>{a(),s?.onClick?.(i)},[a,s])},t=m.cl("className"in e&&e.className,n),u=c??(s&&"href"in s?"a":"span");return r.u(u,{...e,className:t,children:l})}exports.BaseElement=k;
@@ -0,0 +1,24 @@
1
+ import { u as f } from "./jsxRuntime.module-Bzuv3cXw.js";
2
+ import { c as n } from "./cl-CcykAxZN.js";
3
+ import { useCallback as o } from "preact/hooks";
4
+ function k({
5
+ onClick: l,
6
+ as: c,
7
+ children: m,
8
+ componentProps: a,
9
+ className: e
10
+ }) {
11
+ const s = {
12
+ ...a,
13
+ onClick: o(
14
+ (t) => {
15
+ l(), a?.onClick?.(t);
16
+ },
17
+ [l, a]
18
+ )
19
+ }, i = n("className" in s && s.className, e), r = c ?? (a && "href" in a ? "a" : "span");
20
+ return /* @__PURE__ */ f(r, { ...s, className: i, children: m });
21
+ }
22
+ export {
23
+ k as B
24
+ };
@@ -0,0 +1 @@
1
+ "use strict";function t(...n){return n.filter(Boolean).join(" ")}exports.cl=t;
@@ -0,0 +1,6 @@
1
+ function o(...n) {
2
+ return n.filter(Boolean).join(" ");
3
+ }
4
+ export {
5
+ o as c
6
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../AutocompletePageProvider-yFydWINa.cjs"),u=require("../../jsxRuntime.module-B3sGoTIU.cjs"),i=require("../../index.es-Dp6Iaxz3.cjs"),a=require("../../BaseElement-DgwqyaY8.cjs"),m=require("preact/hooks");function p({children:t,hit:e,as:o,componentProps:n}){const r=m.useCallback(()=>{e&&"productId"in e&&i.s(c=>c.recordSearchClick("autocomplete",e))},[e]);return u.u(a.BaseElement,{onClick:r,as:o,componentProps:n,className:"ns-autocomplete-element",children:t})}function d({children:t,class:e,onSubmit:o}){return u.u("div",{className:`ns-autocomplete-element ${e||""}`,onClick:o,onKeyDown:n=>{n.key==="Enter"&&o()},children:t})}function P({as:t,componentProps:e,onSearchInput:o,children:n}){const r={...e,onInput:s=>{o(s.target)}},c=t??"input";return t||(r.type="search"),u.u(c,{...r,children:n})}exports.AutocompletePageProvider=l.AutocompletePageProvider;exports.AutocompleteElement=p;exports.HistoryElement=d;exports.SearchInput=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../AutocompletePageProvider-yFydWINa.cjs"),u=require("../../jsxRuntime.module-B3sGoTIU.cjs"),i=require("../../index.es-Dp6Iaxz3.cjs"),a=require("../../BaseElement-CIHACCWd.cjs"),m=require("preact/hooks"),p=require("../../cl-B00bZ7jc.cjs");function d({children:t,hit:e,as:o,componentProps:n}){const r=m.useCallback(()=>{e&&"productId"in e&&i.s(c=>c.recordSearchClick("autocomplete",e))},[e]);return u.u(a.BaseElement,{onClick:r,as:o,componentProps:n,className:"ns-autocomplete-element",children:t})}function P({children:t,class:e,onSubmit:o}){return u.u("div",{className:p.cl("ns-autocomplete-element",e),onClick:o,onKeyDown:n=>{n.key==="Enter"&&o()},children:t})}function f({as:t,componentProps:e,onSearchInput:o,children:n}){const r={...e,onInput:l=>{o(l.target)}},c=t??"input";return t||(r.type="search"),u.u(c,{...r,children:n})}exports.AutocompletePageProvider=s.AutocompletePageProvider;exports.AutocompleteElement=d;exports.HistoryElement=P;exports.SearchInput=f;
@@ -1,44 +1,45 @@
1
- import { A as I } from "../../AutocompletePageProvider-B5fknz_F.js";
1
+ import { A as g } from "../../AutocompletePageProvider-B5fknz_F.js";
2
2
  import { u as m } from "../../jsxRuntime.module-Bzuv3cXw.js";
3
3
  import { s } from "../../index.es-XNBESE3P.js";
4
- import { B as a } from "../../BaseElement-iXMoOyxY.js";
4
+ import { B as a } from "../../BaseElement-DD_4UwDm.js";
5
5
  import { useCallback as l } from "preact/hooks";
6
- function C({
6
+ import { c as u } from "../../cl-CcykAxZN.js";
7
+ function y({
7
8
  children: o,
8
9
  hit: e,
9
10
  as: t,
10
- componentProps: n
11
+ componentProps: r
11
12
  }) {
12
- const r = l(() => {
13
+ const n = l(() => {
13
14
  e && "productId" in e && s((c) => c.recordSearchClick("autocomplete", e));
14
15
  }, [e]);
15
- return /* @__PURE__ */ m(a, { onClick: r, as: t, componentProps: n, className: "ns-autocomplete-element", children: o });
16
+ return /* @__PURE__ */ m(a, { onClick: n, as: t, componentProps: r, className: "ns-autocomplete-element", children: o });
16
17
  }
17
- function k({ children: o, class: e, onSubmit: t }) {
18
+ function E({ children: o, class: e, onSubmit: t }) {
18
19
  return /* @__PURE__ */ m(
19
20
  "div",
20
21
  {
21
- className: `ns-autocomplete-element ${e || ""}`,
22
+ className: u("ns-autocomplete-element", e),
22
23
  onClick: t,
23
- onKeyDown: (n) => {
24
- n.key === "Enter" && t();
24
+ onKeyDown: (r) => {
25
+ r.key === "Enter" && t();
25
26
  },
26
27
  children: o
27
28
  }
28
29
  );
29
30
  }
30
- function y({ as: o, componentProps: e, onSearchInput: t, children: n }) {
31
- const r = {
31
+ function A({ as: o, componentProps: e, onSearchInput: t, children: r }) {
32
+ const n = {
32
33
  ...e,
33
34
  onInput: (p) => {
34
35
  t(p.target);
35
36
  }
36
37
  }, c = o ?? "input";
37
- return o || (r.type = "search"), /* @__PURE__ */ m(c, { ...r, children: n });
38
+ return o || (n.type = "search"), /* @__PURE__ */ m(c, { ...n, children: r });
38
39
  }
39
40
  export {
40
- C as AutocompleteElement,
41
- I as AutocompletePageProvider,
42
- k as HistoryElement,
43
- y as SearchInput
41
+ y as AutocompleteElement,
42
+ g as AutocompletePageProvider,
43
+ E as HistoryElement,
44
+ A as SearchInput
44
45
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../jsxRuntime.module-B3sGoTIU.cjs"),l=require("../../index.es-Dp6Iaxz3.cjs"),u=require("../../BaseElement-DgwqyaY8.cjs"),S=require("../../useActions-yB4RkNMW.cjs"),d=require("preact/hooks"),g=require("../../SerpPageProvider-1jG3MP2M.cjs"),P="nosto:search:scrollPos";function m(){window.sessionStorage.setItem(P,window.scrollY.toString())}function p({children:s,hit:e,componentProps:t,as:n}){const{pageType:o}=S.useConfig(),r=o==="autocomplete"?void 0:o==="search"?"serp":o,c=d.useCallback(()=>{e&&r&&l.s(i=>i.recordSearchClick(r,e)),m()},[e,r]);return a.u(u.BaseElement,{as:n,onClick:c,componentProps:t,children:s})}exports.SearchPageProvider=g.SearchPageProvider;exports.SerpElement=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../jsxRuntime.module-B3sGoTIU.cjs"),l=require("../../index.es-Dp6Iaxz3.cjs"),u=require("../../BaseElement-CIHACCWd.cjs"),S=require("../../useActions-yB4RkNMW.cjs"),d=require("preact/hooks"),g=require("../../SerpPageProvider-1jG3MP2M.cjs"),P="nosto:search:scrollPos";function m(){window.sessionStorage.setItem(P,window.scrollY.toString())}function p({children:s,hit:e,componentProps:t,as:n}){const{pageType:o}=S.useConfig(),r=o==="autocomplete"?void 0:o==="search"?"serp":o,c=d.useCallback(()=>{e&&r&&l.s(i=>i.recordSearchClick(r,e)),m()},[e,r]);return a.u(u.BaseElement,{as:n,onClick:c,componentProps:t,children:s})}exports.SearchPageProvider=g.SearchPageProvider;exports.SerpElement=p;
@@ -1,6 +1,6 @@
1
1
  import { u as i } from "../../jsxRuntime.module-Bzuv3cXw.js";
2
2
  import { s as l } from "../../index.es-XNBESE3P.js";
3
- import { B as m } from "../../BaseElement-iXMoOyxY.js";
3
+ import { B as m } from "../../BaseElement-DD_4UwDm.js";
4
4
  import { a as p } from "../../useActions-Cd7V2qfb.js";
5
5
  import { useCallback as f } from "preact/hooks";
6
6
  import { S as x } from "../../SerpPageProvider-UgSIPtNb.js";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Utility function to join class names by filtering out falsy values and joining with spaces.
3
+ *
4
+ * @param classes - Class names to join (can include strings, undefined, null, false, etc.)
5
+ * @returns Joined class names as a string
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * cl("base", "active") // "base active"
10
+ * cl("base", undefined, "active") // "base active"
11
+ * cl("base", false && "conditional") // "base"
12
+ * cl("base", condition && "active") // "base" or "base active"
13
+ * ```
14
+ */
15
+ export declare function cl(...classes: unknown[]): string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../bindInput-BnKvCky1.cjs"),e=require("../unique-BXXNictB.cjs"),u=require("../isBot-iyBlT_oq.cjs"),r=require("../logger-Boh_C6Bz.cjs"),t=require("../parseNumber-FsZ8w61u.cjs"),s=require("../pick-rYi1lc2m.cjs");exports.bindInput=i.bindInput;exports.disableNativeAutocomplete=i.disableNativeAutocomplete;exports.deepMerge=e.deepMerge;exports.measure=e.measure;exports.mergeArrays=e.mergeArrays;exports.unique=e.unique;exports.isBot=u.isBot;exports.isEqual=r.isEqual;exports.isPlainObject=r.isPlainObject;exports.logger=r.logger;exports.parseNumber=t.parseNumber;exports.pick=s.pick;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../bindInput-BnKvCky1.cjs"),u=require("../cl-B00bZ7jc.cjs"),e=require("../unique-BXXNictB.cjs"),t=require("../isBot-iyBlT_oq.cjs"),r=require("../logger-Boh_C6Bz.cjs"),s=require("../parseNumber-FsZ8w61u.cjs"),o=require("../pick-rYi1lc2m.cjs");exports.bindInput=i.bindInput;exports.disableNativeAutocomplete=i.disableNativeAutocomplete;exports.cl=u.cl;exports.deepMerge=e.deepMerge;exports.measure=e.measure;exports.mergeArrays=e.mergeArrays;exports.unique=e.unique;exports.isBot=t.isBot;exports.isEqual=r.isEqual;exports.isPlainObject=r.isPlainObject;exports.logger=r.logger;exports.parseNumber=s.parseNumber;exports.pick=o.pick;
@@ -1,5 +1,6 @@
1
1
  /** @module utils */
2
2
  export { type BindElementOptions, bindInput, disableNativeAutocomplete, type InputBindingCallbacks } from './src/bindInput';
3
+ export { cl } from './src/cl';
3
4
  export { deepMerge, type Merge, type PlainMerge } from './src/deepMerge';
4
5
  export { isBot } from './src/isBot';
5
6
  export { isEqual } from './src/isEqual';
@@ -1,20 +1,22 @@
1
1
  import { b as r, d as s } from "../bindInput-CCx0Fhsg.js";
2
- import { d as p, a as t, m as i, u as m } from "../unique-Cv2g464w.js";
3
- import { i as f } from "../isBot-Lnmft0Z0.js";
4
- import { i as x, a as b, l as d } from "../logger-_fg_Za9y.js";
5
- import { p as n } from "../parseNumber-QA48nJLp.js";
6
- import { p as q } from "../pick-DReBictn.js";
2
+ import { c as p } from "../cl-CcykAxZN.js";
3
+ import { d as m, a as i, m as u, u as f } from "../unique-Cv2g464w.js";
4
+ import { i as x } from "../isBot-Lnmft0Z0.js";
5
+ import { i as c, a as d, l as g } from "../logger-_fg_Za9y.js";
6
+ import { p as q } from "../parseNumber-QA48nJLp.js";
7
+ import { p as N } from "../pick-DReBictn.js";
7
8
  export {
8
9
  r as bindInput,
9
- p as deepMerge,
10
+ p as cl,
11
+ m as deepMerge,
10
12
  s as disableNativeAutocomplete,
11
- f as isBot,
12
- x as isEqual,
13
- b as isPlainObject,
14
- d as logger,
15
- t as measure,
16
- i as mergeArrays,
17
- n as parseNumber,
18
- q as pick,
19
- m as unique
13
+ x as isBot,
14
+ c as isEqual,
15
+ d as isPlainObject,
16
+ g as logger,
17
+ i as measure,
18
+ u as mergeArrays,
19
+ q as parseNumber,
20
+ N as pick,
21
+ f as unique
20
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosto/search-js",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "files": [
@@ -1 +0,0 @@
1
- "use strict";const r=require("./jsxRuntime.module-B3sGoTIU.cjs"),m=require("preact/hooks");function C({onClick:a,as:n,children:t,componentProps:s,className:l}){const e={...s,onClick:m.useCallback(i=>{a(),s?.onClick?.(i)},[a,s])},u="className"in e?e.className+" "+l:l,c=n??(s&&"href"in s?"a":"span");return r.u(c,{...e,className:u,children:t})}exports.BaseElement=C;
@@ -1,23 +0,0 @@
1
- import { u as r } from "./jsxRuntime.module-Bzuv3cXw.js";
2
- import { useCallback as f } from "preact/hooks";
3
- function k({
4
- onClick: l,
5
- as: i,
6
- children: t,
7
- componentProps: a,
8
- className: e
9
- }) {
10
- const s = {
11
- ...a,
12
- onClick: f(
13
- (n) => {
14
- l(), a?.onClick?.(n);
15
- },
16
- [l, a]
17
- )
18
- }, c = "className" in s ? s.className + " " + e : e, m = i ?? (a && "href" in a ? "a" : "span");
19
- return /* @__PURE__ */ r(m, { ...s, className: c, children: t });
20
- }
21
- export {
22
- k as B
23
- };