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.7 to 0.1.8

dist/components/SearchSelectPrimitive.d.ts

9

dist/components/SearchSelect.d.ts
import { default as React } from 'react';
export interface SelectItem {
label: string;
value: string;
}
import { SelectItem } from './SearchSelectPrimitive';
export interface SelectProps extends React.InputHTMLAttributes<HTMLInputElement> {
data: SelectItem[] | ((search?: string) => SelectItem[]);
data: SelectItem[] | ((search?: string) => Promise<SelectItem[]>);
itemClassName?: string;
}
declare const SearchSelect: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLInputElement>>;
declare const SearchSelect: React.MemoExoticComponent<React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLInputElement>>>;
export default SearchSelect;
import { default as SearchSelect } from './components/SearchSelect';
export { SearchSelect };
import { default as Select, SelectItem } from './components/SearchSelectPrimitive';
declare const useDataSearch: (data: SelectItem[] | ((search?: string) => Promise<SelectItem[]>), delay?: number) => SelectItem[];
export { SearchSelect, Select, useDataSearch };

@@ -1,32 +0,32 @@

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() {
return k = Object.assign || function(t) {
for (var n, r = 1, a = arguments.length; r < a; r++) {
import { jsx as T, jsxs as ge } from "react/jsx-runtime";
import * as p from "react";
import C, { useState as G, useRef as oe, useEffect as Ae } from "react";
var D = function() {
return D = Object.assign || function(t) {
for (var n, r = 1, o = arguments.length; r < o; r++) {
n = arguments[r];
for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (t[a] = n[a]);
}
return t;
}, k.apply(this, arguments);
}, D.apply(this, arguments);
};
function U(e, t) {
function ye(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]]);
for (var o = 0, r = Object.getOwnPropertySymbols(e); o < r.length; o++)
t.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[o]) && (n[r[o]] = e[r[o]]);
return n;
}
function oe(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));
function Ie(e, t, n) {
if (n || arguments.length === 2) for (var r = 0, o = t.length, a; r < o; r++)
(a || !(r in t)) && (a || (a = Array.prototype.slice.call(t, 0, r)), a[r] = t[r]);
return e.concat(a || Array.prototype.slice.call(t));
}
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) {
var j = "right-scroll-bar-position", H = "width-before-scroll-bar", Ve = "with-scroll-bars-hidden", ke = "--removed-body-scroll-bar-size";
function X(e, t) {
return typeof e == "function" ? e(t) : e && (e.current = t), e;
}
function ie(e, t) {
var n = P(function() {
function Be(e, t) {
var n = G(function() {
return {

@@ -43,4 +43,4 @@ // value

set current(r) {
var a = n.value;
a !== r && (n.value = r, n.callback(r, a));
var o = n.value;
o !== r && (n.value = r, n.callback(r, o));
}

@@ -52,28 +52,28 @@ }

}
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) {
return V(a, r);
var Me = typeof window < "u" ? p.useLayoutEffect : p.useEffect, ae = /* @__PURE__ */ new WeakMap();
function Pe(e, t) {
var n = Be(null, function(r) {
return e.forEach(function(o) {
return X(o, r);
});
});
return ue(function() {
var r = _.get(n);
return Me(function() {
var r = ae.get(n);
if (r) {
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);
var o = new Set(r), a = new Set(e), s = n.current;
o.forEach(function(u) {
a.has(u) || X(u, null);
}), a.forEach(function(u) {
o.has(u) || X(u, s);
});
}
_.set(n, e);
ae.set(n, e);
}, [e]), n;
}
function fe(e) {
function Ne(e) {
return e;
}
function de(e, t) {
t === void 0 && (t = fe);
var n = [], r = !1, a = {
function We(e, t) {
t === void 0 && (t = Ne);
var n = [], r = !1, o = {
read: function() {

@@ -84,18 +84,18 @@ if (r)

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

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

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

@@ -131,11 +131,11 @@ };

};
return a;
return o;
}
function ve(e) {
function je(e) {
e === void 0 && (e = {});
var t = de(null);
return t.options = k({ async: !0, ssr: !1 }, e), t;
var t = We(null);
return t.options = D({ async: !0, ssr: !1 }, e), t;
}
var $ = function(e) {
var t = e.sideCar, n = U(e, ["sideCar"]);
var Ee = function(e) {
var t = e.sideCar, n = ye(e, ["sideCar"]);
if (!t)

@@ -146,23 +146,23 @@ throw new Error("Sidecar: please provide `sideCar` property to import the right car");

throw new Error("Sidecar medium not found");
return u.createElement(r, k({}, n));
return p.createElement(r, D({}, n));
};
$.isSideCarExport = !0;
function he(e, t) {
return e.useMedium(t), $;
Ee.isSideCarExport = !0;
function He(e, t) {
return e.useMedium(t), Ee;
}
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, 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,
var _e = je(), Z = function() {
}, U = p.forwardRef(function(e, t) {
var n = p.useRef(null), r = p.useState({
onScrollCapture: Z,
onWheelCapture: Z,
onTouchMoveCapture: Z
}), o = r[0], a = r[1], s = e.forwardProps, u = e.children, h = e.className, S = e.removeScrollBar, c = e.enabled, l = e.shards, f = e.sideCar, g = e.noIsolation, E = e.inert, i = e.allowPinchZoom, d = e.as, w = d === void 0 ? "div" : d, O = e.gapMode, m = ye(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), v = f, _ = Pe([n, t]), y = D(D({}, m), o);
return p.createElement(
p.Fragment,
null,
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)
c && p.createElement(v, { sideCar: _e, removeScrollBar: S, shards: l, noIsolation: g, inert: E, setCallbacks: a, allowPinchZoom: !!i, lockRef: n, gapMode: O }),
s ? p.cloneElement(p.Children.only(u), D(D({}, y), { ref: _ })) : p.createElement(w, D({}, y, { className: h, ref: _ }), u)
);
});
W.defaultProps = {
U.defaultProps = {
enabled: !0,

@@ -172,11 +172,11 @@ removeScrollBar: !0,

};
W.classNames = {
fullWidth: A,
zeroRight: I
U.classNames = {
fullWidth: H,
zeroRight: j
};
var ge = function() {
var Ge = function() {
if (typeof __webpack_nonce__ < "u")
return __webpack_nonce__;
};
function me() {
function Ue() {
if (!document)

@@ -186,17 +186,17 @@ return null;

e.type = "text/css";
var t = ge();
var t = Ge();
return t && e.setAttribute("nonce", t), e;
}
function pe(e, t) {
function Fe(e, t) {
e.styleSheet ? e.styleSheet.cssText = t : e.appendChild(document.createTextNode(t));
}
function be(e) {
function Ke(e) {
var t = document.head || document.getElementsByTagName("head")[0];
t.appendChild(e);
}
var ye = function() {
var Ye = function() {
var e = 0, t = null;
return {
add: function(n) {
e == 0 && (t = me()) && (pe(t, n), be(t)), e++;
e == 0 && (t = Ue()) && (Fe(t, n), Ke(t)), e++;
},

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

};
}, Se = function() {
var e = ye();
}, ze = function() {
var e = Ye();
return function(t, n) {
u.useEffect(function() {
p.useEffect(function() {
return e.add(t), function() {

@@ -217,9 +217,9 @@ e.remove();

};
}, J = function() {
var e = Se(), t = function(n) {
var r = n.styles, a = n.dynamic;
return e(r, a), null;
}, we = function() {
var e = ze(), t = function(n) {
var r = n.styles, o = n.dynamic;
return e(r, o), null;
};
return t;
}, we = {
}, qe = {
left: 0,

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

gap: 0
}, Y = function(e) {
}, $ = function(e) {
return parseInt(e || "", 10) || 0;
}, 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)];
}, Ee = function(e) {
}, Xe = function(e) {
var t = window.getComputedStyle(document.body), n = t[e === "padding" ? "paddingLeft" : "marginLeft"], r = t[e === "padding" ? "paddingTop" : "marginTop"], o = t[e === "padding" ? "paddingRight" : "marginRight"];
return [$(n), $(r), $(o)];
}, Ze = 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 qe;
var t = Xe(e), n = document.documentElement.clientWidth, r = window.innerWidth;
return {

@@ -245,10 +245,10 @@ left: t[0],

};
}, 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;
}, $e = we(), V = "data-scroll-locked", Qe = function(e, t, n, r) {
var o = e.left, a = e.top, s = e.right, u = e.gap;
return n === void 0 && (n = "margin"), `
.`.concat(ce, ` {
.`.concat(Ve, ` {
overflow: hidden `).concat(r, `;
padding-right: `).concat(c, "px ").concat(r, `;
padding-right: `).concat(u, "px ").concat(r, `;
}
body[`).concat(M, `] {
body[`).concat(V, `] {
overflow: hidden `).concat(r, `;

@@ -259,65 +259,65 @@ overscroll-behavior: contain;

n === "margin" && `
padding-left: `.concat(a, `px;
padding-top: `).concat(o, `px;
padding-right: `).concat(f, `px;
padding-left: `.concat(o, `px;
padding-top: `).concat(a, `px;
padding-right: `).concat(s, `px;
margin-left:0;
margin-top:0;
margin-right: `).concat(c, "px ").concat(r, `;
margin-right: `).concat(u, "px ").concat(r, `;
`),
n === "padding" && "padding-right: ".concat(c, "px ").concat(r, ";")
n === "padding" && "padding-right: ".concat(u, "px ").concat(r, ";")
].filter(Boolean).join(""), `
}
.`).concat(I, ` {
right: `).concat(c, "px ").concat(r, `;
.`).concat(j, ` {
right: `).concat(u, "px ").concat(r, `;
}
.`).concat(A, ` {
margin-right: `).concat(c, "px ").concat(r, `;
.`).concat(H, ` {
margin-right: `).concat(u, "px ").concat(r, `;
}
.`).concat(I, " .").concat(I, ` {
.`).concat(j, " .").concat(j, ` {
right: 0 `).concat(r, `;
}
.`).concat(A, " .").concat(A, ` {
.`).concat(H, " .").concat(H, ` {
margin-right: 0 `).concat(r, `;
}
body[`).concat(M, `] {
`).concat(le, ": ").concat(c, `px;
body[`).concat(V, `] {
`).concat(ke, ": ").concat(u, `px;
}
`);
}, z = function() {
var e = parseInt(document.body.getAttribute(M) || "0", 10);
}, ie = function() {
var e = parseInt(document.body.getAttribute(V) || "0", 10);
return isFinite(e) ? e : 0;
}, xe = function() {
u.useEffect(function() {
return document.body.setAttribute(M, (z() + 1).toString()), function() {
var e = z() - 1;
e <= 0 ? document.body.removeAttribute(M) : document.body.setAttribute(M, e.toString());
}, Je = function() {
p.useEffect(function() {
return document.body.setAttribute(V, (ie() + 1).toString()), function() {
var e = ie() - 1;
e <= 0 ? document.body.removeAttribute(V) : document.body.setAttribute(V, e.toString());
};
}, []);
}, Le = function(e) {
var t = e.noRelative, n = e.noImportant, r = e.gapMode, a = r === void 0 ? "margin" : r;
xe();
var o = u.useMemo(function() {
return Ee(a);
}, [a]);
return u.createElement(Re, { styles: ke(o, !t, a, n ? "" : "!important") });
}, D = !1;
}, et = function(e) {
var t = e.noRelative, n = e.noImportant, r = e.gapMode, o = r === void 0 ? "margin" : r;
Je();
var a = p.useMemo(function() {
return Ze(o);
}, [o]);
return p.createElement($e, { styles: Qe(a, !t, o, n ? "" : "!important") });
}, ne = !1;
if (typeof window < "u")
try {
var B = Object.defineProperty({}, "passive", {
var P = Object.defineProperty({}, "passive", {
get: function() {
return D = !0, !0;
return ne = !0, !0;
}
});
window.addEventListener("test", B, B), window.removeEventListener("test", B, B);
window.addEventListener("test", P, P), window.removeEventListener("test", P, P);
} catch {
D = !1;
ne = !1;
}
var L = D ? { passive: !1 } : !1, Ne = function(e) {
var A = ne ? { passive: !1 } : !1, tt = function(e) {
return e.tagName === "TEXTAREA";
}, K = function(e, t) {
}, be = function(e, t) {
if (!(e instanceof Element))

@@ -329,16 +329,16 @@ return !1;

n[t] !== "hidden" && // contains scroll inside self
!(n.overflowY === n.overflowX && !Ne(e) && n[t] === "visible")
!(n.overflowY === n.overflowX && !tt(e) && n[t] === "visible")
);
}, Pe = function(e) {
return K(e, "overflowY");
}, Me = function(e) {
return K(e, "overflowX");
}, Z = function(e, t) {
}, nt = function(e) {
return be(e, "overflowY");
}, rt = function(e) {
return be(e, "overflowX");
}, ue = function(e, t) {
var n = t.ownerDocument, r = t;
do {
typeof ShadowRoot < "u" && r instanceof ShadowRoot && (r = r.host);
var a = ee(e, r);
if (a) {
var o = te(e, r), f = o[1], c = o[2];
if (f > c)
var o = Oe(e, r);
if (o) {
var a = Ce(e, r), s = a[1], u = a[2];
if (s > u)
return !0;

@@ -349,3 +349,3 @@ }

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

@@ -357,3 +357,3 @@ return [

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

@@ -365,28 +365,28 @@ return [

];
}, ee = function(e, t) {
return e === "v" ? Pe(t) : Me(t);
}, te = function(e, t) {
return e === "v" ? Te(t) : Be(t);
}, Oe = function(e, t) {
return e === "v" ? nt(t) : rt(t);
}, Ce = function(e, t) {
return e === "v" ? ot(t) : at(t);
}, it = function(e, t) {
return e === "h" && t === "rtl" ? -1 : 1;
}, 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;
}, ut = function(e, t, n, r, o) {
var a = it(e, window.getComputedStyle(t).direction), s = a * r, u = n.target, h = t.contains(u), S = !1, c = s > 0, l = 0, f = 0;
do {
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;
var g = Ce(e, u), E = g[0], i = g[1], d = g[2], w = i - d - a * E;
(E || w) && Oe(e, u) && (l += w, f += E), u instanceof ShadowRoot ? u = u.host : u = u.parentNode;
} while (
// portaled content
!S && c !== document.body || // self content
S && (t.contains(c) || t === c)
!h && u !== document.body || // self content
h && (t.contains(u) || t === u)
);
return (h && (Math.abs(E) < 1 || !a) || !h && (Math.abs(R) < 1 || !a)) && (p = !0), p;
}, O = function(e) {
return (c && (Math.abs(l) < 1 || !o) || !c && (Math.abs(f) < 1 || !o)) && (S = !0), S;
}, N = function(e) {
return "changedTouches" in e ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [0, 0];
}, Q = function(e) {
}, ce = function(e) {
return [e.deltaX, e.deltaY];
}, G = function(e) {
}, le = function(e) {
return e && "current" in e ? e.current : e;
}, Ae = function(e, t) {
}, ct = function(e, t) {
return e[0] === t[0] && e[1] === t[1];
}, We = function(e) {
}, lt = function(e) {
return `

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

`);
}, 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]), u.useEffect(function() {
}, st = 0, I = [];
function ft(e) {
var t = p.useRef([]), n = p.useRef([0, 0]), r = p.useRef(), o = p.useState(st++)[0], a = p.useState(we)[0], s = p.useRef(e);
p.useEffect(function() {
s.current = e;
}, [e]), p.useEffect(function() {
if (e.inert) {
document.body.classList.add("block-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));
document.body.classList.add("block-interactivity-".concat(o));
var i = Ie([e.lockRef.current], (e.shards || []).map(le), !0).filter(Boolean);
return i.forEach(function(d) {
return d.classList.add("allow-interactivity-".concat(o));
}), function() {
document.body.classList.remove("block-interactivity-".concat(a)), l.forEach(function(i) {
return i.classList.remove("allow-interactivity-".concat(a));
document.body.classList.remove("block-interactivity-".concat(o)), i.forEach(function(d) {
return d.classList.remove("allow-interactivity-".concat(o));
});

@@ -415,68 +415,68 @@ };

}, [e.inert, e.lockRef.current, e.shards]);
var c = u.useCallback(function(l, i) {
if ("touches" in l && l.touches.length === 2)
return !f.current.allowPinchZoom;
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")
var u = p.useCallback(function(i, d) {
if ("touches" in i && i.touches.length === 2)
return !s.current.allowPinchZoom;
var w = N(i), O = n.current, m = "deltaX" in i ? i.deltaX : O[0] - w[0], v = "deltaY" in i ? i.deltaY : O[1] - w[1], _, y = i.target, b = Math.abs(m) > Math.abs(v) ? "h" : "v";
if ("touches" in i && b === "h" && y.type === "range")
return !1;
var T = Z(m, s);
if (!T)
var R = ue(b, y);
if (!R)
return !0;
if (T ? d = m : (d = m === "v" ? "h" : "v", T = Z(m, s)), !T)
if (R ? _ = b : (_ = b === "v" ? "h" : "v", R = ue(b, y)), !R)
return !1;
if (!r.current && "changedTouches" in l && (b || w) && (r.current = d), !d)
if (!r.current && "changedTouches" in i && (m || v) && (r.current = _), !_)
return !0;
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);
var L = r.current || _;
return ut(L, d, i, L === "h" ? m : v, !0);
}, []), h = p.useCallback(function(i) {
var d = i;
if (!(!I.length || I[I.length - 1] !== a)) {
var w = "deltaY" in d ? ce(d) : N(d), O = t.current.filter(function(_) {
return _.name === d.type && (_.target === d.target || d.target === _.shadowParent) && ct(_.delta, w);
})[0];
if (y && y.should) {
i.cancelable && i.preventDefault();
if (O && O.should) {
d.cancelable && d.preventDefault();
return;
}
if (!y) {
var b = (f.current.shards || []).map(G).filter(Boolean).filter(function(d) {
return d.contains(i.target);
}), w = b.length > 0 ? c(i, b[0]) : !f.current.noIsolation;
w && i.cancelable && i.preventDefault();
if (!O) {
var m = (s.current.shards || []).map(le).filter(Boolean).filter(function(_) {
return _.contains(d.target);
}), v = m.length > 0 ? u(d, m[0]) : !s.current.noIsolation;
v && d.cancelable && d.preventDefault();
}
}
}, []), 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() {
t.current = t.current.filter(function(w) {
return w !== b;
}, []), S = p.useCallback(function(i, d, w, O) {
var m = { name: i, delta: d, target: w, should: O, shadowParent: dt(w) };
t.current.push(m), setTimeout(function() {
t.current = t.current.filter(function(v) {
return v !== m;
});
}, 1);
}, []), h = u.useCallback(function(l) {
n.current = O(l), r.current = void 0;
}, []), 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));
}, []), c = p.useCallback(function(i) {
n.current = N(i), r.current = void 0;
}, []), l = p.useCallback(function(i) {
S(i.type, ce(i), i.target, u(i, e.lockRef.current));
}, []), f = p.useCallback(function(i) {
S(i.type, N(i), i.target, u(i, e.lockRef.current));
}, []);
u.useEffect(function() {
return N.push(o), e.setCallbacks({
onScrollCapture: E,
onWheelCapture: E,
onTouchMoveCapture: R
}), 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, L), document.removeEventListener("touchmove", S, L), document.removeEventListener("touchstart", h, L);
p.useEffect(function() {
return I.push(a), e.setCallbacks({
onScrollCapture: l,
onWheelCapture: l,
onTouchMoveCapture: f
}), document.addEventListener("wheel", h, A), document.addEventListener("touchmove", h, A), document.addEventListener("touchstart", c, A), function() {
I = I.filter(function(i) {
return i !== a;
}), document.removeEventListener("wheel", h, A), document.removeEventListener("touchmove", h, A), document.removeEventListener("touchstart", c, A);
};
}, []);
var C = e.removeScrollBar, g = e.inert;
return u.createElement(
u.Fragment,
var g = e.removeScrollBar, E = e.inert;
return p.createElement(
p.Fragment,
null,
g ? u.createElement(o, { styles: We(a) }) : null,
C ? u.createElement(Le, { gapMode: e.gapMode }) : null
E ? p.createElement(a, { styles: lt(o) }) : null,
g ? p.createElement(et, { gapMode: e.gapMode }) : null
);
}
function Xe(e) {
function dt(e) {
for (var t = null; e !== null; )

@@ -486,89 +486,442 @@ e instanceof ShadowRoot && (t = e.host, e = e.host), e = e.parentNode;

}
const Ye = he(q, Ve);
var re = u.forwardRef(function(e, t) {
return u.createElement(W, k({}, e, { ref: t, sideCar: Ye }));
const vt = He(_e, ft);
var Re = p.forwardRef(function(e, t) {
return p.createElement(U, D({}, e, { ref: t, sideCar: vt }));
});
re.classNames = W.classNames;
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) ?? ""
}
Re.classNames = U.classNames;
const ht = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, se = (e) => {
let t;
const n = /* @__PURE__ */ new Set(), r = (c, l) => {
const f = typeof c == "function" ? c(t) : c;
if (!Object.is(f, t)) {
const g = t;
t = l ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), n.forEach((E) => E(t, g));
}
}, o = () => t, h = { setState: r, getState: o, getInitialState: () => S, subscribe: (c) => (n.add(c), () => n.delete(c)), destroy: () => {
(ht ? "production" : void 0) !== "production" && console.warn(
"[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."
), n.clear();
} }, S = t = e(r, o, h);
return h;
}, St = (e) => e ? se(e) : se;
function mt(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var re = { exports: {} }, Q = {}, W = { exports: {} }, J = {};
/**
* @license React
* use-sync-external-store-shim.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var fe;
function pt() {
if (fe) return J;
fe = 1;
var e = C;
function t(l, f) {
return l === f && (l !== 0 || 1 / l === 1 / f) || l !== l && f !== f;
}
var n = typeof Object.is == "function" ? Object.is : t, r = e.useState, o = e.useEffect, a = e.useLayoutEffect, s = e.useDebugValue;
function u(l, f) {
var g = f(), E = r({ inst: { value: g, getSnapshot: f } }), i = E[0].inst, d = E[1];
return a(function() {
i.value = g, i.getSnapshot = f, h(i) && d({ inst: i });
}, [l, g, f]), o(function() {
return h(i) && d({ inst: i }), l(function() {
h(i) && d({ inst: i });
});
};
j(() => {
if (h) {
E(!1);
return;
}, [l]), s(g), g;
}
function h(l) {
var f = l.getSnapshot;
l = l.value;
try {
var g = f();
return !n(l, g);
} catch {
return !0;
}
}
function S(l, f) {
return f();
}
var c = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? S : u;
return J.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : c, J;
}
var ee = {};
/**
* @license React
* use-sync-external-store-shim.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var de;
function gt() {
return de || (de = 1, process.env.NODE_ENV !== "production" && function() {
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
var e = C, t = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function n(m) {
{
for (var v = arguments.length, _ = new Array(v > 1 ? v - 1 : 0), y = 1; y < v; y++)
_[y - 1] = arguments[y];
r("error", m, _);
}
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);
}
function r(m, v, _) {
{
var y = t.ReactDebugCurrentFrame, b = y.getStackAddendum();
b !== "" && (v += "%s", _ = _.concat([b]));
var R = _.map(function(L) {
return String(L);
});
R.unshift("Warning: " + v), Function.prototype.apply.call(console[m], console, R);
}
}
function o(m, v) {
return m === v && (m !== 0 || 1 / m === 1 / v) || m !== m && v !== v;
}
var a = typeof Object.is == "function" ? Object.is : o, s = e.useState, u = e.useEffect, h = e.useLayoutEffect, S = e.useDebugValue, c = !1, l = !1;
function f(m, v, _) {
c || e.startTransition !== void 0 && (c = !0, n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
var y = v();
if (!l) {
var b = v();
a(y, b) || (n("The result of getSnapshot should be cached to avoid an infinite loop"), l = !0);
}
var R = s({
inst: {
value: y,
getSnapshot: v
}
}), L = R[0].inst, B = R[1];
return h(function() {
L.value = y, L.getSnapshot = v, g(L) && B({
inst: L
});
}, [m, y, v]), u(function() {
g(L) && B({
inst: L
});
var F = function() {
g(L) && B({
inst: L
});
return;
};
return m(F);
}, [m]), S(y), y;
}
function g(m) {
var v = m.getSnapshot, _ = m.value;
try {
var y = v();
return !a(_, y);
} catch {
return !0;
}
}
function E(m, v, _) {
return v();
}
var i = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", d = !i, w = d ? E : f, O = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : w;
ee.useSyncExternalStore = O, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
}()), ee;
}
var ve;
function Le() {
return ve || (ve = 1, process.env.NODE_ENV === "production" ? W.exports = pt() : W.exports = gt()), W.exports;
}
/**
* @license React
* use-sync-external-store-shim/with-selector.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var he;
function yt() {
if (he) return Q;
he = 1;
var e = C, t = Le();
function n(S, c) {
return S === c && (S !== 0 || 1 / S === 1 / c) || S !== S && c !== c;
}
var r = typeof Object.is == "function" ? Object.is : n, o = t.useSyncExternalStore, a = e.useRef, s = e.useEffect, u = e.useMemo, h = e.useDebugValue;
return Q.useSyncExternalStoreWithSelector = function(S, c, l, f, g) {
var E = a(null);
if (E.current === null) {
var i = { hasValue: !1, value: null };
E.current = i;
} else i = E.current;
E = u(function() {
function w(y) {
if (!O) {
if (O = !0, m = y, y = f(y), g !== void 0 && i.hasValue) {
var b = i.value;
if (g(b, y)) return v = b;
}
return v = y;
}
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);
if (b = v, r(m, y)) return b;
var R = f(y);
return g !== void 0 && g(b, R) ? b : (m = y, v = R);
}
var O = !1, m, v, _ = l === void 0 ? null : l;
return [function() {
return w(c());
}, _ === null ? void 0 : function() {
return w(_());
}];
}, [c, l, f, g]);
var d = o(S, E[0], E[1]);
return s(function() {
i.hasValue = !0, i.value = d;
}, [d]), h(d), d;
}, Q;
}
var te = {};
/**
* @license React
* use-sync-external-store-shim/with-selector.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Se;
function Et() {
return Se || (Se = 1, process.env.NODE_ENV !== "production" && function() {
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
var e = C, t = Le();
function n(c, l) {
return c === l && (c !== 0 || 1 / c === 1 / l) || c !== c && l !== l;
}
var r = typeof Object.is == "function" ? Object.is : n, o = t.useSyncExternalStore, a = e.useRef, s = e.useEffect, u = e.useMemo, h = e.useDebugValue;
function S(c, l, f, g, E) {
var i = a(null), d;
i.current === null ? (d = {
hasValue: !1,
value: null
}, i.current = d) : d = i.current;
var w = u(function() {
var _ = !1, y, b, R = function(M) {
if (!_) {
_ = !0, y = M;
var K = g(M);
if (E !== void 0 && d.hasValue) {
var Y = d.value;
if (E(Y, K))
return b = Y, Y;
}
return b = K, K;
}
var xe = y, z = b;
if (r(xe, M))
return z;
var q = g(M);
return E !== void 0 && E(z, q) ? z : (y = M, b = q, q);
}, L = f === void 0 ? null : f, B = function() {
return R(l());
}, F = L === null ? void 0 : function() {
return R(L());
};
return [B, F];
}, [l, f, g, E]), O = w[0], m = w[1], v = o(c, O, m);
return s(function() {
d.hasValue = !0, d.value = v;
}, [v]), h(v), v;
}
te.useSyncExternalStoreWithSelector = S, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
}()), te;
}
process.env.NODE_ENV === "production" ? re.exports = yt() : re.exports = Et();
var _t = re.exports;
const wt = /* @__PURE__ */ mt(_t), Te = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, { useDebugValue: bt } = C, { useSyncExternalStoreWithSelector: Ot } = wt;
let me = !1;
const Ct = (e) => e;
function Rt(e, t = Ct, n) {
(Te ? "production" : void 0) !== "production" && n && !me && (console.warn(
"[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"
), me = !0);
const r = Ot(
e.subscribe,
e.getState,
e.getServerState || e.getInitialState,
t,
n
);
return bt(r), r;
}
const pe = (e) => {
(Te ? "production" : void 0) !== "production" && typeof e != "function" && console.warn(
"[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`."
);
const t = typeof e == "function" ? St(e) : e, n = (r, o) => Rt(t, r, o);
return Object.assign(n, t), n;
}, Lt = (e) => e ? pe(e) : pe, De = Lt((e) => ({
search: "",
isTyping: !1,
inDelay: !1,
setSearch: (t) => e({ search: t }),
setTyping: (t) => e({ isTyping: t }),
setDelay: (t) => e({ inDelay: t })
})), k = C.createContext({
isOpen: !1,
isTyping: !1,
selected: { label: "", value: "" },
toggleOpen: () => {
},
setSelected: () => {
},
setTyping: () => {
},
setSearch: () => {
}
}), x = C.forwardRef(({ children: e, onChange: t, onBlur: n, name: r, ...o }, a) => {
const [s, u] = G(!1), { search: h, isTyping: S, setSearch: c, setTyping: l } = De((w) => w), [f, g] = G({ label: "", value: "" }), E = oe(null), i = oe(null);
C.useEffect(() => {
const w = (O) => {
const m = O.target;
E != null && E.current && !E.current.contains(m) && (i != null && i.current) && !i.current.contains(m) && u(!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);
return document.addEventListener("mousedown", w), () => {
document.removeEventListener("mousedown", w);
};
}, [a]);
const d = () => {
u(!s);
};
return /* @__PURE__ */ T(k.Provider, { value: {
search: h,
isOpen: s,
isTyping: S,
selected: f,
toggleOpen: d,
areaRef: E,
searchRef: i,
setSelected: g,
setTyping: l,
setSearch: c,
onChange: t,
onBlur: n,
name: r,
ref: a
}, children: /* @__PURE__ */ T("div", { ...o, children: e }) });
}), Tt = ({ children: e, ...t }) => {
const { name: n, selected: r, onChange: o, onBlur: a, ref: s } = C.useContext(k);
return /* @__PURE__ */ ge("div", { ...t, children: [
e,
/* @__PURE__ */ T(
"input",
{
id: n,
type: "text",
value: r.value,
className: "hidden",
onChange: o,
onBlur: a,
name: n,
ref: s
}
)
] });
}, Dt = ({ children: e, ...t }) => {
const { isOpen: n, areaRef: r } = C.useContext(k);
return n && /* @__PURE__ */ T(Re, { children: /* @__PURE__ */ T("div", { ...t, ref: r, children: e }) });
}, xt = ({ children: e, onClick: t, value: n, label: r, ...o }) => {
const { setSelected: a, isOpen: s, toggleOpen: u, onChange: h, name: S, search: c, selected: l } = C.useContext(k), f = (g) => {
t && t(g), a({ value: n, label: r }), s && u(), h && h({ target: { name: S, value: n } });
};
return C.useEffect(() => {
c !== "" && (c == null ? void 0 : c.toLowerCase()) === r.toLowerCase() ? a({ value: n, label: r }) : a({ value: "", label: l.label });
}, [r, n, c, a]), /* @__PURE__ */ T("div", { ...o, onClick: f, children: e ?? r });
}, At = ({ children: e, onClick: t, ...n }) => {
const { toggleOpen: r } = C.useContext(k);
return /* @__PURE__ */ T("button", { ...n, onClick: (a) => {
r(), t && t(a);
}, children: e });
}, It = C.memo(({ onChange: e, onFocus: t, ...n }) => {
const { isOpen: r, toggleOpen: o, selected: a, searchRef: s, setSearch: u, setTyping: h, setSelected: S } = C.useContext(k);
return /* @__PURE__ */ T("input", { ref: s, onChange: (f) => {
u(f.target.value.toLowerCase()), S({ label: f.target.value, value: a.value }), h(!0), e && e(f);
}, onFocus: (f) => {
r || o(), t && t(f);
}, type: "text", value: a.label, ...n });
});
x.Trigger = Tt;
x.Item = xt;
x.Panel = Dt;
x.Button = At;
x.Search = It;
const Vt = () => /* @__PURE__ */ T("p", { className: "p-2", children: "Carregando..." }), kt = C.memo(
C.forwardRef(
({
data: e,
placeholder: t,
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",
itemClassName: r = "p-2 cursor-pointer hover:bg-gray-200 transition duration-300 ease-in-out",
disabled: o,
...a
}, s) => {
const u = Bt(e);
return /* @__PURE__ */ ge(x, { className: "relative flex flex-col", ref: s, ...a, children: [
/* @__PURE__ */ T(x.Trigger, { children: /* @__PURE__ */ T(
x.Search,
{
className: n,
placeholder: t,
disabled: o
}
) }),
/* @__PURE__ */ T(x.Panel, { className: "flex flex-col absolute bg-white mt-2 rounded-lg shadow-lg p-2 w-full overflow-y-auto max-h-[260%] scrollbar-none", children: u.length ? u.map((h, S) => /* @__PURE__ */ T(
x.Item,
{
value: h.value,
label: h.label,
className: r
},
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, {})
}
) })
] });
}
S
)) : /* @__PURE__ */ T(Vt, {}) })
] });
}
)
);
He.displayName = "SearchSelect";
kt.displayName = "SearchSelect";
const Bt = (e, t = 500) => {
const { search: n, isTyping: r, setTyping: o, inDelay: a, setDelay: s } = De((S) => S), [u, h] = G([]);
return Ae(() => {
if (r) {
h([]), a || (s(!0), setTimeout(() => {
o(!1), s(!1);
}, t));
return;
}
(async () => {
if (typeof e == "function") {
const c = await e(n);
Array.isArray(c) && h(c.filter(
(l) => l.label.toLowerCase().includes(n.toLowerCase())
));
} else if (Array.isArray(e)) {
const c = e.filter(
(l) => l.label.toLowerCase().includes(n.toLowerCase())
);
h(c);
}
})();
}, [r]), u;
};
export {
He as SearchSelect
kt as SearchSelect,
x as Select,
Bt as useDataSearch
};

@@ -1,41 +0,73 @@

(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,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(c,"px ").concat(r,`;
(function(A,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],C):(A=typeof globalThis<"u"?globalThis:A||self,C(A["simple-search-dropdown"]={},A["react/jsx-runtime"],A.React))})(this,function(A,C,b){"use strict";function Ae(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const g=Ae(b);var I=function(){return I=Object.assign||function(t){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},I.apply(this,arguments)};function oe(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function Ie(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,a;n<o;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var N="right-scroll-bar-position",j="width-before-scroll-bar",Ve="with-scroll-bars-hidden",ke="--removed-body-scroll-bar-size";function q(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Me(e,t){var r=b.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(n){var o=r.value;o!==n&&(r.value=n,r.callback(n,o))}}}})[0];return r.callback=t,r.facade}var Pe=typeof window<"u"?g.useLayoutEffect:g.useEffect,ae=new WeakMap;function Re(e,t){var r=Me(null,function(n){return e.forEach(function(o){return q(o,n)})});return Pe(function(){var n=ae.get(r);if(n){var o=new Set(n),a=new Set(e),s=r.current;o.forEach(function(u){a.has(u)||q(u,null)}),a.forEach(function(u){o.has(u)||q(u,s)})}ae.set(r,e)},[e]),r}function Be(e){return e}function Ne(e,t){t===void 0&&(t=Be);var r=[],n=!1,o={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(a){var s=t(a,n);return r.push(s),function(){r=r.filter(function(u){return u!==s})}},assignSyncMedium:function(a){for(n=!0;r.length;){var s=r;r=[],s.forEach(a)}r={push:function(u){return a(u)},filter:function(){return r}}},assignMedium:function(a){n=!0;var s=[];if(r.length){var u=r;r=[],u.forEach(a),s=r}var h=function(){var c=s;s=[],c.forEach(a)},S=function(){return Promise.resolve().then(h)};S(),r={push:function(c){s.push(c),S()},filter:function(c){return s=s.filter(c),r}}}};return o}function je(e){e===void 0&&(e={});var t=Ne(null);return t.options=I({async:!0,ssr:!1},e),t}var ie=function(e){var t=e.sideCar,r=oe(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=t.read();if(!n)throw new Error("Sidecar medium not found");return g.createElement(n,I({},r))};ie.isSideCarExport=!0;function We(e,t){return e.useMedium(t),ie}var ue=je(),z=function(){},W=g.forwardRef(function(e,t){var r=g.useRef(null),n=g.useState({onScrollCapture:z,onWheelCapture:z,onTouchMoveCapture:z}),o=n[0],a=n[1],s=e.forwardProps,u=e.children,h=e.className,S=e.removeScrollBar,c=e.enabled,l=e.shards,f=e.sideCar,m=e.noIsolation,E=e.inert,i=e.allowPinchZoom,d=e.as,w=d===void 0?"div":d,L=e.gapMode,p=oe(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),v=f,_=Re([r,t]),y=I(I({},p),o);return g.createElement(g.Fragment,null,c&&g.createElement(v,{sideCar:ue,removeScrollBar:S,shards:l,noIsolation:m,inert:E,setCallbacks:a,allowPinchZoom:!!i,lockRef:r,gapMode:L}),s?g.cloneElement(g.Children.only(u),I(I({},y),{ref:_})):g.createElement(w,I({},y,{className:h,ref:_}),u))});W.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},W.classNames={fullWidth:j,zeroRight:N};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 Ue(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function qe(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ze=function(){var e=0,t=null;return{add:function(r){e==0&&(t=Ge())&&(Ue(t,r),qe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Fe=function(){var e=ze();return function(t,r){g.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},ce=function(){var e=Fe(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},Ke={left:0,top:0,right:0,gap:0},F=function(e){return parseInt(e||"",10)||0},Ye=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],n=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[F(r),F(n),F(o)]},Xe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ke;var t=Ye(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},$e=ce(),V="data-scroll-locked",Ze=function(e,t,r,n){var o=e.left,a=e.top,s=e.right,u=e.gap;return r===void 0&&(r="margin"),`
.`.concat(Ve,` {
overflow: hidden `).concat(n,`;
padding-right: `).concat(u,"px ").concat(n,`;
}
body[`).concat(T,`] {
overflow: hidden `).concat(r,`;
body[`).concat(V,`] {
overflow: hidden `).concat(n,`;
overscroll-behavior: contain;
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
padding-left: `.concat(a,`px;
padding-top: `).concat(o,`px;
padding-right: `).concat(f,`px;
`).concat([t&&"position: relative ".concat(n,";"),r==="margin"&&`
padding-left: `.concat(o,`px;
padding-top: `).concat(a,`px;
padding-right: `).concat(s,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(c,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
margin-right: `).concat(u,"px ").concat(n,`;
`),r==="padding"&&"padding-right: ".concat(u,"px ").concat(n,";")].filter(Boolean).join(""),`
}
.`).concat(R,` {
right: `).concat(c,"px ").concat(r,`;
.`).concat(N,` {
right: `).concat(u,"px ").concat(n,`;
}
.`).concat(j,` {
margin-right: `).concat(c,"px ").concat(r,`;
margin-right: `).concat(u,"px ").concat(n,`;
}
.`).concat(R," .").concat(R,` {
right: 0 `).concat(r,`;
.`).concat(N," .").concat(N,` {
right: 0 `).concat(n,`;
}
.`).concat(j," .").concat(j,` {
margin-right: 0 `).concat(r,`;
margin-right: 0 `).concat(n,`;
}
body[`).concat(T,`] {
`).concat(ce,": ").concat(c,`px;
body[`).concat(V,`] {
`).concat(ke,": ").concat(u,`px;
}
`)},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`
`)},le=function(){var e=parseInt(document.body.getAttribute(V)||"0",10);return isFinite(e)?e:0},Qe=function(){g.useEffect(function(){return document.body.setAttribute(V,(le()+1).toString()),function(){var e=le()-1;e<=0?document.body.removeAttribute(V):document.body.setAttribute(V,e.toString())}},[])},Je=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,o=n===void 0?"margin":n;Qe();var a=g.useMemo(function(){return Xe(o)},[o]);return g.createElement($e,{styles:Ze(a,!t,o,r?"":"!important")})},K=!1;if(typeof window<"u")try{var H=Object.defineProperty({},"passive",{get:function(){return K=!0,!0}});window.addEventListener("test",H,H),window.removeEventListener("test",H,H)}catch{K=!1}var k=K?{passive:!1}:!1,et=function(e){return e.tagName==="TEXTAREA"},se=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!et(e)&&r[t]==="visible")},tt=function(e){return se(e,"overflowY")},rt=function(e){return se(e,"overflowX")},fe=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=de(e,n);if(o){var a=ve(e,n),s=a[1],u=a[2];if(s>u)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},nt=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},ot=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},de=function(e,t){return e==="v"?tt(t):rt(t)},ve=function(e,t){return e==="v"?nt(t):ot(t)},at=function(e,t){return e==="h"&&t==="rtl"?-1:1},it=function(e,t,r,n,o){var a=at(e,window.getComputedStyle(t).direction),s=a*n,u=r.target,h=t.contains(u),S=!1,c=s>0,l=0,f=0;do{var m=ve(e,u),E=m[0],i=m[1],d=m[2],w=i-d-a*E;(E||w)&&de(e,u)&&(l+=w,f+=E),u instanceof ShadowRoot?u=u.host:u=u.parentNode}while(!h&&u!==document.body||h&&(t.contains(u)||t===u));return(c&&(Math.abs(l)<1||!o)||!c&&(Math.abs(f)<1||!o))&&(S=!0),S},G=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},he=function(e){return[e.deltaX,e.deltaY]},Se=function(e){return e&&"current"in e?e.current:e},ut=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ct=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=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"})});
`)},lt=0,M=[];function st(e){var t=g.useRef([]),r=g.useRef([0,0]),n=g.useRef(),o=g.useState(lt++)[0],a=g.useState(ce)[0],s=g.useRef(e);g.useEffect(function(){s.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var i=Ie([e.lockRef.current],(e.shards||[]).map(Se),!0).filter(Boolean);return i.forEach(function(d){return d.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),i.forEach(function(d){return d.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var u=g.useCallback(function(i,d){if("touches"in i&&i.touches.length===2)return!s.current.allowPinchZoom;var w=G(i),L=r.current,p="deltaX"in i?i.deltaX:L[0]-w[0],v="deltaY"in i?i.deltaY:L[1]-w[1],_,y=i.target,O=Math.abs(p)>Math.abs(v)?"h":"v";if("touches"in i&&O==="h"&&y.type==="range")return!1;var T=fe(O,y);if(!T)return!0;if(T?_=O:(_=O==="v"?"h":"v",T=fe(O,y)),!T)return!1;if(!n.current&&"changedTouches"in i&&(p||v)&&(n.current=_),!_)return!0;var D=n.current||_;return it(D,d,i,D==="h"?p:v,!0)},[]),h=g.useCallback(function(i){var d=i;if(!(!M.length||M[M.length-1]!==a)){var w="deltaY"in d?he(d):G(d),L=t.current.filter(function(_){return _.name===d.type&&(_.target===d.target||d.target===_.shadowParent)&&ut(_.delta,w)})[0];if(L&&L.should){d.cancelable&&d.preventDefault();return}if(!L){var p=(s.current.shards||[]).map(Se).filter(Boolean).filter(function(_){return _.contains(d.target)}),v=p.length>0?u(d,p[0]):!s.current.noIsolation;v&&d.cancelable&&d.preventDefault()}}},[]),S=g.useCallback(function(i,d,w,L){var p={name:i,delta:d,target:w,should:L,shadowParent:ft(w)};t.current.push(p),setTimeout(function(){t.current=t.current.filter(function(v){return v!==p})},1)},[]),c=g.useCallback(function(i){r.current=G(i),n.current=void 0},[]),l=g.useCallback(function(i){S(i.type,he(i),i.target,u(i,e.lockRef.current))},[]),f=g.useCallback(function(i){S(i.type,G(i),i.target,u(i,e.lockRef.current))},[]);g.useEffect(function(){return M.push(a),e.setCallbacks({onScrollCapture:l,onWheelCapture:l,onTouchMoveCapture:f}),document.addEventListener("wheel",h,k),document.addEventListener("touchmove",h,k),document.addEventListener("touchstart",c,k),function(){M=M.filter(function(i){return i!==a}),document.removeEventListener("wheel",h,k),document.removeEventListener("touchmove",h,k),document.removeEventListener("touchstart",c,k)}},[]);var m=e.removeScrollBar,E=e.inert;return g.createElement(g.Fragment,null,E?g.createElement(a,{styles:ct(o)}):null,m?g.createElement(Je,{gapMode:e.gapMode}):null)}function ft(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const dt=We(ue,st);var pe=g.forwardRef(function(e,t){return g.createElement(W,I({},e,{ref:t,sideCar:dt}))});pe.classNames=W.classNames;const vt={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},ge=e=>{let t;const r=new Set,n=(c,l)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const m=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(E=>E(t,m))}},o=()=>t,h={setState:n,getState:o,getInitialState:()=>S,subscribe:c=>(r.add(c),()=>r.delete(c)),destroy:()=>{(vt?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},S=t=e(n,o,h);return h},ht=e=>e?ge(e):ge;function St(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Y={exports:{}},X={},U={exports:{}},$={};/**
* @license React
* use-sync-external-store-shim.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var me;function pt(){if(me)return $;me=1;var e=b;function t(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}var r=typeof Object.is=="function"?Object.is:t,n=e.useState,o=e.useEffect,a=e.useLayoutEffect,s=e.useDebugValue;function u(l,f){var m=f(),E=n({inst:{value:m,getSnapshot:f}}),i=E[0].inst,d=E[1];return a(function(){i.value=m,i.getSnapshot=f,h(i)&&d({inst:i})},[l,m,f]),o(function(){return h(i)&&d({inst:i}),l(function(){h(i)&&d({inst:i})})},[l]),s(m),m}function h(l){var f=l.getSnapshot;l=l.value;try{var m=f();return!r(l,m)}catch{return!0}}function S(l,f){return f()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?S:u;return $.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,$}var Z={};/**
* @license React
* use-sync-external-store-shim.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ye;function gt(){return ye||(ye=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=b,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function r(p){{for(var v=arguments.length,_=new Array(v>1?v-1:0),y=1;y<v;y++)_[y-1]=arguments[y];n("error",p,_)}}function n(p,v,_){{var y=t.ReactDebugCurrentFrame,O=y.getStackAddendum();O!==""&&(v+="%s",_=_.concat([O]));var T=_.map(function(D){return String(D)});T.unshift("Warning: "+v),Function.prototype.apply.call(console[p],console,T)}}function o(p,v){return p===v&&(p!==0||1/p===1/v)||p!==p&&v!==v}var a=typeof Object.is=="function"?Object.is:o,s=e.useState,u=e.useEffect,h=e.useLayoutEffect,S=e.useDebugValue,c=!1,l=!1;function f(p,v,_){c||e.startTransition!==void 0&&(c=!0,r("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var y=v();if(!l){var O=v();a(y,O)||(r("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}var T=s({inst:{value:y,getSnapshot:v}}),D=T[0].inst,R=T[1];return h(function(){D.value=y,D.getSnapshot=v,m(D)&&R({inst:D})},[p,y,v]),u(function(){m(D)&&R({inst:D});var J=function(){m(D)&&R({inst:D})};return p(J)},[p]),S(y),y}function m(p){var v=p.getSnapshot,_=p.value;try{var y=v();return!a(_,y)}catch{return!0}}function E(p,v,_){return v()}var i=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",d=!i,w=d?E:f,L=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:w;Z.useSyncExternalStore=L,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Z}var Ee;function _e(){return Ee||(Ee=1,process.env.NODE_ENV==="production"?U.exports=pt():U.exports=gt()),U.exports}/**
* @license React
* use-sync-external-store-shim/with-selector.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var be;function mt(){if(be)return X;be=1;var e=b,t=_e();function r(S,c){return S===c&&(S!==0||1/S===1/c)||S!==S&&c!==c}var n=typeof Object.is=="function"?Object.is:r,o=t.useSyncExternalStore,a=e.useRef,s=e.useEffect,u=e.useMemo,h=e.useDebugValue;return X.useSyncExternalStoreWithSelector=function(S,c,l,f,m){var E=a(null);if(E.current===null){var i={hasValue:!1,value:null};E.current=i}else i=E.current;E=u(function(){function w(y){if(!L){if(L=!0,p=y,y=f(y),m!==void 0&&i.hasValue){var O=i.value;if(m(O,y))return v=O}return v=y}if(O=v,n(p,y))return O;var T=f(y);return m!==void 0&&m(O,T)?O:(p=y,v=T)}var L=!1,p,v,_=l===void 0?null:l;return[function(){return w(c())},_===null?void 0:function(){return w(_())}]},[c,l,f,m]);var d=o(S,E[0],E[1]);return s(function(){i.hasValue=!0,i.value=d},[d]),h(d),d},X}var Q={};/**
* @license React
* use-sync-external-store-shim/with-selector.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var we;function yt(){return we||(we=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=b,t=_e();function r(c,l){return c===l&&(c!==0||1/c===1/l)||c!==c&&l!==l}var n=typeof Object.is=="function"?Object.is:r,o=t.useSyncExternalStore,a=e.useRef,s=e.useEffect,u=e.useMemo,h=e.useDebugValue;function S(c,l,f,m,E){var i=a(null),d;i.current===null?(d={hasValue:!1,value:null},i.current=d):d=i.current;var w=u(function(){var _=!1,y,O,T=function(B){if(!_){_=!0,y=B;var ee=m(B);if(E!==void 0&&d.hasValue){var te=d.value;if(E(te,ee))return O=te,te}return O=ee,ee}var Vt=y,re=O;if(n(Vt,B))return re;var ne=m(B);return E!==void 0&&E(re,ne)?re:(y=B,O=ne,ne)},D=f===void 0?null:f,R=function(){return T(l())},J=D===null?void 0:function(){return T(D())};return[R,J]},[l,f,m,E]),L=w[0],p=w[1],v=o(c,L,p);return s(function(){d.hasValue=!0,d.value=v},[v]),h(v),v}Q.useSyncExternalStoreWithSelector=S,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Q}process.env.NODE_ENV==="production"?Y.exports=mt():Y.exports=yt();var Et=Y.exports;const _t=St(Et),Oe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},{useDebugValue:bt}=b,{useSyncExternalStoreWithSelector:wt}=_t;let Ce=!1;const Ot=e=>e;function Ct(e,t=Ot,r){(Oe?"production":void 0)!=="production"&&r&&!Ce&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Ce=!0);const n=wt(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return bt(n),n}const Le=e=>{(Oe?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?ht(e):e,r=(n,o)=>Ct(t,n,o);return Object.assign(r,t),r},Te=(e=>e?Le(e):Le)(e=>({search:"",isTyping:!1,inDelay:!1,setSearch:t=>e({search:t}),setTyping:t=>e({isTyping:t}),setDelay:t=>e({inDelay:t})})),P=b.createContext({isOpen:!1,isTyping:!1,selected:{label:"",value:""},toggleOpen:()=>{},setSelected:()=>{},setTyping:()=>{},setSearch:()=>{}}),x=b.forwardRef(({children:e,onChange:t,onBlur:r,name:n,...o},a)=>{const[s,u]=b.useState(!1),{search:h,isTyping:S,setSearch:c,setTyping:l}=Te(w=>w),[f,m]=b.useState({label:"",value:""}),E=b.useRef(null),i=b.useRef(null);b.useEffect(()=>{const w=L=>{const p=L.target;E!=null&&E.current&&!E.current.contains(p)&&(i!=null&&i.current)&&!i.current.contains(p)&&u(!1)};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[a]);const d=()=>{u(!s)};return C.jsx(P.Provider,{value:{search:h,isOpen:s,isTyping:S,selected:f,toggleOpen:d,areaRef:E,searchRef:i,setSelected:m,setTyping:l,setSearch:c,onChange:t,onBlur:r,name:n,ref:a},children:C.jsx("div",{...o,children:e})})}),Lt=({children:e,...t})=>{const{name:r,selected:n,onChange:o,onBlur:a,ref:s}=b.useContext(P);return C.jsxs("div",{...t,children:[e,C.jsx("input",{id:r,type:"text",value:n.value,className:"hidden",onChange:o,onBlur:a,name:r,ref:s})]})},Tt=({children:e,...t})=>{const{isOpen:r,areaRef:n}=b.useContext(P);return r&&C.jsx(pe,{children:C.jsx("div",{...t,ref:n,children:e})})},Dt=({children:e,onClick:t,value:r,label:n,...o})=>{const{setSelected:a,isOpen:s,toggleOpen:u,onChange:h,name:S,search:c,selected:l}=b.useContext(P),f=m=>{t&&t(m),a({value:r,label:n}),s&&u(),h&&h({target:{name:S,value:r}})};return b.useEffect(()=>{c!==""&&(c==null?void 0:c.toLowerCase())===n.toLowerCase()?a({value:r,label:n}):a({value:"",label:l.label})},[n,r,c,a]),C.jsx("div",{...o,onClick:f,children:e??n})},xt=({children:e,onClick:t,...r})=>{const{toggleOpen:n}=b.useContext(P),o=a=>{n(),t&&t(a)};return C.jsx("button",{...r,onClick:o,children:e})},At=b.memo(({onChange:e,onFocus:t,...r})=>{const{isOpen:n,toggleOpen:o,selected:a,searchRef:s,setSearch:u,setTyping:h,setSelected:S}=b.useContext(P),c=f=>{u(f.target.value.toLowerCase()),S({label:f.target.value,value:a.value}),h(!0),e&&e(f)},l=f=>{n||o(),t&&t(f)};return C.jsx("input",{ref:s,onChange:c,onFocus:l,type:"text",value:a.label,...r})});x.Trigger=Lt,x.Item=Dt,x.Panel=Tt,x.Button=xt,x.Search=At;const It=()=>C.jsx("p",{className:"p-2",children:"Carregando..."}),De=b.memo(b.forwardRef(({data:e,placeholder:t,className:r="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",itemClassName:n="p-2 cursor-pointer hover:bg-gray-200 transition duration-300 ease-in-out",disabled:o,...a},s)=>{const u=xe(e);return C.jsxs(x,{className:"relative flex flex-col",ref:s,...a,children:[C.jsx(x.Trigger,{children:C.jsx(x.Search,{className:r,placeholder:t,disabled:o})}),C.jsx(x.Panel,{className:"flex flex-col absolute bg-white mt-2 rounded-lg shadow-lg p-2 w-full overflow-y-auto max-h-[260%] scrollbar-none",children:u.length?u.map((h,S)=>C.jsx(x.Item,{value:h.value,label:h.label,className:n},S)):C.jsx(It,{})})]})}));De.displayName="SearchSelect";const xe=(e,t=500)=>{const{search:r,isTyping:n,setTyping:o,inDelay:a,setDelay:s}=Te(S=>S),[u,h]=b.useState([]);return b.useEffect(()=>{if(n){h([]),a||(s(!0),setTimeout(()=>{o(!1),s(!1)},t));return}(async()=>{if(typeof e=="function"){const c=await e(r);Array.isArray(c)&&h(c.filter(l=>l.label.toLowerCase().includes(r.toLowerCase())))}else if(Array.isArray(e)){const c=e.filter(l=>l.label.toLowerCase().includes(r.toLowerCase()));h(c)}})()},[n]),u};A.SearchSelect=De,A.Select=x,A.useDataSearch=xe,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
{
"name": "simple-search-dropdown",
"private": false,
"version": "0.1.7",
"version": "0.1.8",
"repository": {

@@ -33,15 +33,17 @@ "type": "git",

"react-dom": "^18.3.1",
"react-remove-scroll": "^2.5.10"
"react-remove-scroll": "^2.5.10",
"zustand": "^4.5.5"
},
"devDependencies": {
"@eslint/js": "^9.8.0",
"@eslint/js": "^9.9.0",
"@testing-library/react": "^16.0.0",
"@types/node": "^22.3.0",
"@types/react": "^18.3.3",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^22.5.0",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
"eslint": "^9.8.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
"eslint": "^9.9.0",
"eslint-plugin-react-hooks": "5.1.0-rc-fb9a90fa48-20240614",
"eslint-plugin-react-refresh": "^0.4.10",
"globals": "^15.9.0",

@@ -55,6 +57,7 @@ "husky": "^9.1.5",

"react-hook-form": "^7.52.2",
"tailwind-scrollbar": "^3.1.0",
"tailwindcss": "^3.4.10",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.0",
"vite": "^5.4.0",
"typescript": "^5.5.4",
"typescript-eslint": "^8.2.0",
"vite": "^5.4.2",
"vite-plugin-dts": "^4.0.3",

@@ -74,4 +77,5 @@ "vitest": "^2.0.5"

"test": "vitest",
"test:unit": "vitest --watch false"
"test:unit": "vitest --watch false",
"update": "node update.js"
}
}

@@ -5,8 +5,203 @@

Componente com sistema de pesquisa e dropdown imbutidos em um só. É possível listar todos os itens duma lista e filtrar por aquilo que você está buscando, sendo compativel até mesmo com requisições de APIs.
## Instalação
Instalando `simple-search-dropdown`:
```bash
npm install simple-search-dropdown
# OU
yarn add simple-search-dropdown
# OU
pnpm add simple-search-dropdown
```
## Uso/Exemplos
### Dados como Array
```javascript
import { SearchSelect } from 'simple-search-dropdown'
function App() {
const data = [
{value: 1, label: "Abacaxi"},
{value: 2, label: "Banana"},
{value: 3, label: "Avião"},
{value: 4, label: "Bola"},
{value: 5, label: "Lula"},
{value: 6, label: "Faca"},
{value: 7, label: "Magnus"},
{value: 8, label: "Xadrez"},
]
return (
<main className="flex flex-col justify-center items-center ">
<div className="flex flex-col mt-2">
<SearchSelect data={data} placeholder="Pesquisar"} />
</div>
</main>
)
}
export default App
```
### Dados como função Async
```javascript
import { SearchSelect } from 'simple-search-dropdown'
function App() {
const promiseOptions = () =>
new Promise((resolve) => {
setTimeout(() => {
const data = [
{value: 1, label: "Abacaxi"},
{value: 2, label: "Banana"},
{value: 3, label: "Avião"},
{value: 4, label: "Bola"},
{value: 5, label: "Lula"},
{value: 6, label: "Faca"},
{value: 7, label: "Magnus"},
{value: 8, label: "Xadrez"},
]
resolve(data);
}, 1000);
});
return (
<main className="flex flex-col justify-center items-center ">
<div className="flex flex-col mt-2">
<SearchSelect data={promiseOptions} placeholder="Pesquisar"} />
</div>
</main>
)
}
export default App
```
### Usando react-hook-form
```javascript
import { useForm } from "react-hook-form";
import { SearchSelect } from 'simple-search-dropdown'
function App() {
const { handleSubmit, register } = useForm()
const promiseOptions = () =>
new Promise((resolve) => {
setTimeout(() => {
const data = [
{value: 1, label: "Abacaxi"},
{value: 2, label: "Banana"},
{value: 3, label: "Avião"},
{value: 4, label: "Bola"},
{value: 5, label: "Lula"},
{value: 6, label: "Faca"},
{value: 7, label: "Magnus"},
{value: 8, label: "Xadrez"},
]
resolve(data);
}, 1000);
});
return (
<main className="flex flex-col justify-center items-center ">
<form className="flex flex-col mt-2" onSubmit={handleSubmit((data) => console.log(data))}>
<SearchSelect
data={promiseOptions}
placeholder="Pesquisar" {...register("abc")}
/>
<button type="submit" className="p-2 bg-blue-500 text-white mt-2">Submit</button>
</form>
</main>
)
}
export default App
```
### Criando seu próprio
É possível fazer seu próprio componente usando o `Select` e `useDataSearch` do pacote.
```javascript
import { Select, useDataSearch } from 'simple-search-dropdown'
function YourSelectComponent({data}) {
const itemFiltered = useDataSearch(data)
return (
<Select>
<Select.Trigger>
<Select.Search />
</Select.Trigger>
<Select.Panel>
{
itemFiltered.length > 0 &&
itemFiltered.map((item, idx) => (
<Select.Item key={idx} value={item.value} label={item.label} />
))
}
</Select.Panel>
</Select>
)
}
export default YourSelectComponent
```
## Funcionalidades
- Tipo primitivo para customização pessoal.
- Componente já predefinido para utilidade rápida e fácil.
- Aceita lista de dados ou uma função assíncrona.
- Componente primitivo para customização pessoal.
- Compatível com react-hook-form.
- Sistema de pesquisa e dropdown em um só.
## Para Desenvolvedores
Contribuições são sempre bem-vindas!
### Conhecimento
É necessário o entendimento de TypeScript para contribuições envolvendo os componentes. Além do TypeScript, entender como funciona o react e ref são essenciais.
### Pré requisito
- Git
- Node.js
- IDE (VSCode/Zed)
### Contribuindo
1. Crie um fork do projeto clicando no botão localizado a direita do nome do repositório.
2. Clone o repositório que está na sua conta do github. (Siga os passos do próximo tópico)
3. Faça suas alterações.
4. Commit e abra um Pull Request.
5. Espere a aprovação de algum desenvolvedor.
## Rodando localmente
Clone o projeto
```bash
git clone https://github.com/KingTimer12/simple-search-dropdown.git
```
Entre no diretório do projeto
```bash
cd simple-search-dropdown
```
Instale as dependências
```bash
pnpm install
```
## Rodando os testes
Para rodar os testes, rode o seguinte comando
```bash
npm run test
# OU
yarn test
# OU
pnpm test
```
## Autores

@@ -16,2 +211,2 @@

- [@Mateus Bessa](https://github.com/Mateusinbessa)
- [@Henrique Mota](https://github.com/henriquemota)
- [@Henrique Mota](https://github.com/henriquemota)

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