simple-search-dropdown
Advanced tools
Comparing version 0.1.5 to 0.1.7
@@ -1,4 +0,4 @@ | ||
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"; | ||
import { jsxs as ne, jsx as x } from "react/jsx-runtime"; | ||
import * as u from "react"; | ||
import ae, { useState as P, useRef as F, useEffect as j } from "react"; | ||
var k = function() { | ||
@@ -21,3 +21,3 @@ return k = Object.assign || function(t) { | ||
} | ||
function ce(e, t, n) { | ||
function oe(e, t, n) { | ||
if (n || arguments.length === 2) for (var r = 0, a = t.length, o; r < a; r++) | ||
@@ -27,7 +27,7 @@ (o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]); | ||
} | ||
var I = "right-scroll-bar-position", A = "width-before-scroll-bar", le = "with-scroll-bars-hidden", ie = "--removed-body-scroll-bar-size"; | ||
var I = "right-scroll-bar-position", A = "width-before-scroll-bar", ce = "with-scroll-bars-hidden", le = "--removed-body-scroll-bar-size"; | ||
function V(e, t) { | ||
return typeof e == "function" ? e(t) : e && (e.current = t), e; | ||
} | ||
function ue(e, t) { | ||
function ie(e, t) { | ||
var n = P(function() { | ||
@@ -53,5 +53,5 @@ return { | ||
} | ||
var se = typeof window < "u" ? i.useLayoutEffect : i.useEffect, _ = /* @__PURE__ */ new WeakMap(); | ||
function fe(e, t) { | ||
var n = ue(null, function(r) { | ||
var ue = typeof window < "u" ? u.useLayoutEffect : u.useEffect, _ = /* @__PURE__ */ new WeakMap(); | ||
function se(e, t) { | ||
var n = ie(null, function(r) { | ||
return e.forEach(function(a) { | ||
@@ -61,3 +61,3 @@ return V(a, r); | ||
}); | ||
return se(function() { | ||
return ue(function() { | ||
var r = _.get(n); | ||
@@ -75,7 +75,7 @@ if (r) { | ||
} | ||
function de(e) { | ||
function fe(e) { | ||
return e; | ||
} | ||
function ve(e, t) { | ||
t === void 0 && (t = de); | ||
function de(e, t) { | ||
t === void 0 && (t = fe); | ||
var n = [], r = !1, a = { | ||
@@ -119,8 +119,8 @@ read: function() { | ||
f = [], h.forEach(o); | ||
}, y = function() { | ||
}, p = function() { | ||
return Promise.resolve().then(S); | ||
}; | ||
y(), n = { | ||
p(), n = { | ||
push: function(h) { | ||
f.push(h), y(); | ||
f.push(h), p(); | ||
}, | ||
@@ -135,5 +135,5 @@ filter: function(h) { | ||
} | ||
function he(e) { | ||
function ve(e) { | ||
e === void 0 && (e = {}); | ||
var t = ve(null); | ||
var t = de(null); | ||
return t.options = k({ async: !0, ssr: !1 }, e), t; | ||
@@ -148,20 +148,20 @@ } | ||
throw new Error("Sidecar medium not found"); | ||
return i.createElement(r, k({}, n)); | ||
return u.createElement(r, k({}, n)); | ||
}; | ||
$.isSideCarExport = !0; | ||
function me(e, t) { | ||
function he(e, t) { | ||
return e.useMedium(t), $; | ||
} | ||
var q = he(), X = function() { | ||
}, W = i.forwardRef(function(e, t) { | ||
var n = i.useRef(null), r = i.useState({ | ||
var q = ve(), X = function() { | ||
}, W = u.forwardRef(function(e, t) { | ||
var n = u.useRef(null), r = u.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, | ||
}), a = r[0], o = r[1], f = e.forwardProps, c = e.children, S = e.className, p = e.removeScrollBar, h = e.enabled, E = e.shards, R = e.sideCar, C = e.noIsolation, g = e.inert, l = e.allowPinchZoom, i = e.as, v = i === void 0 ? "div" : i, y = e.gapMode, b = U(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), w = R, d = se([n, t]), s = k(k({}, b), a); | ||
return u.createElement( | ||
u.Fragment, | ||
null, | ||
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) | ||
h && u.createElement(w, { sideCar: q, removeScrollBar: p, shards: E, noIsolation: C, inert: g, setCallbacks: o, allowPinchZoom: !!l, lockRef: n, gapMode: y }), | ||
f ? u.cloneElement(u.Children.only(c), k(k({}, s), { ref: d })) : u.createElement(v, k({}, s, { className: S, ref: d }), c) | ||
); | ||
@@ -182,3 +182,3 @@ }); | ||
}; | ||
function ye() { | ||
function me() { | ||
if (!document) | ||
@@ -191,14 +191,14 @@ return null; | ||
} | ||
function be(e, t) { | ||
function pe(e, t) { | ||
e.styleSheet ? e.styleSheet.cssText = t : e.appendChild(document.createTextNode(t)); | ||
} | ||
function pe(e) { | ||
function be(e) { | ||
var t = document.head || document.getElementsByTagName("head")[0]; | ||
t.appendChild(e); | ||
} | ||
var Se = function() { | ||
var ye = function() { | ||
var e = 0, t = null; | ||
return { | ||
add: function(n) { | ||
e == 0 && (t = ye()) && (be(t, n), pe(t)), e++; | ||
e == 0 && (t = me()) && (pe(t, n), be(t)), e++; | ||
}, | ||
@@ -209,6 +209,6 @@ remove: function() { | ||
}; | ||
}, we = function() { | ||
var e = Se(); | ||
}, Se = function() { | ||
var e = ye(); | ||
return function(t, n) { | ||
i.useEffect(function() { | ||
u.useEffect(function() { | ||
return e.add(t), function() { | ||
@@ -220,3 +220,3 @@ e.remove(); | ||
}, J = function() { | ||
var e = we(), t = function(n) { | ||
var e = Se(), t = function(n) { | ||
var r = n.styles, a = n.dynamic; | ||
@@ -226,3 +226,3 @@ return e(r, a), null; | ||
return t; | ||
}, Ce = { | ||
}, we = { | ||
left: 0, | ||
@@ -234,9 +234,9 @@ top: 0, | ||
return parseInt(e || "", 10) || 0; | ||
}, Ee = function(e) { | ||
}, Ce = 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 [Y(n), Y(r), Y(a)]; | ||
}, Re = function(e) { | ||
}, Ee = function(e) { | ||
if (e === void 0 && (e = "margin"), typeof window > "u") | ||
return Ce; | ||
var t = Ee(e), n = document.documentElement.clientWidth, r = window.innerWidth; | ||
return we; | ||
var t = Ce(e), n = document.documentElement.clientWidth, r = window.innerWidth; | ||
return { | ||
@@ -248,10 +248,10 @@ left: t[0], | ||
}; | ||
}, ke = J(), N = "data-scroll-locked", xe = function(e, t, n, r) { | ||
}, Re = J(), M = "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(le, ` { | ||
.`.concat(ce, ` { | ||
overflow: hidden `).concat(r, `; | ||
padding-right: `).concat(c, "px ").concat(r, `; | ||
} | ||
body[`).concat(N, `] { | ||
body[`).concat(M, `] { | ||
overflow: hidden `).concat(r, `; | ||
@@ -289,23 +289,23 @@ overscroll-behavior: contain; | ||
body[`).concat(N, `] { | ||
`).concat(ie, ": ").concat(c, `px; | ||
body[`).concat(M, `] { | ||
`).concat(le, ": ").concat(c, `px; | ||
} | ||
`); | ||
}, z = function() { | ||
var e = parseInt(document.body.getAttribute(N) || "0", 10); | ||
var e = parseInt(document.body.getAttribute(M) || "0", 10); | ||
return isFinite(e) ? e : 0; | ||
}, Le = function() { | ||
i.useEffect(function() { | ||
return document.body.setAttribute(N, (z() + 1).toString()), function() { | ||
}, xe = function() { | ||
u.useEffect(function() { | ||
return document.body.setAttribute(M, (z() + 1).toString()), function() { | ||
var e = z() - 1; | ||
e <= 0 ? document.body.removeAttribute(N) : document.body.setAttribute(N, e.toString()); | ||
e <= 0 ? document.body.removeAttribute(M) : document.body.setAttribute(M, e.toString()); | ||
}; | ||
}, []); | ||
}, Pe = function(e) { | ||
}, Le = function(e) { | ||
var t = e.noRelative, n = e.noImportant, r = e.gapMode, a = r === void 0 ? "margin" : r; | ||
Le(); | ||
var o = i.useMemo(function() { | ||
return Re(a); | ||
xe(); | ||
var o = u.useMemo(function() { | ||
return Ee(a); | ||
}, [a]); | ||
return i.createElement(ke, { styles: xe(o, !t, a, n ? "" : "!important") }); | ||
return u.createElement(Re, { styles: ke(o, !t, a, n ? "" : "!important") }); | ||
}, D = !1; | ||
@@ -323,3 +323,3 @@ if (typeof window < "u") | ||
} | ||
var x = D ? { passive: !1 } : !1, Ne = function(e) { | ||
var L = D ? { passive: !1 } : !1, Ne = function(e) { | ||
return e.tagName === "TEXTAREA"; | ||
@@ -335,5 +335,5 @@ }, K = function(e, t) { | ||
); | ||
}, Pe = function(e) { | ||
return K(e, "overflowY"); | ||
}, Me = function(e) { | ||
return K(e, "overflowY"); | ||
}, Te = function(e) { | ||
return K(e, "overflowX"); | ||
@@ -353,3 +353,3 @@ }, Z = function(e, t) { | ||
return !1; | ||
}, Be = function(e) { | ||
}, Te = function(e) { | ||
var t = e.scrollTop, n = e.scrollHeight, r = e.clientHeight; | ||
@@ -361,3 +361,3 @@ return [ | ||
]; | ||
}, Oe = function(e) { | ||
}, Be = function(e) { | ||
var t = e.scrollLeft, n = e.scrollWidth, r = e.clientWidth; | ||
@@ -370,12 +370,12 @@ return [ | ||
}, ee = function(e, t) { | ||
return e === "v" ? Me(t) : Te(t); | ||
return e === "v" ? Pe(t) : Me(t); | ||
}, te = function(e, t) { | ||
return e === "v" ? Be(t) : Oe(t); | ||
}, Ie = function(e, t) { | ||
return e === "v" ? Te(t) : Be(t); | ||
}, Oe = function(e, t) { | ||
return e === "h" && t === "rtl" ? -1 : 1; | ||
}, 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; | ||
}, Ie = function(e, t, n, r, a) { | ||
var o = Oe(e, window.getComputedStyle(t).direction), f = o * r, c = n.target, S = t.contains(c), p = !1, h = f > 0, E = 0, R = 0; | ||
do { | ||
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; | ||
var C = te(e, c), g = C[0], l = C[1], i = C[2], v = l - i - o * g; | ||
(g || v) && ee(e, c) && (E += v, R += g), c instanceof ShadowRoot ? c = c.host : c = c.parentNode; | ||
} while ( | ||
@@ -386,3 +386,3 @@ // portaled content | ||
); | ||
return (h && (Math.abs(E) < 1 || !a) || !h && (Math.abs(R) < 1 || !a)) && (y = !0), y; | ||
return (h && (Math.abs(E) < 1 || !a) || !h && (Math.abs(R) < 1 || !a)) && (p = !0), p; | ||
}, O = function(e) { | ||
@@ -394,5 +394,5 @@ return "changedTouches" in e ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [0, 0]; | ||
return e && "current" in e ? e.current : e; | ||
}, We = function(e, t) { | ||
}, Ae = function(e, t) { | ||
return e[0] === t[0] && e[1] === t[1]; | ||
}, je = function(e) { | ||
}, We = function(e) { | ||
return ` | ||
@@ -402,16 +402,16 @@ .block-interactivity-`.concat(e, ` {pointer-events: none;} | ||
`); | ||
}, 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() { | ||
}, je = 0, N = []; | ||
function Ve(e) { | ||
var t = u.useRef([]), n = u.useRef([0, 0]), r = u.useRef(), a = u.useState(je++)[0], o = u.useState(J)[0], f = u.useRef(e); | ||
u.useEffect(function() { | ||
f.current = e; | ||
}, [e]), i.useEffect(function() { | ||
}, [e]), u.useEffect(function() { | ||
if (e.inert) { | ||
document.body.classList.add("block-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)); | ||
var l = oe([e.lockRef.current], (e.shards || []).map(G), !0).filter(Boolean); | ||
return l.forEach(function(i) { | ||
return i.classList.add("allow-interactivity-".concat(a)); | ||
}), function() { | ||
document.body.classList.remove("block-interactivity-".concat(a)), l.forEach(function(u) { | ||
return u.classList.remove("allow-interactivity-".concat(a)); | ||
document.body.classList.remove("block-interactivity-".concat(a)), l.forEach(function(i) { | ||
return i.classList.remove("allow-interactivity-".concat(a)); | ||
}); | ||
@@ -421,36 +421,36 @@ }; | ||
}, [e.inert, e.lockRef.current, e.shards]); | ||
var c = i.useCallback(function(l, u) { | ||
var c = u.useCallback(function(l, i) { | ||
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") | ||
var v = O(l), y = n.current, b = "deltaX" in l ? l.deltaX : y[0] - v[0], w = "deltaY" in l ? l.deltaY : y[1] - v[1], d, s = l.target, m = Math.abs(b) > Math.abs(w) ? "h" : "v"; | ||
if ("touches" in l && m === "h" && s.type === "range") | ||
return !1; | ||
var T = Z(g, s); | ||
var T = Z(m, s); | ||
if (!T) | ||
return !0; | ||
if (T ? d = g : (d = g === "v" ? "h" : "v", T = Z(g, s)), !T) | ||
if (T ? d = m : (d = m === "v" ? "h" : "v", T = Z(m, s)), !T) | ||
return !1; | ||
if (!r.current && "changedTouches" in l && (b || w) && (r.current = d), !d) | ||
return !0; | ||
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); | ||
var H = r.current || d; | ||
return Ie(H, i, l, H === "h" ? b : w, !0); | ||
}, []), S = u.useCallback(function(l) { | ||
var i = l; | ||
if (!(!N.length || N[N.length - 1] !== o)) { | ||
var v = "deltaY" in i ? Q(i) : O(i), y = t.current.filter(function(d) { | ||
return d.name === i.type && (d.target === i.target || i.target === d.shadowParent) && Ae(d.delta, v); | ||
})[0]; | ||
if (p && p.should) { | ||
u.cancelable && u.preventDefault(); | ||
if (y && y.should) { | ||
i.cancelable && i.preventDefault(); | ||
return; | ||
} | ||
if (!p) { | ||
if (!y) { | ||
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(); | ||
return d.contains(i.target); | ||
}), w = b.length > 0 ? c(i, b[0]) : !f.current.noIsolation; | ||
w && i.cancelable && i.preventDefault(); | ||
} | ||
} | ||
}, []), y = i.useCallback(function(l, u, v, p) { | ||
var b = { name: l, delta: u, target: v, should: p, shadowParent: Ye(v) }; | ||
}, []), p = u.useCallback(function(l, i, v, y) { | ||
var b = { name: l, delta: i, target: v, should: y, shadowParent: Xe(v) }; | ||
t.current.push(b), setTimeout(function() { | ||
@@ -461,29 +461,29 @@ t.current = t.current.filter(function(w) { | ||
}, 1); | ||
}, []), h = i.useCallback(function(l) { | ||
}, []), h = u.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)); | ||
}, []), E = u.useCallback(function(l) { | ||
p(l.type, Q(l), l.target, c(l, e.lockRef.current)); | ||
}, []), R = u.useCallback(function(l) { | ||
p(l.type, O(l), l.target, c(l, e.lockRef.current)); | ||
}, []); | ||
i.useEffect(function() { | ||
return L.push(o), e.setCallbacks({ | ||
u.useEffect(function() { | ||
return N.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) { | ||
}), document.addEventListener("wheel", S, L), document.addEventListener("touchmove", S, L), document.addEventListener("touchstart", h, L), function() { | ||
N = N.filter(function(l) { | ||
return l !== o; | ||
}), document.removeEventListener("wheel", S, x), document.removeEventListener("touchmove", S, x), document.removeEventListener("touchstart", h, x); | ||
}), document.removeEventListener("wheel", S, L), document.removeEventListener("touchmove", S, L), document.removeEventListener("touchstart", h, L); | ||
}; | ||
}, []); | ||
var C = e.removeScrollBar, m = e.inert; | ||
return i.createElement( | ||
i.Fragment, | ||
var C = e.removeScrollBar, g = e.inert; | ||
return u.createElement( | ||
u.Fragment, | ||
null, | ||
m ? i.createElement(o, { styles: je(a) }) : null, | ||
C ? i.createElement(Pe, { gapMode: e.gapMode }) : null | ||
g ? u.createElement(o, { styles: We(a) }) : null, | ||
C ? u.createElement(Le, { gapMode: e.gapMode }) : null | ||
); | ||
} | ||
function Ye(e) { | ||
function Xe(e) { | ||
for (var t = null; e !== null; ) | ||
@@ -493,86 +493,89 @@ e instanceof ShadowRoot && (t = e.host, e = e.host), e = e.parentNode; | ||
} | ||
const De = me(q, Xe); | ||
var re = i.forwardRef(function(e, t) { | ||
return i.createElement(W, k({}, e, { ref: t, sideCar: De })); | ||
const Ye = he(q, Ve); | ||
var re = u.forwardRef(function(e, t) { | ||
return u.createElement(W, k({}, e, { ref: t, sideCar: Ye })); | ||
}); | ||
re.classNames = W.classNames; | ||
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 (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); | ||
}); | ||
const De = () => /* @__PURE__ */ x("p", { className: "p-2", children: "Carregando..." }), He = ae.forwardRef( | ||
({ data: e, placeholder: t, className: n, itemClassName: r, disabled: a, onChange: o, ...f }, c) => { | ||
const [S, p] = P(!1), [h, E] = P(!1), [R, C] = P({ label: "", value: "" }), [g, l] = P(""), [i, v] = P(), y = F(null), b = F(null), w = (s) => { | ||
o && o({ | ||
target: { | ||
name: f.name, | ||
value: (s == null ? void 0 : s.value) ?? "" | ||
} | ||
}); | ||
}; | ||
j(() => { | ||
if (h) { | ||
E(!1); | ||
return; | ||
} | ||
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 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: p, | ||
onFocus: () => y(!0), | ||
className: n, | ||
type: "text", | ||
value: R.label, | ||
onChange: (s) => { | ||
C({ label: s.target.value ?? "", value: R.value }), l(s.target.value.toLowerCase()), E(!0); | ||
}, | ||
disabled: a, | ||
placeholder: t | ||
} | ||
), | ||
/* @__PURE__ */ M( | ||
"input", | ||
{ | ||
ref: c, | ||
className: "hidden", | ||
type: "text", | ||
value: R.value, | ||
onChange: o, | ||
...f | ||
} | ||
), | ||
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"; | ||
if (i != null && i.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) && b.current && !b.current.contains(m) && p(!1); | ||
}; | ||
return j(() => (document.addEventListener("mousedown", d), () => { | ||
document.removeEventListener("mousedown", d); | ||
}), []), j(() => { | ||
if (g !== "" && i && i.length > 0) { | ||
const s = i.find((m) => m.label.toLowerCase() === g); | ||
console.log( | ||
s, | ||
g, | ||
i.map((m) => m.label.toLowerCase()) | ||
), s && (C(s), w(s)); | ||
} else g === "" && w(); | ||
}, [g]), /* @__PURE__ */ ne("div", { className: "relative flex flex-col", children: [ | ||
/* @__PURE__ */ x( | ||
"input", | ||
{ | ||
ref: y, | ||
onFocus: () => p(!0), | ||
className: n ?? "border-[1px] p-4 w-full cursor-pointer focus:cursor-text placeholder:gray-400 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition duration-300 ease-in-out", | ||
type: "text", | ||
value: R.label, | ||
onChange: (s) => { | ||
C({ label: s.target.value ?? "", value: R.value }), l(s.target.value.toLowerCase()), E(!0); | ||
}, | ||
disabled: a, | ||
placeholder: t | ||
} | ||
), | ||
/* @__PURE__ */ x("input", { ref: c, className: "hidden", type: "text", value: R.value, onChange: o, ...f }), | ||
S && /* @__PURE__ */ x(re, { children: /* @__PURE__ */ x( | ||
"div", | ||
{ | ||
ref: b, | ||
className: "flex flex-col absolute bg-white mt-2 rounded-lg shadow-lg p-2 w-full max-h-[260%] overflow-y-scroll scrollbar-none", | ||
children: i != null && i.length ? i.filter((s) => s.label.toLowerCase().indexOf(g ?? "") > -1).map((s, m) => /* @__PURE__ */ x( | ||
"div", | ||
{ | ||
className: r ?? "p-2 cursor-pointer hover:bg-gray-200 transition duration-300 ease-in-out", | ||
onClick: () => { | ||
C(s), p(!1), w(s); | ||
}, | ||
children: s.label | ||
}, | ||
m | ||
)) : /* @__PURE__ */ x(De, {}) | ||
} | ||
) }) | ||
] }); | ||
} | ||
); | ||
He.displayName = "SearchSelect"; | ||
export { | ||
Fe as SearchSelect | ||
He as SearchSelect | ||
}; |
@@ -1,2 +0,2 @@ | ||
(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"),` | ||
(function(N,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):(N=typeof globalThis<"u"?globalThis:N||self,E(N["simple-search-dropdown"]={},N["react/jsx-runtime"],N.React))})(this,function(N,E,y){"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 i=ne(y);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 H(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",j="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 le(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"?i.useLayoutEffect:i.useEffect,_=new WeakMap;function ue(e,t){var n=le(null,function(r){return e.forEach(function(a){return D(a,r)})});return ie(function(){var r=_.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)})}_.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 z=function(e){var t=e.sideCar,n=H(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 i.createElement(r,x({},n))};z.isSideCarExport=!0;function ve(e,t){return e.useMedium(t),z}var F=de(),V=function(){},B=i.forwardRef(function(e,t){var n=i.useRef(null),r=i.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,l=e.allowPinchZoom,u=e.as,v=u===void 0?"div":u,b=e.gapMode,S=H(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 i.createElement(i.Fragment,null,h&&i.createElement(C,{sideCar:F,removeScrollBar:p,shards:P,noIsolation:k,inert:g,setCallbacks:o,allowPinchZoom:!!l,lockRef:n,gapMode:b}),f?i.cloneElement(i.Children.only(c),x(x({},s),{ref:d})):i.createElement(v,x({},s,{className:w,ref:d}),c))});B.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},B.classNames={fullWidth:j,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)}}},be=function(){var e=Se();return function(t,n){i.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},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 ye;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(),T="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,` { | ||
@@ -6,3 +6,3 @@ overflow: hidden `).concat(r,`; | ||
} | ||
body[`).concat(N,`] { | ||
body[`).concat(T,`] { | ||
overflow: hidden `).concat(r,`; | ||
@@ -24,3 +24,3 @@ overscroll-behavior: contain; | ||
.`).concat(B,` { | ||
.`).concat(j,` { | ||
margin-right: `).concat(c,"px ").concat(r,`; | ||
@@ -33,12 +33,12 @@ } | ||
.`).concat(B," .").concat(B,` { | ||
.`).concat(j," .").concat(j,` { | ||
margin-right: 0 `).concat(r,`; | ||
} | ||
body[`).concat(N,`] { | ||
body[`).concat(T,`] { | ||
`).concat(ce,": ").concat(c,`px; | ||
} | ||
`)},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` | ||
`)},Q=function(){var e=parseInt(document.body.getAttribute(T)||"0",10);return isFinite(e)?e:0},xe=function(){i.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;xe();var o=i.useMemo(function(){return Ce(a)},[a]);return i.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")},Ne=function(e){return q(e,"overflowY")},Te=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"?Ne(t):Te(t)},$=function(e,t){return e==="v"?Oe(t):Me(t)},Re=function(e,t){return e==="h"&&t==="rtl"?-1:1},je=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],l=k[1],u=k[2],v=l-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},Be=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;} | ||
`)},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"})}); | ||
`)},Ae=0,M=[];function We(e){var t=i.useRef([]),n=i.useRef([0,0]),r=i.useRef(),a=i.useState(Ae++)[0],o=i.useState(Z)[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 l=ae([e.lockRef.current],(e.shards||[]).map(K),!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)),l.forEach(function(u){return u.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var c=i.useCallback(function(l,u){if("touches"in l&&l.touches.length===2)return!f.current.allowPinchZoom;var v=A(l),b=n.current,S="deltaX"in l?l.deltaX:b[0]-v[0],C="deltaY"in l?l.deltaY:b[1]-v[1],d,s=l.target,m=Math.abs(S)>Math.abs(C)?"h":"v";if("touches"in l&&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 l&&(S||C)&&(r.current=d),!d)return!0;var re=r.current||d;return je(re,u,l,re==="h"?S:C,!0)},[]),w=i.useCallback(function(l){var u=l;if(!(!M.length||M[M.length-1]!==o)){var v="deltaY"in u?J(u):A(u),b=t.current.filter(function(d){return d.name===u.type&&(d.target===u.target||u.target===d.shadowParent)&&Be(d.delta,v)})[0];if(b&&b.should){u.cancelable&&u.preventDefault();return}if(!b){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=i.useCallback(function(l,u,v,b){var S={name:l,delta:u,target:v,should:b,shadowParent:De(v)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(C){return C!==S})},1)},[]),h=i.useCallback(function(l){n.current=A(l),r.current=void 0},[]),P=i.useCallback(function(l){p(l.type,J(l),l.target,c(l,e.lockRef.current))},[]),L=i.useCallback(function(l){p(l.type,A(l),l.target,c(l,e.lockRef.current))},[]);i.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(l){return l!==o}),document.removeEventListener("wheel",w,O),document.removeEventListener("touchmove",w,O),document.removeEventListener("touchstart",h,O)}},[]);var k=e.removeScrollBar,g=e.inert;return i.createElement(i.Fragment,null,g?i.createElement(o,{styles:Ie(a)}):null,k?i.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(F,We);var ee=i.forwardRef(function(e,t){return i.createElement(B,x({},e,{ref:t,sideCar:Ve}))});ee.classNames=B.classNames;const Xe=()=>E.jsx("p",{className:"p-2",children:"Carregando..."}),te=y.forwardRef(({data:e,placeholder:t,className:n,itemClassName:r,disabled:a,onChange:o,...f},c)=>{const[w,p]=y.useState(!1),[h,P]=y.useState(!1),[L,k]=y.useState({label:"",value:""}),[g,l]=y.useState(""),[u,v]=y.useState(),b=y.useRef(null),S=y.useRef(null),C=s=>{o&&o({target:{name:f.name,value:(s==null?void 0:s.value)??""}})};y.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;b.current&&!b.current.contains(m)&&S.current&&!S.current.contains(m)&&p(!1)};return y.useEffect(()=>(document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}),[]),y.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("div",{className:"relative flex flex-col",children:[E.jsx("input",{ref:b,onFocus:()=>p(!0),className:n??"border-[1px] p-4 w-full cursor-pointer focus:cursor-text placeholder:gray-400 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition duration-300 ease-in-out",type:"text",value:L.label,onChange:s=>{k({label:s.target.value??"",value:L.value}),l(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&&E.jsx(ee,{children:E.jsx("div",{ref:S,className:"flex flex-col absolute bg-white mt-2 rounded-lg shadow-lg p-2 w-full max-h-[260%] overflow-y-scroll scrollbar-none",children:u!=null&&u.length?u.filter(s=>s.label.toLowerCase().indexOf(g??"")>-1).map((s,m)=>E.jsx("div",{className:r??"p-2 cursor-pointer hover:bg-gray-200 transition duration-300 ease-in-out",onClick:()=>{k(s),p(!1),C(s)},children:s.label},m)):E.jsx(Xe,{})})})]})});te.displayName="SearchSelect",N.SearchSelect=te,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}); |
{ | ||
"name": "simple-search-dropdown", | ||
"private": false, | ||
"version": "0.1.5", | ||
"version": "0.1.7", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:KingTimer12/simple-search-dropdown.git" | ||
}, | ||
"engines": { | ||
"node": "20" | ||
}, | ||
"main": "./dist/index.umd.js", | ||
@@ -30,2 +37,3 @@ "module": "./dist/index.es.js", | ||
"@eslint/js": "^9.8.0", | ||
"@testing-library/react": "^16.0.0", | ||
"@types/node": "^22.3.0", | ||
@@ -40,3 +48,8 @@ "@types/react": "^18.3.3", | ||
"globals": "^15.9.0", | ||
"husky": "^9.1.5", | ||
"jsdom": "^24.1.1", | ||
"json": "^11.0.0", | ||
"lint-staged": "^15.2.9", | ||
"postcss": "^8.4.41", | ||
"prettier": "^3.3.3", | ||
"react-hook-form": "^7.52.2", | ||
@@ -50,8 +63,15 @@ "tailwindcss": "^3.4.10", | ||
}, | ||
"lint-staged": { | ||
"*.{ts,tsx,js,jsx,json,css,md}": [ | ||
"prettier -w" | ||
] | ||
}, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", | ||
"preview": "vite preview" | ||
"lint": "eslint lib/**", | ||
"preview": "vite preview", | ||
"test": "vitest", | ||
"test:unit": "vitest --watch false" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
42340
9
0
673
0
24