@nosto/search-js 3.1.0 → 3.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.
@@ -0,0 +1,207 @@
1
+ import { u as b } from "./jsxRuntime.module-Bzuv3cXw.js";
2
+ import { b as U, a as I } from "./useLoadMore-FglaJn2W.js";
3
+ import { i as A } from "./logger-DVwg4Wor.js";
4
+ import { p as M } from "./pick-DReBictn.js";
5
+ import { Component as c, options as l, createElement as d, Fragment as h, toChildArray as m } from "preact";
6
+ import { useRef as W, useEffect as V } from "preact/hooks";
7
+ function H(e, r) {
8
+ for (var t in r) e[t] = r[t];
9
+ return e;
10
+ }
11
+ function y(e, r) {
12
+ for (var t in e) if (t !== "__source" && !(t in r)) return !0;
13
+ for (var o in r) if (o !== "__source" && e[o] !== r[o]) return !0;
14
+ return !1;
15
+ }
16
+ function g(e, r) {
17
+ this.props = e, this.context = r;
18
+ }
19
+ function j(e, r) {
20
+ function t(n) {
21
+ var i = this.props.ref, u = i == n.ref;
22
+ return !u && i && (i.call ? i(null) : i.current = null), r ? !r(this.props, n) || !u : y(this.props, n);
23
+ }
24
+ function o(n) {
25
+ return this.shouldComponentUpdate = t, d(e, n);
26
+ }
27
+ return o.displayName = "Memo(" + (e.displayName || e.name) + ")", o.prototype.isReactComponent = !0, o.__f = !0, o;
28
+ }
29
+ (g.prototype = new c()).isPureReactComponent = !0, g.prototype.shouldComponentUpdate = function(e, r) {
30
+ return y(this.props, e) || y(this.state, r);
31
+ };
32
+ var k = l.__b;
33
+ l.__b = function(e) {
34
+ e.type && e.type.__f && e.ref && (e.props.ref = e.ref, e.ref = null), k && k(e);
35
+ };
36
+ var z = l.__e;
37
+ l.__e = function(e, r, t, o) {
38
+ if (e.then) {
39
+ for (var n, i = r; i = i.__; ) if ((n = i.__c) && n.__c) return r.__e == null && (r.__e = t.__e, r.__k = t.__k), n.__c(e, r);
40
+ }
41
+ z(e, r, t, o);
42
+ };
43
+ var O = l.unmount;
44
+ function C(e, r, t) {
45
+ return e && (e.__c && e.__c.__H && (e.__c.__H.__.forEach(function(o) {
46
+ typeof o.__c == "function" && o.__c();
47
+ }), e.__c.__H = null), (e = H({}, e)).__c != null && (e.__c.__P === t && (e.__c.__P = r), e.__c = null), e.__k = e.__k && e.__k.map(function(o) {
48
+ return C(o, r, t);
49
+ })), e;
50
+ }
51
+ function N(e, r, t) {
52
+ return e && t && (e.__v = null, e.__k = e.__k && e.__k.map(function(o) {
53
+ return N(o, r, t);
54
+ }), e.__c && e.__c.__P === r && (e.__e && t.appendChild(e.__e), e.__c.__e = !0, e.__c.__P = t)), e;
55
+ }
56
+ function v() {
57
+ this.__u = 0, this.o = null, this.__b = null;
58
+ }
59
+ function x(e) {
60
+ var r = e.__.__c;
61
+ return r && r.__a && r.__a(e);
62
+ }
63
+ function f() {
64
+ this.i = null, this.l = null;
65
+ }
66
+ l.unmount = function(e) {
67
+ var r = e.__c;
68
+ r && r.__R && r.__R(), r && 32 & e.__u && (e.type = null), O && O(e);
69
+ }, (v.prototype = new c()).__c = function(e, r) {
70
+ var t = r.__c, o = this;
71
+ o.o == null && (o.o = []), o.o.push(t);
72
+ var n = x(o.__v), i = !1, u = function() {
73
+ i || (i = !0, t.__R = null, n ? n(_) : _());
74
+ };
75
+ t.__R = u;
76
+ var _ = function() {
77
+ if (!--o.__u) {
78
+ if (o.state.__a) {
79
+ var a = o.state.__a;
80
+ o.__v.__k[0] = N(a, a.__c.__P, a.__c.__O);
81
+ }
82
+ var s;
83
+ for (o.setState({ __a: o.__b = null }); s = o.o.pop(); ) s.forceUpdate();
84
+ }
85
+ };
86
+ o.__u++ || 32 & r.__u || o.setState({ __a: o.__b = o.__v.__k[0] }), e.then(u, u);
87
+ }, v.prototype.componentWillUnmount = function() {
88
+ this.o = [];
89
+ }, v.prototype.render = function(e, r) {
90
+ if (this.__b) {
91
+ if (this.__v.__k) {
92
+ var t = document.createElement("div"), o = this.__v.__k[0].__c;
93
+ this.__v.__k[0] = C(this.__b, t, o.__O = o.__P);
94
+ }
95
+ this.__b = null;
96
+ }
97
+ var n = r.__a && d(h, null, e.fallback);
98
+ return n && (n.__u &= -33), [d(h, null, r.__a ? null : e.children), n];
99
+ };
100
+ var w = function(e, r, t) {
101
+ if (++t[1] === t[0] && e.l.delete(r), e.props.revealOrder && (e.props.revealOrder[0] !== "t" || !e.l.size)) for (t = e.i; t; ) {
102
+ for (; t.length > 3; ) t.pop()();
103
+ if (t[1] < t[0]) break;
104
+ e.i = t = t[2];
105
+ }
106
+ };
107
+ (f.prototype = new c()).__a = function(e) {
108
+ var r = this, t = x(r.__v), o = r.l.get(e);
109
+ return o[0]++, function(n) {
110
+ var i = function() {
111
+ r.props.revealOrder ? (o.push(n), w(r, e, o)) : n();
112
+ };
113
+ t ? t(i) : i();
114
+ };
115
+ }, f.prototype.render = function(e) {
116
+ this.i = null, this.l = /* @__PURE__ */ new Map();
117
+ var r = m(e.children);
118
+ e.revealOrder && e.revealOrder[0] === "b" && r.reverse();
119
+ for (var t = r.length; t--; ) this.l.set(r[t], this.i = [1, 0, this.i]);
120
+ return e.children;
121
+ }, f.prototype.componentDidUpdate = f.prototype.componentDidMount = function() {
122
+ var e = this;
123
+ this.l.forEach(function(r, t) {
124
+ w(e, t, r);
125
+ });
126
+ };
127
+ var B = typeof Symbol < "u" && Symbol.for && Symbol.for("react.element") || 60103, L = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/, q = /^on(Ani|Tra|Tou|BeforeInp|Compo)/, D = /[A-Z0-9]/g, F = typeof document < "u", T = function(e) {
128
+ return (typeof Symbol < "u" && typeof Symbol() == "symbol" ? /fil|che|rad/ : /fil|che|ra/).test(e);
129
+ };
130
+ c.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(e) {
131
+ Object.defineProperty(c.prototype, e, { configurable: !0, get: function() {
132
+ return this["UNSAFE_" + e];
133
+ }, set: function(r) {
134
+ Object.defineProperty(this, e, { configurable: !0, writable: !0, value: r });
135
+ } });
136
+ });
137
+ var P = l.event;
138
+ function $() {
139
+ }
140
+ function Z() {
141
+ return this.cancelBubble;
142
+ }
143
+ function G() {
144
+ return this.defaultPrevented;
145
+ }
146
+ l.event = function(e) {
147
+ return P && (e = P(e)), e.persist = $, e.isPropagationStopped = Z, e.isDefaultPrevented = G, e.nativeEvent = e;
148
+ };
149
+ var J = { enumerable: !1, configurable: !0, get: function() {
150
+ return this.class;
151
+ } }, E = l.vnode;
152
+ l.vnode = function(e) {
153
+ typeof e.type == "string" && function(r) {
154
+ var t = r.props, o = r.type, n = {}, i = o.indexOf("-") === -1;
155
+ for (var u in t) {
156
+ var _ = t[u];
157
+ if (!(u === "value" && "defaultValue" in t && _ == null || F && u === "children" && o === "noscript" || u === "class" || u === "className")) {
158
+ var a = u.toLowerCase();
159
+ u === "defaultValue" && "value" in t && t.value == null ? u = "value" : u === "download" && _ === !0 ? _ = "" : a === "translate" && _ === "no" ? _ = !1 : a[0] === "o" && a[1] === "n" ? a === "ondoubleclick" ? u = "ondblclick" : a !== "onchange" || o !== "input" && o !== "textarea" || T(t.type) ? a === "onfocus" ? u = "onfocusin" : a === "onblur" ? u = "onfocusout" : q.test(u) && (u = a) : a = u = "oninput" : i && L.test(u) ? u = u.replace(D, "-$&").toLowerCase() : _ === null && (_ = void 0), a === "oninput" && n[u = a] && (u = "oninputCapture"), n[u] = _;
160
+ }
161
+ }
162
+ o == "select" && n.multiple && Array.isArray(n.value) && (n.value = m(t.children).forEach(function(s) {
163
+ s.props.selected = n.value.indexOf(s.props.value) != -1;
164
+ })), o == "select" && n.defaultValue != null && (n.value = m(t.children).forEach(function(s) {
165
+ s.props.selected = n.multiple ? n.defaultValue.indexOf(s.props.value) != -1 : n.defaultValue == s.props.value;
166
+ })), t.class && !t.className ? (n.class = t.class, Object.defineProperty(n, "className", J)) : (t.className && !t.class || t.class && t.className) && (n.class = n.className = t.className), r.props = n;
167
+ }(e), e.$$typeof = B, E && E(e);
168
+ };
169
+ var R = l.__r;
170
+ l.__r = function(e) {
171
+ R && R(e), e.__c;
172
+ };
173
+ var S = l.diffed;
174
+ l.diffed = function(e) {
175
+ S && S(e);
176
+ var r = e.props, t = e.__e;
177
+ t != null && e.type === "textarea" && "value" in r && r.value !== t.value && (t.value = r.value == null ? "" : r.value);
178
+ };
179
+ function K(e, r) {
180
+ var i, u, _;
181
+ const t = ((i = r.products) == null ? void 0 : i.total) ?? 0, o = ((u = e.products) == null ? void 0 : u.from) ?? 0, n = ((_ = e.products) == null ? void 0 : _.size) ?? 0;
182
+ return t > 0 && t > o + n;
183
+ }
184
+ function ne() {
185
+ return !!(window.IntersectionObserver && window.IntersectionObserverEntry && "intersectionRatio" in window.IntersectionObserverEntry.prototype);
186
+ }
187
+ function Q({ children: e, pageSize: r, observerOptions: t }) {
188
+ const o = W(null), { query: n, response: i } = U((_) => M(_, "query", "response")), { loadMore: u } = I(r);
189
+ return V(() => {
190
+ let _, a;
191
+ return K(n, i) && (_ = o.current, a = new IntersectionObserver((s) => {
192
+ const p = s[0];
193
+ p != null && p.isIntersecting && u();
194
+ }, t), _ && a.observe(_)), () => {
195
+ _ && a.unobserve(_);
196
+ };
197
+ }, [i]), /* @__PURE__ */ b(h, { children: [
198
+ e,
199
+ /* @__PURE__ */ b("div", { ref: o, style: { height: "1px" } })
200
+ ] });
201
+ }
202
+ const ue = j(Q, A);
203
+ export {
204
+ ue as I,
205
+ K as h,
206
+ ne as i
207
+ };
@@ -0,0 +1 @@
1
+ "use strict";const d=require("./jsxRuntime.module-B3sGoTIU.cjs"),h=require("./useLoadMore-CeqFdxt1.cjs"),x=require("./logger-BcHMZObS.cjs"),A=require("./pick-rYi1lc2m.cjs"),u=require("preact"),m=require("preact/hooks");function M(e,r){for(var t in r)e[t]=r[t];return e}function v(e,r){for(var t in e)if(t!=="__source"&&!(t in r))return!0;for(var o in r)if(o!=="__source"&&e[o]!==r[o])return!0;return!1}function y(e,r){this.props=e,this.context=r}function U(e,r){function t(n){var s=this.props.ref,i=s==n.ref;return!i&&s&&(s.call?s(null):s.current=null),r?!r(this.props,n)||!i:v(this.props,n)}function o(n){return this.shouldComponentUpdate=t,u.createElement(e,n)}return o.displayName="Memo("+(e.displayName||e.name)+")",o.prototype.isReactComponent=!0,o.__f=!0,o}(y.prototype=new u.Component).isPureReactComponent=!0,y.prototype.shouldComponentUpdate=function(e,r){return v(this.props,e)||v(this.state,r)};var b=u.options.__b;u.options.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),b&&b(e)};var q=u.options.__e;u.options.__e=function(e,r,t,o){if(e.then){for(var n,s=r;s=s.__;)if((n=s.__c)&&n.__c)return r.__e==null&&(r.__e=t.__e,r.__k=t.__k),n.__c(e,r)}q(e,r,t,o)};var g=u.options.unmount;function P(e,r,t){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=M({},e)).__c!=null&&(e.__c.__P===t&&(e.__c.__P=r),e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return P(o,r,t)})),e}function R(e,r,t){return e&&t&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return R(o,r,t)}),e.__c&&e.__c.__P===r&&(e.__e&&t.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=t)),e}function f(){this.__u=0,this.o=null,this.__b=null}function S(e){var r=e.__.__c;return r&&r.__a&&r.__a(e)}function c(){this.i=null,this.l=null}u.options.unmount=function(e){var r=e.__c;r&&r.__R&&r.__R(),r&&32&e.__u&&(e.type=null),g&&g(e)},(f.prototype=new u.Component).__c=function(e,r){var t=r.__c,o=this;o.o==null&&(o.o=[]),o.o.push(t);var n=S(o.__v),s=!1,i=function(){s||(s=!0,t.__R=null,n?n(_):_())};t.__R=i;var _=function(){if(!--o.__u){if(o.state.__a){var l=o.state.__a;o.__v.__k[0]=R(l,l.__c.__P,l.__c.__O)}var a;for(o.setState({__a:o.__b=null});a=o.o.pop();)a.forceUpdate()}};o.__u++||32&r.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(i,i)},f.prototype.componentWillUnmount=function(){this.o=[]},f.prototype.render=function(e,r){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=P(this.__b,t,o.__O=o.__P)}this.__b=null}var n=r.__a&&u.createElement(u.Fragment,null,e.fallback);return n&&(n.__u&=-33),[u.createElement(u.Fragment,null,r.__a?null:e.children),n]};var k=function(e,r,t){if(++t[1]===t[0]&&e.l.delete(r),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(t=e.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;e.i=t=t[2]}};(c.prototype=new u.Component).__a=function(e){var r=this,t=S(r.__v),o=r.l.get(e);return o[0]++,function(n){var s=function(){r.props.revealOrder?(o.push(n),k(r,e,o)):n()};t?t(s):s()}},c.prototype.render=function(e){this.i=null,this.l=new Map;var r=u.toChildArray(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&r.reverse();for(var t=r.length;t--;)this.l.set(r[t],this.i=[1,0,this.i]);return e.children},c.prototype.componentDidUpdate=c.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(r,t){k(e,t,r)})};var I=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,W=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,V=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,j=/[A-Z0-9]/g,F=typeof document<"u",H=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};u.Component.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(u.Component.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(r){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:r})}})});var O=u.options.event;function L(){}function z(){return this.cancelBubble}function B(){return this.defaultPrevented}u.options.event=function(e){return O&&(e=O(e)),e.persist=L,e.isPropagationStopped=z,e.isDefaultPrevented=B,e.nativeEvent=e};var D={enumerable:!1,configurable:!0,get:function(){return this.class}},C=u.options.vnode;u.options.vnode=function(e){typeof e.type=="string"&&function(r){var t=r.props,o=r.type,n={},s=o.indexOf("-")===-1;for(var i in t){var _=t[i];if(!(i==="value"&&"defaultValue"in t&&_==null||F&&i==="children"&&o==="noscript"||i==="class"||i==="className")){var l=i.toLowerCase();i==="defaultValue"&&"value"in t&&t.value==null?i="value":i==="download"&&_===!0?_="":l==="translate"&&_==="no"?_=!1:l[0]==="o"&&l[1]==="n"?l==="ondoubleclick"?i="ondblclick":l!=="onchange"||o!=="input"&&o!=="textarea"||H(t.type)?l==="onfocus"?i="onfocusin":l==="onblur"?i="onfocusout":V.test(i)&&(i=l):l=i="oninput":s&&W.test(i)?i=i.replace(j,"-$&").toLowerCase():_===null&&(_=void 0),l==="oninput"&&n[i=l]&&(i="oninputCapture"),n[i]=_}}o=="select"&&n.multiple&&Array.isArray(n.value)&&(n.value=u.toChildArray(t.children).forEach(function(a){a.props.selected=n.value.indexOf(a.props.value)!=-1})),o=="select"&&n.defaultValue!=null&&(n.value=u.toChildArray(t.children).forEach(function(a){a.props.selected=n.multiple?n.defaultValue.indexOf(a.props.value)!=-1:n.defaultValue==a.props.value})),t.class&&!t.className?(n.class=t.class,Object.defineProperty(n,"className",D)):(t.className&&!t.class||t.class&&t.className)&&(n.class=n.className=t.className),r.props=n}(e),e.$$typeof=I,C&&C(e)};var w=u.options.__r;u.options.__r=function(e){w&&w(e),e.__c};var E=u.options.diffed;u.options.diffed=function(e){E&&E(e);var r=e.props,t=e.__e;t!=null&&e.type==="textarea"&&"value"in r&&r.value!==t.value&&(t.value=r.value==null?"":r.value)};function N(e,r){var s,i,_;const t=((s=r.products)==null?void 0:s.total)??0,o=((i=e.products)==null?void 0:i.from)??0,n=((_=e.products)==null?void 0:_.size)??0;return t>0&&t>o+n}function T(){return!!(window.IntersectionObserver&&window.IntersectionObserverEntry&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)}function $({children:e,pageSize:r,observerOptions:t}){const o=m.useRef(null),{query:n,response:s}=h.useNostoAppState(_=>A.pick(_,"query","response")),{loadMore:i}=h.useLoadMore(r);return m.useEffect(()=>{let _,l;return N(n,s)&&(_=o.current,l=new IntersectionObserver(a=>{const p=a[0];p!=null&&p.isIntersecting&&i()},t),_&&l.observe(_)),()=>{_&&l.unobserve(_)}},[s]),d.u(u.Fragment,{children:[e,d.u("div",{ref:o,style:{height:"1px"}})]})}const Z=U($,x.isEqual);exports.InfiniteScrollWithObserver=Z;exports.hasMoreResults=N;exports.intersectionObserverSupported=T;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../unique-Blp-K9zG.cjs"),t=require("../jsxRuntime.module-B3sGoTIU.cjs"),c=require("../useLoadMore-CeqFdxt1.cjs"),p=require("../pick-rYi1lc2m.cjs"),n=require("../InfiniteScrollWithObserver-C1NKm8WG.cjs"),q=require("preact"),r=require("../configContext-BR7w4VlU.cjs");function b({pageSize:o}){const{loadMore:e}=c.useLoadMore(o);return t.u("button",{onClick:e,children:"More results"})}function u({children:o,loadMoreComponent:e,pageSize:i}){const{loading:s,query:l,response:a}=c.useNostoAppState(S=>p.pick(S,"loading","query","response")),d=!s&&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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../unique-Blp-K9zG.cjs"),t=require("../jsxRuntime.module-B3sGoTIU.cjs"),c=require("../useLoadMore-CeqFdxt1.cjs"),p=require("../pick-rYi1lc2m.cjs"),n=require("../InfiniteScrollWithObserver-DtlqmHSY.cjs"),q=require("preact"),r=require("../configContext-BR7w4VlU.cjs");function b({pageSize:o}){const{loadMore:e}=c.useLoadMore(o);return t.u("button",{onClick:e,children:"More results"})}function u({children:o,loadMoreComponent:e,pageSize:i}){const{loading:s,query:l,response:a}=c.useNostoAppState(S=>p.pick(S,"loading","query","response")),d=!s&&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;
@@ -1,8 +1,8 @@
1
1
  import { i as l } from "../unique-m1TIDWdl.js";
2
2
  import { u as r } from "../jsxRuntime.module-Bzuv3cXw.js";
3
- import { b as p, a as m } from "../useLoadMore-Der8Cglb.js";
3
+ import { a as p, b as m } from "../useLoadMore-FglaJn2W.js";
4
4
  import { p as u } from "../pick-DReBictn.js";
5
- import { h as d, i as f, I as S } from "../InfiniteScrollWithObserver-C4YMu07G.js";
5
+ import { h as d, i as f, I as S } from "../InfiniteScrollWithObserver-B6k7NAW1.js";
6
6
  import { Fragment as h } from "preact";
7
7
  import { S as O, a as W, c as A, d as B } from "../configContext-GuZOIX3o.js";
8
8
  function M({ pageSize: e }) {
@@ -1,5 +1,5 @@
1
- import { a as y, c as x } from "../useLoadMore-Der8Cglb.js";
2
- import { b as fe } from "../useLoadMore-Der8Cglb.js";
1
+ import { b as y, c as x } from "../useLoadMore-FglaJn2W.js";
2
+ import { a as fe } from "../useLoadMore-FglaJn2W.js";
3
3
  import { a as P } from "../logger-DVwg4Wor.js";
4
4
  import { useState as L, useCallback as S, useMemo as b, useEffect as O, useRef as T } from "preact/hooks";
5
5
  import { s as C } from "../index.es-B8mbAxS4.js";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../useLoadMore-CeqFdxt1.cjs"),r=require("../InfiniteScrollWithObserver-C1NKm8WG.cjs");exports.getNextPageQuery=e.getNextPageQuery;exports.newSearch=e.newSearch;exports.updateSearch=e.updateSearch;exports.InfiniteScrollWithObserver=r.InfiniteScrollWithObserver;exports.intersectionObserverSupported=r.intersectionObserverSupported;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../useLoadMore-CeqFdxt1.cjs"),r=require("../InfiniteScrollWithObserver-DtlqmHSY.cjs");exports.getNextPageQuery=e.getNextPageQuery;exports.newSearch=e.newSearch;exports.updateSearch=e.updateSearch;exports.InfiniteScrollWithObserver=r.InfiniteScrollWithObserver;exports.intersectionObserverSupported=r.intersectionObserverSupported;
@@ -1,5 +1,5 @@
1
- import { g as t, n as a, u as s } from "../useLoadMore-Der8Cglb.js";
2
- import { I as i, i as n } from "../InfiniteScrollWithObserver-C4YMu07G.js";
1
+ import { g as t, n as a, u as s } from "../useLoadMore-FglaJn2W.js";
2
+ import { I as i, i as n } from "../InfiniteScrollWithObserver-B6k7NAW1.js";
3
3
  export {
4
4
  i as InfiniteScrollWithObserver,
5
5
  t as getNextPageQuery,
@@ -1,5 +1,4 @@
1
1
  import { ComponentChildren, ComponentType } from 'preact';
2
- import { InfiniteScrollWithObserver } from './InfiniteScrollWithObserver';
3
2
  /**
4
3
  * Infinite scroll component props
5
4
  * @param children - The children to render
@@ -55,4 +54,4 @@ export interface InfiniteScrollProps {
55
54
  * ```
56
55
  * @group Components
57
56
  */
58
- export declare const InfiniteScroll: typeof InfiniteScrollWithObserver;
57
+ export declare const InfiniteScroll: ({ children, pageSize, observerOptions }: InfiniteScrollProps) => import("preact").JSX.Element;
@@ -1,7 +1,8 @@
1
- import { JSX } from 'preact';
2
1
  import { InfiniteScrollProps } from './InfiniteScroll';
2
+ declare function BaseInfiniteScrollWithObserver({ children, pageSize, observerOptions }: InfiniteScrollProps): import("preact").JSX.Element;
3
3
  /**
4
4
  * Infinite scroll component that loads more results when user scrolls to the end of the page.
5
5
  * @group Components
6
6
  */
7
- export declare function InfiniteScrollWithObserver({ children, pageSize, observerOptions }: InfiniteScrollProps): JSX.Element;
7
+ export declare const InfiniteScrollWithObserver: typeof BaseInfiniteScrollWithObserver;
8
+ export {};
@@ -195,8 +195,8 @@ function X(e = 24) {
195
195
  };
196
196
  }
197
197
  export {
198
- L as a,
199
- X as b,
198
+ X as a,
199
+ L as b,
200
200
  j as c,
201
201
  G as g,
202
202
  b as n,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosto/search-js",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "files": [
@@ -1 +0,0 @@
1
- "use strict";const d=require("./jsxRuntime.module-B3sGoTIU.cjs"),f=require("./useLoadMore-CeqFdxt1.cjs"),b=require("./pick-rYi1lc2m.cjs"),p=require("preact/hooks"),h=require("preact");function a(s,i){var t,o,e;const r=((t=i.products)==null?void 0:t.total)??0,n=((o=s.products)==null?void 0:o.from)??0,c=((e=s.products)==null?void 0:e.size)??0;return r>0&&r>n+c}function w(){return!!(window.IntersectionObserver&&window.IntersectionObserverEntry&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)}function I({children:s,pageSize:i,observerOptions:r={}}){const n=p.useRef(null),{query:c,response:t}=f.useNostoAppState(e=>b.pick(e,"query","response")),{loadMore:o}=f.useLoadMore(i);return p.useEffect(()=>{let e,u;return a(c,t)&&(e=n.current,u=new IntersectionObserver(v=>{const l=v[0];l!=null&&l.isIntersecting&&o()},r),e&&u.observe(e)),()=>{e&&u.unobserve(e)}},[t,r]),d.u(h.Fragment,{children:[s,d.u("div",{ref:n,style:{height:"1px"}})]})}exports.InfiniteScrollWithObserver=I;exports.hasMoreResults=a;exports.intersectionObserverSupported=w;
@@ -1,37 +0,0 @@
1
- import { u as p } from "./jsxRuntime.module-Bzuv3cXw.js";
2
- import { a as l, b as d } from "./useLoadMore-Der8Cglb.js";
3
- import { p as m } from "./pick-DReBictn.js";
4
- import { useRef as b, useEffect as v } from "preact/hooks";
5
- import { Fragment as w } from "preact";
6
- function I(o, i) {
7
- var t, n, e;
8
- const r = ((t = i.products) == null ? void 0 : t.total) ?? 0, s = ((n = o.products) == null ? void 0 : n.from) ?? 0, c = ((e = o.products) == null ? void 0 : e.size) ?? 0;
9
- return r > 0 && r > s + c;
10
- }
11
- function M() {
12
- return !!(window.IntersectionObserver && window.IntersectionObserverEntry && "intersectionRatio" in window.IntersectionObserverEntry.prototype);
13
- }
14
- function S({
15
- children: o,
16
- pageSize: i,
17
- observerOptions: r = {}
18
- }) {
19
- const s = b(null), { query: c, response: t } = l((e) => m(e, "query", "response")), { loadMore: n } = d(i);
20
- return v(() => {
21
- let e, u;
22
- return I(c, t) && (e = s.current, u = new IntersectionObserver((a) => {
23
- const f = a[0];
24
- f != null && f.isIntersecting && n();
25
- }, r), e && u.observe(e)), () => {
26
- e && u.unobserve(e);
27
- };
28
- }, [t, r]), /* @__PURE__ */ p(w, { children: [
29
- o,
30
- /* @__PURE__ */ p("div", { ref: s, style: { height: "1px" } })
31
- ] });
32
- }
33
- export {
34
- S as I,
35
- I as h,
36
- M as i
37
- };