Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-search-dropdown

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-search-dropdown - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

1

dist/components/SearchSelect.d.ts

@@ -8,4 +8,5 @@ import { default as React } from 'react';

data: SelectItem[] | ((search?: string) => SelectItem[]);
itemClassName?: string;
}
declare const SearchSelect: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLInputElement>>;
export default SearchSelect;

491

dist/index.es.js

@@ -1,12 +0,12 @@

import { jsxs as ne, jsx as B } from "react/jsx-runtime";
import * as l from "react";
import ae, { useState as x, useRef as H, useEffect as z } from "react";
var E = function() {
return E = Object.assign || function(t) {
import { jsxs as ne, Fragment as ae, jsx as M } from "react/jsx-runtime";
import * as i from "react";
import oe, { useState as P, useRef as H, useEffect as j } from "react";
var k = function() {
return k = Object.assign || function(t) {
for (var n, r = 1, a = arguments.length; r < a; r++) {
n = arguments[r];
for (var c in n) Object.prototype.hasOwnProperty.call(n, c) && (t[c] = n[c]);
for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
}
return t;
}, E.apply(this, arguments);
}, k.apply(this, arguments);
};

@@ -21,13 +21,13 @@ function U(e, t) {

}
function oe(e, t, n) {
if (n || arguments.length === 2) for (var r = 0, a = t.length, c; r < a; r++)
(c || !(r in t)) && (c || (c = Array.prototype.slice.call(t, 0, r)), c[r] = t[r]);
return e.concat(c || Array.prototype.slice.call(t));
function ce(e, t, n) {
if (n || arguments.length === 2) for (var r = 0, a = t.length, o; r < a; r++)
(o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
return e.concat(o || Array.prototype.slice.call(t));
}
var I = "right-scroll-bar-position", A = "width-before-scroll-bar", ce = "with-scroll-bars-hidden", ie = "--removed-body-scroll-bar-size";
function j(e, t) {
var I = "right-scroll-bar-position", A = "width-before-scroll-bar", le = "with-scroll-bars-hidden", ie = "--removed-body-scroll-bar-size";
function V(e, t) {
return typeof e == "function" ? e(t) : e && (e.current = t), e;
}
function le(e, t) {
var n = x(function() {
function ue(e, t) {
var n = P(function() {
return {

@@ -52,27 +52,27 @@ // value

}
var ue = typeof window < "u" ? l.useLayoutEffect : l.useEffect, F = /* @__PURE__ */ new WeakMap();
function se(e, t) {
var n = le(null, function(r) {
var se = typeof window < "u" ? i.useLayoutEffect : i.useEffect, _ = /* @__PURE__ */ new WeakMap();
function fe(e, t) {
var n = ue(null, function(r) {
return e.forEach(function(a) {
return j(a, r);
return V(a, r);
});
});
return ue(function() {
var r = F.get(n);
return se(function() {
var r = _.get(n);
if (r) {
var a = new Set(r), c = new Set(e), u = n.current;
a.forEach(function(o) {
c.has(o) || j(o, null);
}), c.forEach(function(o) {
a.has(o) || j(o, u);
var a = new Set(r), o = new Set(e), f = n.current;
a.forEach(function(c) {
o.has(c) || V(c, null);
}), o.forEach(function(c) {
a.has(c) || V(c, f);
});
}
F.set(n, e);
_.set(n, e);
}, [e]), n;
}
function fe(e) {
function de(e) {
return e;
}
function de(e, t) {
t === void 0 && (t = fe);
function ve(e, t) {
t === void 0 && (t = de);
var n = [], r = !1, a = {

@@ -84,18 +84,18 @@ read: function() {

},
useMedium: function(c) {
var u = t(c, r);
return n.push(u), function() {
n = n.filter(function(o) {
return o !== u;
useMedium: function(o) {
var f = t(o, r);
return n.push(f), function() {
n = n.filter(function(c) {
return c !== f;
});
};
},
assignSyncMedium: function(c) {
assignSyncMedium: function(o) {
for (r = !0; n.length; ) {
var u = n;
n = [], u.forEach(c);
var f = n;
n = [], f.forEach(o);
}
n = {
push: function(o) {
return c(o);
push: function(c) {
return o(c);
},

@@ -107,21 +107,21 @@ filter: function() {

},
assignMedium: function(c) {
assignMedium: function(o) {
r = !0;
var u = [];
var f = [];
if (n.length) {
var o = n;
n = [], o.forEach(c), u = n;
var c = n;
n = [], c.forEach(o), f = n;
}
var m = function() {
var d = u;
u = [], d.forEach(c);
}, b = function() {
return Promise.resolve().then(m);
var S = function() {
var h = f;
f = [], h.forEach(o);
}, y = function() {
return Promise.resolve().then(S);
};
b(), n = {
push: function(d) {
u.push(d), b();
y(), n = {
push: function(h) {
f.push(h), y();
},
filter: function(d) {
return u = u.filter(d), n;
filter: function(h) {
return f = f.filter(h), n;
}

@@ -133,6 +133,6 @@ };

}
function ve(e) {
function he(e) {
e === void 0 && (e = {});
var t = de(null);
return t.options = E({ async: !0, ssr: !1 }, e), t;
var t = ve(null);
return t.options = k({ async: !0, ssr: !1 }, e), t;
}

@@ -146,20 +146,20 @@ var $ = function(e) {

throw new Error("Sidecar medium not found");
return l.createElement(r, E({}, n));
return i.createElement(r, k({}, n));
};
$.isSideCarExport = !0;
function he(e, t) {
function me(e, t) {
return e.useMedium(t), $;
}
var q = ve(), V = function() {
}, W = l.forwardRef(function(e, t) {
var n = l.useRef(null), r = l.useState({
onScrollCapture: V,
onWheelCapture: V,
onTouchMoveCapture: V
}), a = r[0], c = r[1], u = e.forwardProps, o = e.children, m = e.className, b = e.removeScrollBar, d = e.enabled, y = e.shards, S = e.sideCar, g = e.noIsolation, C = e.inert, i = e.allowPinchZoom, s = e.as, f = s === void 0 ? "div" : s, v = e.gapMode, p = U(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), w = S, h = se([n, t]), R = E(E({}, p), a);
return l.createElement(
l.Fragment,
var q = he(), X = function() {
}, W = i.forwardRef(function(e, t) {
var n = i.useRef(null), r = i.useState({
onScrollCapture: X,
onWheelCapture: X,
onTouchMoveCapture: X
}), a = r[0], o = r[1], f = e.forwardProps, c = e.children, S = e.className, y = e.removeScrollBar, h = e.enabled, E = e.shards, R = e.sideCar, C = e.noIsolation, m = e.inert, l = e.allowPinchZoom, u = e.as, v = u === void 0 ? "div" : u, p = e.gapMode, b = U(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), w = R, d = fe([n, t]), s = k(k({}, b), a);
return i.createElement(
i.Fragment,
null,
d && l.createElement(w, { sideCar: q, removeScrollBar: b, shards: y, noIsolation: g, inert: C, setCallbacks: c, allowPinchZoom: !!i, lockRef: n, gapMode: v }),
u ? l.cloneElement(l.Children.only(o), E(E({}, R), { ref: h })) : l.createElement(f, E({}, R, { className: m, ref: h }), o)
h && i.createElement(w, { sideCar: q, removeScrollBar: y, shards: E, noIsolation: C, inert: m, setCallbacks: o, allowPinchZoom: !!l, lockRef: n, gapMode: p }),
f ? i.cloneElement(i.Children.only(c), k(k({}, s), { ref: d })) : i.createElement(v, k({}, s, { className: S, ref: d }), c)
);

@@ -180,3 +180,3 @@ });

};
function me() {
function ye() {
if (!document)

@@ -189,14 +189,14 @@ return null;

}
function pe(e, t) {
function be(e, t) {
e.styleSheet ? e.styleSheet.cssText = t : e.appendChild(document.createTextNode(t));
}
function be(e) {
function pe(e) {
var t = document.head || document.getElementsByTagName("head")[0];
t.appendChild(e);
}
var ye = function() {
var Se = function() {
var e = 0, t = null;
return {
add: function(n) {
e == 0 && (t = me()) && (pe(t, n), be(t)), e++;
e == 0 && (t = ye()) && (be(t, n), pe(t)), e++;
},

@@ -207,6 +207,6 @@ remove: function() {

};
}, Se = function() {
var e = ye();
}, we = function() {
var e = Se();
return function(t, n) {
l.useEffect(function() {
i.useEffect(function() {
return e.add(t), function() {

@@ -218,3 +218,3 @@ e.remove();

}, J = function() {
var e = Se(), t = function(n) {
var e = we(), t = function(n) {
var r = n.styles, a = n.dynamic;

@@ -224,3 +224,3 @@ return e(r, a), null;

return t;
}, we = {
}, Ce = {
left: 0,

@@ -230,11 +230,11 @@ top: 0,

gap: 0
}, X = function(e) {
}, Y = function(e) {
return parseInt(e || "", 10) || 0;
}, Ce = function(e) {
}, Ee = function(e) {
var t = window.getComputedStyle(document.body), n = t[e === "padding" ? "paddingLeft" : "marginLeft"], r = t[e === "padding" ? "paddingTop" : "marginTop"], a = t[e === "padding" ? "paddingRight" : "marginRight"];
return [X(n), X(r), X(a)];
}, Ee = function(e) {
return [Y(n), Y(r), Y(a)];
}, Re = function(e) {
if (e === void 0 && (e = "margin"), typeof window > "u")
return we;
var t = Ce(e), n = document.documentElement.clientWidth, r = window.innerWidth;
return Ce;
var t = Ee(e), n = document.documentElement.clientWidth, r = window.innerWidth;
return {

@@ -246,8 +246,8 @@ left: t[0],

};
}, Re = J(), N = "data-scroll-locked", ke = function(e, t, n, r) {
var a = e.left, c = e.top, u = e.right, o = e.gap;
}, ke = J(), N = "data-scroll-locked", xe = function(e, t, n, r) {
var a = e.left, o = e.top, f = e.right, c = e.gap;
return n === void 0 && (n = "margin"), `
.`.concat(ce, ` {
.`.concat(le, ` {
overflow: hidden `).concat(r, `;
padding-right: `).concat(o, "px ").concat(r, `;
padding-right: `).concat(c, "px ").concat(r, `;
}

@@ -261,9 +261,9 @@ body[`).concat(N, `] {

padding-left: `.concat(a, `px;
padding-top: `).concat(c, `px;
padding-right: `).concat(u, `px;
padding-top: `).concat(o, `px;
padding-right: `).concat(f, `px;
margin-left:0;
margin-top:0;
margin-right: `).concat(o, "px ").concat(r, `;
margin-right: `).concat(c, "px ").concat(r, `;
`),
n === "padding" && "padding-right: ".concat(o, "px ").concat(r, ";")
n === "padding" && "padding-right: ".concat(c, "px ").concat(r, ";")
].filter(Boolean).join(""), `

@@ -273,7 +273,7 @@ }

.`).concat(I, ` {
right: `).concat(o, "px ").concat(r, `;
right: `).concat(c, "px ").concat(r, `;
}
.`).concat(A, ` {
margin-right: `).concat(o, "px ").concat(r, `;
margin-right: `).concat(c, "px ").concat(r, `;
}

@@ -290,35 +290,35 @@

body[`).concat(N, `] {
`).concat(ie, ": ").concat(o, `px;
`).concat(ie, ": ").concat(c, `px;
}
`);
}, _ = function() {
}, z = function() {
var e = parseInt(document.body.getAttribute(N) || "0", 10);
return isFinite(e) ? e : 0;
}, Pe = function() {
l.useEffect(function() {
return document.body.setAttribute(N, (_() + 1).toString()), function() {
var e = _() - 1;
}, Le = function() {
i.useEffect(function() {
return document.body.setAttribute(N, (z() + 1).toString()), function() {
var e = z() - 1;
e <= 0 ? document.body.removeAttribute(N) : document.body.setAttribute(N, e.toString());
};
}, []);
}, Le = function(e) {
}, Pe = function(e) {
var t = e.noRelative, n = e.noImportant, r = e.gapMode, a = r === void 0 ? "margin" : r;
Pe();
var c = l.useMemo(function() {
return Ee(a);
Le();
var o = i.useMemo(function() {
return Re(a);
}, [a]);
return l.createElement(Re, { styles: ke(c, !t, a, n ? "" : "!important") });
}, Y = !1;
return i.createElement(ke, { styles: xe(o, !t, a, n ? "" : "!important") });
}, D = !1;
if (typeof window < "u")
try {
var T = Object.defineProperty({}, "passive", {
var B = Object.defineProperty({}, "passive", {
get: function() {
return Y = !0, !0;
return D = !0, !0;
}
});
window.addEventListener("test", T, T), window.removeEventListener("test", T, T);
window.addEventListener("test", B, B), window.removeEventListener("test", B, B);
} catch {
Y = !1;
D = !1;
}
var P = Y ? { passive: !1 } : !1, xe = function(e) {
var x = D ? { passive: !1 } : !1, Ne = function(e) {
return e.tagName === "TEXTAREA";

@@ -332,7 +332,7 @@ }, K = function(e, t) {

n[t] !== "hidden" && // contains scroll inside self
!(n.overflowY === n.overflowX && !xe(e) && n[t] === "visible")
!(n.overflowY === n.overflowX && !Ne(e) && n[t] === "visible")
);
}, Ne = function(e) {
}, Me = function(e) {
return K(e, "overflowY");
}, Be = function(e) {
}, Te = function(e) {
return K(e, "overflowX");

@@ -345,4 +345,4 @@ }, Z = function(e, t) {

if (a) {
var c = te(e, r), u = c[1], o = c[2];
if (u > o)
var o = te(e, r), f = o[1], c = o[2];
if (f > c)
return !0;

@@ -353,3 +353,3 @@ }

return !1;
}, Me = function(e) {
}, Be = function(e) {
var t = e.scrollTop, n = e.scrollHeight, r = e.clientHeight;

@@ -361,3 +361,3 @@ return [

];
}, Te = function(e) {
}, Oe = function(e) {
var t = e.scrollLeft, n = e.scrollWidth, r = e.clientWidth;

@@ -370,18 +370,18 @@ return [

}, ee = function(e, t) {
return e === "v" ? Ne(t) : Be(t);
return e === "v" ? Me(t) : Te(t);
}, te = function(e, t) {
return e === "v" ? Me(t) : Te(t);
}, Oe = function(e, t) {
return e === "v" ? Be(t) : Oe(t);
}, Ie = function(e, t) {
return e === "h" && t === "rtl" ? -1 : 1;
}, Ie = function(e, t, n, r, a) {
var c = Oe(e, window.getComputedStyle(t).direction), u = c * r, o = n.target, m = t.contains(o), b = !1, d = u > 0, y = 0, S = 0;
}, Ae = function(e, t, n, r, a) {
var o = Ie(e, window.getComputedStyle(t).direction), f = o * r, c = n.target, S = t.contains(c), y = !1, h = f > 0, E = 0, R = 0;
do {
var g = te(e, o), C = g[0], i = g[1], s = g[2], f = i - s - c * C;
(C || f) && ee(e, o) && (y += f, S += C), o instanceof ShadowRoot ? o = o.host : o = o.parentNode;
var C = te(e, c), m = C[0], l = C[1], u = C[2], v = l - u - o * m;
(m || v) && ee(e, c) && (E += v, R += m), c instanceof ShadowRoot ? c = c.host : c = c.parentNode;
} while (
// portaled content
!m && o !== document.body || // self content
m && (t.contains(o) || t === o)
!S && c !== document.body || // self content
S && (t.contains(c) || t === c)
);
return (d && (Math.abs(y) < 1 || !a) || !d && (Math.abs(S) < 1 || !a)) && (b = !0), b;
return (h && (Math.abs(E) < 1 || !a) || !h && (Math.abs(R) < 1 || !a)) && (y = !0), y;
}, O = function(e) {

@@ -393,5 +393,5 @@ return "changedTouches" in e ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [0, 0];

return e && "current" in e ? e.current : e;
}, Ae = function(e, t) {
}, We = function(e, t) {
return e[0] === t[0] && e[1] === t[1];
}, We = function(e) {
}, je = function(e) {
return `

@@ -401,16 +401,16 @@ .block-interactivity-`.concat(e, ` {pointer-events: none;}

`);
}, je = 0, L = [];
function Ve(e) {
var t = l.useRef([]), n = l.useRef([0, 0]), r = l.useRef(), a = l.useState(je++)[0], c = l.useState(J)[0], u = l.useRef(e);
l.useEffect(function() {
u.current = e;
}, [e]), l.useEffect(function() {
}, Ve = 0, L = [];
function Xe(e) {
var t = i.useRef([]), n = i.useRef([0, 0]), r = i.useRef(), a = i.useState(Ve++)[0], o = i.useState(J)[0], f = i.useRef(e);
i.useEffect(function() {
f.current = e;
}, [e]), i.useEffect(function() {
if (e.inert) {
document.body.classList.add("block-interactivity-".concat(a));
var i = oe([e.lockRef.current], (e.shards || []).map(G), !0).filter(Boolean);
return i.forEach(function(s) {
return s.classList.add("allow-interactivity-".concat(a));
var l = ce([e.lockRef.current], (e.shards || []).map(G), !0).filter(Boolean);
return l.forEach(function(u) {
return u.classList.add("allow-interactivity-".concat(a));
}), function() {
document.body.classList.remove("block-interactivity-".concat(a)), i.forEach(function(s) {
return s.classList.remove("allow-interactivity-".concat(a));
document.body.classList.remove("block-interactivity-".concat(a)), l.forEach(function(u) {
return u.classList.remove("allow-interactivity-".concat(a));
});

@@ -420,68 +420,68 @@ };

}, [e.inert, e.lockRef.current, e.shards]);
var o = l.useCallback(function(i, s) {
if ("touches" in i && i.touches.length === 2)
return !u.current.allowPinchZoom;
var f = O(i), v = n.current, p = "deltaX" in i ? i.deltaX : v[0] - f[0], w = "deltaY" in i ? i.deltaY : v[1] - f[1], h, R = i.target, k = Math.abs(p) > Math.abs(w) ? "h" : "v";
if ("touches" in i && k === "h" && R.type === "range")
var c = i.useCallback(function(l, u) {
if ("touches" in l && l.touches.length === 2)
return !f.current.allowPinchZoom;
var v = O(l), p = n.current, b = "deltaX" in l ? l.deltaX : p[0] - v[0], w = "deltaY" in l ? l.deltaY : p[1] - v[1], d, s = l.target, g = Math.abs(b) > Math.abs(w) ? "h" : "v";
if ("touches" in l && g === "h" && s.type === "range")
return !1;
var M = Z(k, R);
if (!M)
var T = Z(g, s);
if (!T)
return !0;
if (M ? h = k : (h = k === "v" ? "h" : "v", M = Z(k, R)), !M)
if (T ? d = g : (d = g === "v" ? "h" : "v", T = Z(g, s)), !T)
return !1;
if (!r.current && "changedTouches" in i && (p || w) && (r.current = h), !h)
if (!r.current && "changedTouches" in l && (b || w) && (r.current = d), !d)
return !0;
var D = r.current || h;
return Ie(D, s, i, D === "h" ? p : w, !0);
}, []), m = l.useCallback(function(i) {
var s = i;
if (!(!L.length || L[L.length - 1] !== c)) {
var f = "deltaY" in s ? Q(s) : O(s), v = t.current.filter(function(h) {
return h.name === s.type && (h.target === s.target || s.target === h.shadowParent) && Ae(h.delta, f);
var F = r.current || d;
return Ae(F, u, l, F === "h" ? b : w, !0);
}, []), S = i.useCallback(function(l) {
var u = l;
if (!(!L.length || L[L.length - 1] !== o)) {
var v = "deltaY" in u ? Q(u) : O(u), p = t.current.filter(function(d) {
return d.name === u.type && (d.target === u.target || u.target === d.shadowParent) && We(d.delta, v);
})[0];
if (v && v.should) {
s.cancelable && s.preventDefault();
if (p && p.should) {
u.cancelable && u.preventDefault();
return;
}
if (!v) {
var p = (u.current.shards || []).map(G).filter(Boolean).filter(function(h) {
return h.contains(s.target);
}), w = p.length > 0 ? o(s, p[0]) : !u.current.noIsolation;
w && s.cancelable && s.preventDefault();
if (!p) {
var b = (f.current.shards || []).map(G).filter(Boolean).filter(function(d) {
return d.contains(u.target);
}), w = b.length > 0 ? c(u, b[0]) : !f.current.noIsolation;
w && u.cancelable && u.preventDefault();
}
}
}, []), b = l.useCallback(function(i, s, f, v) {
var p = { name: i, delta: s, target: f, should: v, shadowParent: Xe(f) };
t.current.push(p), setTimeout(function() {
}, []), y = i.useCallback(function(l, u, v, p) {
var b = { name: l, delta: u, target: v, should: p, shadowParent: Ye(v) };
t.current.push(b), setTimeout(function() {
t.current = t.current.filter(function(w) {
return w !== p;
return w !== b;
});
}, 1);
}, []), d = l.useCallback(function(i) {
n.current = O(i), r.current = void 0;
}, []), y = l.useCallback(function(i) {
b(i.type, Q(i), i.target, o(i, e.lockRef.current));
}, []), S = l.useCallback(function(i) {
b(i.type, O(i), i.target, o(i, e.lockRef.current));
}, []), h = i.useCallback(function(l) {
n.current = O(l), r.current = void 0;
}, []), E = i.useCallback(function(l) {
y(l.type, Q(l), l.target, c(l, e.lockRef.current));
}, []), R = i.useCallback(function(l) {
y(l.type, O(l), l.target, c(l, e.lockRef.current));
}, []);
l.useEffect(function() {
return L.push(c), e.setCallbacks({
onScrollCapture: y,
onWheelCapture: y,
onTouchMoveCapture: S
}), document.addEventListener("wheel", m, P), document.addEventListener("touchmove", m, P), document.addEventListener("touchstart", d, P), function() {
L = L.filter(function(i) {
return i !== c;
}), document.removeEventListener("wheel", m, P), document.removeEventListener("touchmove", m, P), document.removeEventListener("touchstart", d, P);
i.useEffect(function() {
return L.push(o), e.setCallbacks({
onScrollCapture: E,
onWheelCapture: E,
onTouchMoveCapture: R
}), document.addEventListener("wheel", S, x), document.addEventListener("touchmove", S, x), document.addEventListener("touchstart", h, x), function() {
L = L.filter(function(l) {
return l !== o;
}), document.removeEventListener("wheel", S, x), document.removeEventListener("touchmove", S, x), document.removeEventListener("touchstart", h, x);
};
}, []);
var g = e.removeScrollBar, C = e.inert;
return l.createElement(
l.Fragment,
var C = e.removeScrollBar, m = e.inert;
return i.createElement(
i.Fragment,
null,
C ? l.createElement(c, { styles: We(a) }) : null,
g ? l.createElement(Le, { gapMode: e.gapMode }) : null
m ? i.createElement(o, { styles: je(a) }) : null,
C ? i.createElement(Pe, { gapMode: e.gapMode }) : null
);
}
function Xe(e) {
function Ye(e) {
for (var t = null; e !== null; )

@@ -491,73 +491,86 @@ e instanceof ShadowRoot && (t = e.host, e = e.host), e = e.parentNode;

}
const Ye = he(q, Ve);
var re = l.forwardRef(function(e, t) {
return l.createElement(W, E({}, e, { ref: t, sideCar: Ye }));
const De = me(q, Xe);
var re = i.forwardRef(function(e, t) {
return i.createElement(W, k({}, e, { ref: t, sideCar: De }));
});
re.classNames = W.classNames;
const ze = ae.forwardRef((e, t) => {
const [n, r] = x(!1), [a, c] = x(!1), [u, o] = x({ label: "", value: "" }), [m, b] = x(""), [d, y] = x(), { data: S, ...g } = e, C = H(null), i = H(null);
z(() => {
if (a) {
c(!1);
const Fe = oe.forwardRef(({
data: e,
placeholder: t,
className: n,
itemClassName: r,
disabled: a,
onChange: o,
...f
}, c) => {
const [S, y] = P(!1), [h, E] = P(!1), [R, C] = P({ label: "", value: "" }), [m, l] = P(""), [u, v] = P(), p = H(null), b = H(null), w = (s) => {
o && o({
target: {
name: f.name,
value: (s == null ? void 0 : s.value) ?? ""
}
});
};
j(() => {
if (h) {
E(!1);
return;
}
if (d != null && d.length && m && y(void 0), S && typeof S == "function") {
const f = S(m);
if (f instanceof Promise) {
f.then((v) => {
y(v);
if (u != null && u.length && m && v(void 0), e && typeof e == "function") {
const s = e(m);
if (s instanceof Promise) {
s.then((g) => {
v(g);
});
return;
}
y(f);
} else S && y(S);
}, [a]);
const s = (f) => {
const v = f.target;
C.current && !C.current.contains(v) && i.current && !i.current.contains(v) && r(!1);
v(s);
} else e && v(e);
}, [h]);
const d = (s) => {
const g = s.target;
p.current && !p.current.contains(g) && b.current && !b.current.contains(g) && y(!1);
};
return z(() => (document.addEventListener("mousedown", s), () => {
document.removeEventListener("mousedown", s);
}), []), /* @__PURE__ */ ne("div", { children: [
/* @__PURE__ */ B(
return j(() => (document.addEventListener("mousedown", d), () => {
document.removeEventListener("mousedown", d);
}), []), j(() => {
if (m !== "" && u && u.length > 0) {
const s = u.find((g) => g.label.toLowerCase() === m);
console.log(s, m, u.map((g) => g.label.toLowerCase())), s && (C(s), w(s));
} else m === "" && w();
}, [m]), /* @__PURE__ */ ne(ae, { children: [
/* @__PURE__ */ M(
"input",
{
ref: C,
onFocus: () => r(!0),
className: "p-2 bg-gray-200 cursor-pointer focus:cursor-text",
ref: p,
onFocus: () => y(!0),
className: n,
type: "text",
value: u.label,
onChange: (f) => {
var p, w;
const v = ((p = d == null ? void 0 : d.find((h) => {
var R, k;
return ((R = h.value) == null ? void 0 : R.toLowerCase()) === ((k = f.target.value) == null ? void 0 : k.toLowerCase());
})) == null ? void 0 : p.value) ?? u.value;
b((w = f.target.value) == null ? void 0 : w.toLowerCase()), o({ label: f.target.value ?? "", value: v }), c(!0), g.onChange && g.onChange(f);
value: R.label,
onChange: (s) => {
C({ label: s.target.value ?? "", value: R.value }), l(s.target.value.toLowerCase()), E(!0);
},
placeholder: g.placeholder,
disabled: g.disabled
disabled: a,
placeholder: t
}
),
/* @__PURE__ */ B(
/* @__PURE__ */ M(
"input",
{
id: g.name,
name: g.name,
onChange: g.onChange,
onBlur: g.onBlur,
ref: t,
disabled: !0,
ref: c,
className: "hidden",
type: "text",
value: u.value
value: R.value,
onChange: o,
...f
}
),
n && d && d.length > 0 && /* @__PURE__ */ B(re, { children: /* @__PURE__ */ B("div", { ref: i, className: "absolute z-10 w-full bg-white border border-gray-300 rounded mt-1", children: d.filter((f) => f.label.toLowerCase().indexOf(m ?? "") > -1).map((f, v) => /* @__PURE__ */ B("div", { className: "p-2 cursor-pointer hover:bg-gray-100", onClick: () => {
o(f), r(!1);
}, children: f.label }, v)) }) })
S && u && u.length > 0 && /* @__PURE__ */ M(re, { children: /* @__PURE__ */ M("div", { ref: b, className: "fixed flex flex-col bg-white border border-gray-300 rounded mt-1 max-h-[20%] overflow-y-auto", children: u.filter((s) => s.label.toLowerCase().indexOf(m ?? "") > -1).map((s, g) => /* @__PURE__ */ M("div", { className: r, onClick: () => {
C(s), y(!1), w(s);
}, children: s.label }, g)) }) })
] });
});
Fe.displayName = "SearchSelect";
export {
ze as SearchSelect
Fe as SearchSelect
};

@@ -1,7 +0,7 @@

(function(L,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],k):(L=typeof globalThis<"u"?globalThis:L||self,k(L["simple-search-dropdown"]={},L["react/jsx-runtime"],L.React))})(this,function(L,k,y){"use strict";function re(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const l=re(y);var P=function(){return P=Object.assign||function(t){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var c in n)Object.prototype.hasOwnProperty.call(n,c)&&(t[c]=n[c])}return t},P.apply(this,arguments)};function z(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n}function ne(e,t,n){if(n||arguments.length===2)for(var r=0,a=t.length,c;r<a;r++)(c||!(r in t))&&(c||(c=Array.prototype.slice.call(t,0,r)),c[r]=t[r]);return e.concat(c||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var M="right-scroll-bar-position",B="width-before-scroll-bar",ae="with-scroll-bars-hidden",oe="--removed-body-scroll-bar-size";function D(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function ce(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=t,n.facade}var ie=typeof window<"u"?l.useLayoutEffect:l.useEffect,H=new WeakMap;function le(e,t){var n=ce(null,function(r){return e.forEach(function(a){return D(a,r)})});return ie(function(){var r=H.get(n);if(r){var a=new Set(r),c=new Set(e),u=n.current;a.forEach(function(o){c.has(o)||D(o,null)}),c.forEach(function(o){a.has(o)||D(o,u)})}H.set(n,e)},[e]),n}function ue(e){return e}function se(e,t){t===void 0&&(t=ue);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(c){var u=t(c,r);return n.push(u),function(){n=n.filter(function(o){return o!==u})}},assignSyncMedium:function(c){for(r=!0;n.length;){var u=n;n=[],u.forEach(c)}n={push:function(o){return c(o)},filter:function(){return n}}},assignMedium:function(c){r=!0;var u=[];if(n.length){var o=n;n=[],o.forEach(c),u=n}var m=function(){var d=u;u=[],d.forEach(c)},b=function(){return Promise.resolve().then(m)};b(),n={push:function(d){u.push(d),b()},filter:function(d){return u=u.filter(d),n}}}};return a}function fe(e){e===void 0&&(e={});var t=se(null);return t.options=P({async:!0,ssr:!1},e),t}var _=function(e){var t=e.sideCar,n=z(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return l.createElement(r,P({},n))};_.isSideCarExport=!0;function de(e,t){return e.useMedium(t),_}var F=fe(),V=function(){},j=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:V,onWheelCapture:V,onTouchMoveCapture:V}),a=r[0],c=r[1],u=e.forwardProps,o=e.children,m=e.className,b=e.removeScrollBar,d=e.enabled,S=e.shards,w=e.sideCar,g=e.noIsolation,E=e.inert,i=e.allowPinchZoom,s=e.as,f=s===void 0?"div":s,v=e.gapMode,p=z(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=w,h=le([n,t]),x=P(P({},p),a);return l.createElement(l.Fragment,null,d&&l.createElement(C,{sideCar:F,removeScrollBar:b,shards:S,noIsolation:g,inert:E,setCallbacks:c,allowPinchZoom:!!i,lockRef:n,gapMode:v}),u?l.cloneElement(l.Children.only(o),P(P({},x),{ref:h})):l.createElement(f,P({},x,{className:m,ref:h}),o))});j.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},j.classNames={fullWidth:B,zeroRight:M};var ve=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function he(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ve();return t&&e.setAttribute("nonce",t),e}function ge(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function me(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var pe=function(){var e=0,t=null;return{add:function(n){e==0&&(t=he())&&(ge(t,n),me(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},be=function(){var e=pe();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Z=function(){var e=be(),t=function(n){var r=n.styles,a=n.dynamic;return e(r,a),null};return t},ye={left:0,top:0,right:0,gap:0},X=function(e){return parseInt(e||"",10)||0},Se=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[X(n),X(r),X(a)]},we=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ye;var t=Se(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Ce=Z(),T="data-scroll-locked",Ee=function(e,t,n,r){var a=e.left,c=e.top,u=e.right,o=e.gap;return n===void 0&&(n="margin"),`
.`.concat(ae,` {
(function(T,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],E):(T=typeof globalThis<"u"?globalThis:T||self,E(T["simple-search-dropdown"]={},T["react/jsx-runtime"],T.React))})(this,function(T,E,b){"use strict";function ne(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const l=ne(b);var x=function(){return x=Object.assign||function(t){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},x.apply(this,arguments)};function F(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n}function ae(e,t,n){if(n||arguments.length===2)for(var r=0,a=t.length,o;r<a;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var R="right-scroll-bar-position",B="width-before-scroll-bar",oe="with-scroll-bars-hidden",ce="--removed-body-scroll-bar-size";function D(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function ie(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=t,n.facade}var le=typeof window<"u"?l.useLayoutEffect:l.useEffect,H=new WeakMap;function ue(e,t){var n=ie(null,function(r){return e.forEach(function(a){return D(a,r)})});return le(function(){var r=H.get(n);if(r){var a=new Set(r),o=new Set(e),f=n.current;a.forEach(function(c){o.has(c)||D(c,null)}),o.forEach(function(c){a.has(c)||D(c,f)})}H.set(n,e)},[e]),n}function se(e){return e}function fe(e,t){t===void 0&&(t=se);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var f=t(o,r);return n.push(f),function(){n=n.filter(function(c){return c!==f})}},assignSyncMedium:function(o){for(r=!0;n.length;){var f=n;n=[],f.forEach(o)}n={push:function(c){return o(c)},filter:function(){return n}}},assignMedium:function(o){r=!0;var f=[];if(n.length){var c=n;n=[],c.forEach(o),f=n}var w=function(){var h=f;f=[],h.forEach(o)},p=function(){return Promise.resolve().then(w)};p(),n={push:function(h){f.push(h),p()},filter:function(h){return f=f.filter(h),n}}}};return a}function de(e){e===void 0&&(e={});var t=fe(null);return t.options=x({async:!0,ssr:!1},e),t}var _=function(e){var t=e.sideCar,n=F(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return l.createElement(r,x({},n))};_.isSideCarExport=!0;function ve(e,t){return e.useMedium(t),_}var z=de(),V=function(){},j=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:V,onWheelCapture:V,onTouchMoveCapture:V}),a=r[0],o=r[1],f=e.forwardProps,c=e.children,w=e.className,p=e.removeScrollBar,h=e.enabled,P=e.shards,L=e.sideCar,k=e.noIsolation,g=e.inert,i=e.allowPinchZoom,u=e.as,v=u===void 0?"div":u,y=e.gapMode,S=F(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=L,d=ue([n,t]),s=x(x({},S),a);return l.createElement(l.Fragment,null,h&&l.createElement(C,{sideCar:z,removeScrollBar:p,shards:P,noIsolation:k,inert:g,setCallbacks:o,allowPinchZoom:!!i,lockRef:n,gapMode:y}),f?l.cloneElement(l.Children.only(c),x(x({},s),{ref:d})):l.createElement(v,x({},s,{className:w,ref:d}),c))});j.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},j.classNames={fullWidth:B,zeroRight:R};var he=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ge(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=he();return t&&e.setAttribute("nonce",t),e}function me(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function pe(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Se=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ge())&&(me(t,n),pe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ye=function(){var e=Se();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Z=function(){var e=ye(),t=function(n){var r=n.styles,a=n.dynamic;return e(r,a),null};return t},be={left:0,top:0,right:0,gap:0},X=function(e){return parseInt(e||"",10)||0},we=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[X(n),X(r),X(a)]},Ce=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return be;var t=we(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Ee=Z(),N="data-scroll-locked",ke=function(e,t,n,r){var a=e.left,o=e.top,f=e.right,c=e.gap;return n===void 0&&(n="margin"),`
.`.concat(oe,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(o,"px ").concat(r,`;
padding-right: `).concat(c,"px ").concat(r,`;
}
body[`).concat(T,`] {
body[`).concat(N,`] {
overflow: hidden `).concat(r,`;

@@ -11,19 +11,19 @@ overscroll-behavior: contain;

padding-left: `.concat(a,`px;
padding-top: `).concat(c,`px;
padding-right: `).concat(u,`px;
padding-top: `).concat(o,`px;
padding-right: `).concat(f,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(o,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(o,"px ").concat(r,";")].filter(Boolean).join(""),`
margin-right: `).concat(c,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
}
.`).concat(M,` {
right: `).concat(o,"px ").concat(r,`;
.`).concat(R,` {
right: `).concat(c,"px ").concat(r,`;
}
.`).concat(B,` {
margin-right: `).concat(o,"px ").concat(r,`;
margin-right: `).concat(c,"px ").concat(r,`;
}
.`).concat(M," .").concat(M,` {
.`).concat(R," .").concat(R,` {
right: 0 `).concat(r,`;

@@ -36,8 +36,8 @@ }

body[`).concat(T,`] {
`).concat(oe,": ").concat(o,`px;
body[`).concat(N,`] {
`).concat(ce,": ").concat(c,`px;
}
`)},Q=function(){var e=parseInt(document.body.getAttribute(T)||"0",10);return isFinite(e)?e:0},ke=function(){l.useEffect(function(){return document.body.setAttribute(T,(Q()+1).toString()),function(){var e=Q()-1;e<=0?document.body.removeAttribute(T):document.body.setAttribute(T,e.toString())}},[])},Pe=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=r===void 0?"margin":r;ke();var c=l.useMemo(function(){return we(a)},[a]);return l.createElement(Ce,{styles:Ee(c,!t,a,n?"":"!important")})},Y=!1;if(typeof window<"u")try{var I=Object.defineProperty({},"passive",{get:function(){return Y=!0,!0}});window.addEventListener("test",I,I),window.removeEventListener("test",I,I)}catch{Y=!1}var N=Y?{passive:!1}:!1,xe=function(e){return e.tagName==="TEXTAREA"},q=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!xe(e)&&n[t]==="visible")},Le=function(e){return q(e,"overflowY")},Re=function(e){return q(e,"overflowX")},G=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=U(e,r);if(a){var c=$(e,r),u=c[1],o=c[2];if(u>o)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Te=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Ne=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},U=function(e,t){return e==="v"?Le(t):Re(t)},$=function(e,t){return e==="v"?Te(t):Ne(t)},Oe=function(e,t){return e==="h"&&t==="rtl"?-1:1},Me=function(e,t,n,r,a){var c=Oe(e,window.getComputedStyle(t).direction),u=c*r,o=n.target,m=t.contains(o),b=!1,d=u>0,S=0,w=0;do{var g=$(e,o),E=g[0],i=g[1],s=g[2],f=i-s-c*E;(E||f)&&U(e,o)&&(S+=f,w+=E),o instanceof ShadowRoot?o=o.host:o=o.parentNode}while(!m&&o!==document.body||m&&(t.contains(o)||t===o));return(d&&(Math.abs(S)<1||!a)||!d&&(Math.abs(w)<1||!a))&&(b=!0),b},A=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},J=function(e){return[e.deltaX,e.deltaY]},K=function(e){return e&&"current"in e?e.current:e},Be=function(e,t){return e[0]===t[0]&&e[1]===t[1]},je=function(e){return`
`)},Q=function(){var e=parseInt(document.body.getAttribute(N)||"0",10);return isFinite(e)?e:0},xe=function(){l.useEffect(function(){return document.body.setAttribute(N,(Q()+1).toString()),function(){var e=Q()-1;e<=0?document.body.removeAttribute(N):document.body.setAttribute(N,e.toString())}},[])},Pe=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=r===void 0?"margin":r;xe();var o=l.useMemo(function(){return Ce(a)},[a]);return l.createElement(Ee,{styles:ke(o,!t,a,n?"":"!important")})},Y=!1;if(typeof window<"u")try{var I=Object.defineProperty({},"passive",{get:function(){return Y=!0,!0}});window.addEventListener("test",I,I),window.removeEventListener("test",I,I)}catch{Y=!1}var O=Y?{passive:!1}:!1,Le=function(e){return e.tagName==="TEXTAREA"},q=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Le(e)&&n[t]==="visible")},Te=function(e){return q(e,"overflowY")},Ne=function(e){return q(e,"overflowX")},G=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=U(e,r);if(a){var o=$(e,r),f=o[1],c=o[2];if(f>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Oe=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Me=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},U=function(e,t){return e==="v"?Te(t):Ne(t)},$=function(e,t){return e==="v"?Oe(t):Me(t)},Re=function(e,t){return e==="h"&&t==="rtl"?-1:1},Be=function(e,t,n,r,a){var o=Re(e,window.getComputedStyle(t).direction),f=o*r,c=n.target,w=t.contains(c),p=!1,h=f>0,P=0,L=0;do{var k=$(e,c),g=k[0],i=k[1],u=k[2],v=i-u-o*g;(g||v)&&U(e,c)&&(P+=v,L+=g),c instanceof ShadowRoot?c=c.host:c=c.parentNode}while(!w&&c!==document.body||w&&(t.contains(c)||t===c));return(h&&(Math.abs(P)<1||!a)||!h&&(Math.abs(L)<1||!a))&&(p=!0),p},A=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},J=function(e){return[e.deltaX,e.deltaY]},K=function(e){return e&&"current"in e?e.current:e},je=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ie=function(e){return`
.block-interactivity-`.concat(e,` {pointer-events: none;}
.allow-interactivity-`).concat(e,` {pointer-events: all;}
`)},Ie=0,O=[];function Ae(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),a=l.useState(Ie++)[0],c=l.useState(Z)[0],u=l.useRef(e);l.useEffect(function(){u.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var i=ne([e.lockRef.current],(e.shards||[]).map(K),!0).filter(Boolean);return i.forEach(function(s){return s.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),i.forEach(function(s){return s.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var o=l.useCallback(function(i,s){if("touches"in i&&i.touches.length===2)return!u.current.allowPinchZoom;var f=A(i),v=n.current,p="deltaX"in i?i.deltaX:v[0]-f[0],C="deltaY"in i?i.deltaY:v[1]-f[1],h,x=i.target,R=Math.abs(p)>Math.abs(C)?"h":"v";if("touches"in i&&R==="h"&&x.type==="range")return!1;var W=G(R,x);if(!W)return!0;if(W?h=R:(h=R==="v"?"h":"v",W=G(R,x)),!W)return!1;if(!r.current&&"changedTouches"in i&&(p||C)&&(r.current=h),!h)return!0;var te=r.current||h;return Me(te,s,i,te==="h"?p:C,!0)},[]),m=l.useCallback(function(i){var s=i;if(!(!O.length||O[O.length-1]!==c)){var f="deltaY"in s?J(s):A(s),v=t.current.filter(function(h){return h.name===s.type&&(h.target===s.target||s.target===h.shadowParent)&&Be(h.delta,f)})[0];if(v&&v.should){s.cancelable&&s.preventDefault();return}if(!v){var p=(u.current.shards||[]).map(K).filter(Boolean).filter(function(h){return h.contains(s.target)}),C=p.length>0?o(s,p[0]):!u.current.noIsolation;C&&s.cancelable&&s.preventDefault()}}},[]),b=l.useCallback(function(i,s,f,v){var p={name:i,delta:s,target:f,should:v,shadowParent:We(f)};t.current.push(p),setTimeout(function(){t.current=t.current.filter(function(C){return C!==p})},1)},[]),d=l.useCallback(function(i){n.current=A(i),r.current=void 0},[]),S=l.useCallback(function(i){b(i.type,J(i),i.target,o(i,e.lockRef.current))},[]),w=l.useCallback(function(i){b(i.type,A(i),i.target,o(i,e.lockRef.current))},[]);l.useEffect(function(){return O.push(c),e.setCallbacks({onScrollCapture:S,onWheelCapture:S,onTouchMoveCapture:w}),document.addEventListener("wheel",m,N),document.addEventListener("touchmove",m,N),document.addEventListener("touchstart",d,N),function(){O=O.filter(function(i){return i!==c}),document.removeEventListener("wheel",m,N),document.removeEventListener("touchmove",m,N),document.removeEventListener("touchstart",d,N)}},[]);var g=e.removeScrollBar,E=e.inert;return l.createElement(l.Fragment,null,E?l.createElement(c,{styles:je(a)}):null,g?l.createElement(Pe,{gapMode:e.gapMode}):null)}function We(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const De=de(F,Ae);var ee=l.forwardRef(function(e,t){return l.createElement(j,P({},e,{ref:t,sideCar:De}))});ee.classNames=j.classNames;const Ve=y.forwardRef((e,t)=>{const[n,r]=y.useState(!1),[a,c]=y.useState(!1),[u,o]=y.useState({label:"",value:""}),[m,b]=y.useState(""),[d,S]=y.useState(),{data:w,...g}=e,E=y.useRef(null),i=y.useRef(null);y.useEffect(()=>{if(a){c(!1);return}if(d!=null&&d.length&&m&&S(void 0),w&&typeof w=="function"){const f=w(m);if(f instanceof Promise){f.then(v=>{S(v)});return}S(f)}else w&&S(w)},[a]);const s=f=>{const v=f.target;E.current&&!E.current.contains(v)&&i.current&&!i.current.contains(v)&&r(!1)};return y.useEffect(()=>(document.addEventListener("mousedown",s),()=>{document.removeEventListener("mousedown",s)}),[]),k.jsxs("div",{children:[k.jsx("input",{ref:E,onFocus:()=>r(!0),className:"p-2 bg-gray-200 cursor-pointer focus:cursor-text",type:"text",value:u.label,onChange:f=>{var p,C;const v=((p=d==null?void 0:d.find(h=>{var x,R;return((x=h.value)==null?void 0:x.toLowerCase())===((R=f.target.value)==null?void 0:R.toLowerCase())}))==null?void 0:p.value)??u.value;b((C=f.target.value)==null?void 0:C.toLowerCase()),o({label:f.target.value??"",value:v}),c(!0),g.onChange&&g.onChange(f)},placeholder:g.placeholder,disabled:g.disabled}),k.jsx("input",{id:g.name,name:g.name,onChange:g.onChange,onBlur:g.onBlur,ref:t,disabled:!0,className:"hidden",type:"text",value:u.value}),n&&d&&d.length>0&&k.jsx(ee,{children:k.jsx("div",{ref:i,className:"absolute z-10 w-full bg-white border border-gray-300 rounded mt-1",children:d.filter(f=>f.label.toLowerCase().indexOf(m??"")>-1).map((f,v)=>k.jsx("div",{className:"p-2 cursor-pointer hover:bg-gray-100",onClick:()=>{o(f),r(!1)},children:f.label},v))})})]})});L.SearchSelect=Ve,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});
`)},Ae=0,M=[];function We(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),a=l.useState(Ae++)[0],o=l.useState(Z)[0],f=l.useRef(e);l.useEffect(function(){f.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var i=ae([e.lockRef.current],(e.shards||[]).map(K),!0).filter(Boolean);return i.forEach(function(u){return u.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),i.forEach(function(u){return u.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(i,u){if("touches"in i&&i.touches.length===2)return!f.current.allowPinchZoom;var v=A(i),y=n.current,S="deltaX"in i?i.deltaX:y[0]-v[0],C="deltaY"in i?i.deltaY:y[1]-v[1],d,s=i.target,m=Math.abs(S)>Math.abs(C)?"h":"v";if("touches"in i&&m==="h"&&s.type==="range")return!1;var W=G(m,s);if(!W)return!0;if(W?d=m:(d=m==="v"?"h":"v",W=G(m,s)),!W)return!1;if(!r.current&&"changedTouches"in i&&(S||C)&&(r.current=d),!d)return!0;var re=r.current||d;return Be(re,u,i,re==="h"?S:C,!0)},[]),w=l.useCallback(function(i){var u=i;if(!(!M.length||M[M.length-1]!==o)){var v="deltaY"in u?J(u):A(u),y=t.current.filter(function(d){return d.name===u.type&&(d.target===u.target||u.target===d.shadowParent)&&je(d.delta,v)})[0];if(y&&y.should){u.cancelable&&u.preventDefault();return}if(!y){var S=(f.current.shards||[]).map(K).filter(Boolean).filter(function(d){return d.contains(u.target)}),C=S.length>0?c(u,S[0]):!f.current.noIsolation;C&&u.cancelable&&u.preventDefault()}}},[]),p=l.useCallback(function(i,u,v,y){var S={name:i,delta:u,target:v,should:y,shadowParent:De(v)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(C){return C!==S})},1)},[]),h=l.useCallback(function(i){n.current=A(i),r.current=void 0},[]),P=l.useCallback(function(i){p(i.type,J(i),i.target,c(i,e.lockRef.current))},[]),L=l.useCallback(function(i){p(i.type,A(i),i.target,c(i,e.lockRef.current))},[]);l.useEffect(function(){return M.push(o),e.setCallbacks({onScrollCapture:P,onWheelCapture:P,onTouchMoveCapture:L}),document.addEventListener("wheel",w,O),document.addEventListener("touchmove",w,O),document.addEventListener("touchstart",h,O),function(){M=M.filter(function(i){return i!==o}),document.removeEventListener("wheel",w,O),document.removeEventListener("touchmove",w,O),document.removeEventListener("touchstart",h,O)}},[]);var k=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(o,{styles:Ie(a)}):null,k?l.createElement(Pe,{gapMode:e.gapMode}):null)}function De(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Ve=ve(z,We);var ee=l.forwardRef(function(e,t){return l.createElement(j,x({},e,{ref:t,sideCar:Ve}))});ee.classNames=j.classNames;const te=b.forwardRef(({data:e,placeholder:t,className:n,itemClassName:r,disabled:a,onChange:o,...f},c)=>{const[w,p]=b.useState(!1),[h,P]=b.useState(!1),[L,k]=b.useState({label:"",value:""}),[g,i]=b.useState(""),[u,v]=b.useState(),y=b.useRef(null),S=b.useRef(null),C=s=>{o&&o({target:{name:f.name,value:(s==null?void 0:s.value)??""}})};b.useEffect(()=>{if(h){P(!1);return}if(u!=null&&u.length&&g&&v(void 0),e&&typeof e=="function"){const s=e(g);if(s instanceof Promise){s.then(m=>{v(m)});return}v(s)}else e&&v(e)},[h]);const d=s=>{const m=s.target;y.current&&!y.current.contains(m)&&S.current&&!S.current.contains(m)&&p(!1)};return b.useEffect(()=>(document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}),[]),b.useEffect(()=>{if(g!==""&&u&&u.length>0){const s=u.find(m=>m.label.toLowerCase()===g);console.log(s,g,u.map(m=>m.label.toLowerCase())),s&&(k(s),C(s))}else g===""&&C()},[g]),E.jsxs(E.Fragment,{children:[E.jsx("input",{ref:y,onFocus:()=>p(!0),className:n,type:"text",value:L.label,onChange:s=>{k({label:s.target.value??"",value:L.value}),i(s.target.value.toLowerCase()),P(!0)},disabled:a,placeholder:t}),E.jsx("input",{ref:c,className:"hidden",type:"text",value:L.value,onChange:o,...f}),w&&u&&u.length>0&&E.jsx(ee,{children:E.jsx("div",{ref:S,className:"fixed flex flex-col bg-white border border-gray-300 rounded mt-1 max-h-[20%] overflow-y-auto",children:u.filter(s=>s.label.toLowerCase().indexOf(g??"")>-1).map((s,m)=>E.jsx("div",{className:r,onClick:()=>{k(s),p(!1),C(s)},children:s.label},m))})})]})});te.displayName="SearchSelect",T.SearchSelect=te,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
{
"name": "simple-search-dropdown",
"private": false,
"version": "0.1.4",
"version": "0.1.5",
"main": "./dist/index.umd.js",

@@ -6,0 +6,0 @@ "module": "./dist/index.es.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc