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

simple-search-dropdown

Package Overview
Dependencies
Maintainers
1
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.1 to 0.1.2

124

dist/index.es.js
import { jsxs as ne, jsx as B } from "react/jsx-runtime";
import * as l from "react";
import ae, { useState as L, useRef as H, useEffect as z } from "react";
var C = function() {
return C = Object.assign || function(t) {
var E = function() {
return E = Object.assign || function(t) {
for (var n, r = 1, a = arguments.length; r < a; r++) {

@@ -11,3 +11,3 @@ n = arguments[r];

return t;
}, C.apply(this, arguments);
}, E.apply(this, arguments);
};

@@ -112,11 +112,11 @@ function G(e, t) {

}
var m = function() {
var g = function() {
var d = u;
u = [], d.forEach(c);
}, p = function() {
return Promise.resolve().then(m);
}, b = function() {
return Promise.resolve().then(g);
};
p(), n = {
b(), n = {
push: function(d) {
u.push(d), p();
u.push(d), b();
},

@@ -134,3 +134,3 @@ filter: function(d) {

var t = de(null);
return t.options = C({ async: !0, ssr: !1 }, e), t;
return t.options = E({ async: !0, ssr: !1 }, e), t;
}

@@ -144,3 +144,3 @@ var U = function(e) {

throw new Error("Sidecar medium not found");
return l.createElement(r, C({}, n));
return l.createElement(r, E({}, n));
};

@@ -157,8 +157,8 @@ U.isSideCarExport = !0;

onTouchMoveCapture: V
}), a = r[0], c = r[1], u = e.forwardProps, o = e.children, m = e.className, p = e.removeScrollBar, d = e.enabled, b = e.shards, y = e.sideCar, h = e.noIsolation, S = e.inert, i = e.allowPinchZoom, s = e.as, f = s === void 0 ? "div" : s, v = e.gapMode, w = G(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), E = y, g = se([n, t]), R = C(C({}, w), a);
}), a = r[0], c = r[1], u = e.forwardProps, o = e.children, g = e.className, b = e.removeScrollBar, d = e.enabled, y = e.shards, S = e.sideCar, h = e.noIsolation, w = e.inert, i = e.allowPinchZoom, s = e.as, f = s === void 0 ? "div" : s, v = e.gapMode, p = G(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), C = S, m = se([n, t]), R = E(E({}, p), a);
return l.createElement(
l.Fragment,
null,
d && l.createElement(E, { sideCar: q, removeScrollBar: p, shards: b, noIsolation: h, inert: S, setCallbacks: c, allowPinchZoom: !!i, lockRef: n, gapMode: v }),
u ? l.cloneElement(l.Children.only(o), C(C({}, R), { ref: g })) : l.createElement(f, C({}, R, { className: m, ref: g }), o)
d && l.createElement(C, { sideCar: q, removeScrollBar: b, shards: y, noIsolation: h, inert: w, setCallbacks: c, allowPinchZoom: !!i, lockRef: n, gapMode: v }),
u ? l.cloneElement(l.Children.only(o), E(E({}, R), { ref: m })) : l.createElement(f, E({}, R, { className: g, ref: m }), o)
);

@@ -175,7 +175,7 @@ });

};
var me = function() {
var ge = function() {
if (typeof __webpack_nonce__ < "u")
return __webpack_nonce__;
};
function ge() {
function me() {
if (!document)

@@ -185,3 +185,3 @@ return null;

e.type = "text/css";
var t = me();
var t = ge();
return t && e.setAttribute("nonce", t), e;

@@ -200,3 +200,3 @@ }

add: function(n) {
e == 0 && (t = ge()) && (pe(t, n), be(t)), e++;
e == 0 && (t = me()) && (pe(t, n), be(t)), e++;
},

@@ -364,12 +364,12 @@ remove: function() {

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

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

return !u.current.allowPinchZoom;
var f = O(i), v = n.current, w = "deltaX" in i ? i.deltaX : v[0] - f[0], E = "deltaY" in i ? i.deltaY : v[1] - f[1], g, R = i.target, N = Math.abs(w) > Math.abs(E) ? "h" : "v";
var f = O(i), v = n.current, p = "deltaX" in i ? i.deltaX : v[0] - f[0], C = "deltaY" in i ? i.deltaY : v[1] - f[1], m, R = i.target, N = Math.abs(p) > Math.abs(C) ? "h" : "v";
if ("touches" in i && N === "h" && R.type === "range")

@@ -416,13 +416,13 @@ return !1;

return !0;
if (M ? g = N : (g = N === "v" ? "h" : "v", M = Z(N, R)), !M)
if (M ? m = N : (m = N === "v" ? "h" : "v", M = Z(N, R)), !M)
return !1;
if (!r.current && "changedTouches" in i && (w || E) && (r.current = g), !g)
if (!r.current && "changedTouches" in i && (p || C) && (r.current = m), !m)
return !0;
var D = r.current || g;
return Ie(D, s, i, D === "h" ? w : E, !0);
}, []), m = l.useCallback(function(i) {
var D = r.current || m;
return Ie(D, s, i, D === "h" ? p : C, !0);
}, []), g = l.useCallback(function(i) {
var s = i;
if (!(!P.length || P[P.length - 1] !== c)) {
var f = "deltaY" in s ? Q(s) : O(s), v = t.current.filter(function(g) {
return g.name === s.type && (g.target === s.target || s.target === g.shadowParent) && Ae(g.delta, f);
var f = "deltaY" in s ? Q(s) : O(s), v = t.current.filter(function(m) {
return m.name === s.type && (m.target === s.target || s.target === m.shadowParent) && Ae(m.delta, f);
})[0];

@@ -434,13 +434,13 @@ if (v && v.should) {

if (!v) {
var w = (u.current.shards || []).map($).filter(Boolean).filter(function(g) {
return g.contains(s.target);
}), E = w.length > 0 ? o(s, w[0]) : !u.current.noIsolation;
E && s.cancelable && s.preventDefault();
var p = (u.current.shards || []).map($).filter(Boolean).filter(function(m) {
return m.contains(s.target);
}), C = p.length > 0 ? o(s, p[0]) : !u.current.noIsolation;
C && s.cancelable && s.preventDefault();
}
}
}, []), p = l.useCallback(function(i, s, f, v) {
var w = { name: i, delta: s, target: f, should: v, shadowParent: Xe(f) };
t.current.push(w), setTimeout(function() {
t.current = t.current.filter(function(E) {
return E !== w;
}, []), b = l.useCallback(function(i, s, f, v) {
var p = { name: i, delta: s, target: f, should: v, shadowParent: Xe(f) };
t.current.push(p), setTimeout(function() {
t.current = t.current.filter(function(C) {
return C !== p;
});

@@ -450,23 +450,23 @@ }, 1);

n.current = O(i), r.current = void 0;
}, []), b = l.useCallback(function(i) {
p(i.type, Q(i), i.target, o(i, e.lockRef.current));
}, []), y = l.useCallback(function(i) {
p(i.type, O(i), i.target, o(i, e.lockRef.current));
b(i.type, Q(i), i.target, o(i, e.lockRef.current));
}, []), S = l.useCallback(function(i) {
b(i.type, O(i), i.target, o(i, e.lockRef.current));
}, []);
l.useEffect(function() {
return P.push(c), e.setCallbacks({
onScrollCapture: b,
onWheelCapture: b,
onTouchMoveCapture: y
}), document.addEventListener("wheel", m, k), document.addEventListener("touchmove", m, k), document.addEventListener("touchstart", d, k), function() {
onScrollCapture: y,
onWheelCapture: y,
onTouchMoveCapture: S
}), document.addEventListener("wheel", g, k), document.addEventListener("touchmove", g, k), document.addEventListener("touchstart", d, k), function() {
P = P.filter(function(i) {
return i !== c;
}), document.removeEventListener("wheel", m, k), document.removeEventListener("touchmove", m, k), document.removeEventListener("touchstart", d, k);
}), document.removeEventListener("wheel", g, k), document.removeEventListener("touchmove", g, k), document.removeEventListener("touchstart", d, k);
};
}, []);
var h = e.removeScrollBar, S = e.inert;
var h = e.removeScrollBar, w = e.inert;
return l.createElement(
l.Fragment,
null,
S ? l.createElement(c, { styles: We(a) }) : null,
w ? l.createElement(c, { styles: We(a) }) : null,
h ? l.createElement(Le, { gapMode: e.gapMode }) : null

@@ -482,7 +482,7 @@ );

var re = l.forwardRef(function(e, t) {
return l.createElement(W, C({}, e, { ref: t, sideCar: Ye }));
return l.createElement(W, E({}, e, { ref: t, sideCar: Ye }));
});
re.classNames = W.classNames;
const ze = ae.forwardRef((e, t) => {
const [n, r] = L(!1), [a, c] = L(!1), [u, o] = L({ label: "", value: "" }), [m, p] = L(""), [d, b] = L(), { data: y, ...h } = e, S = H(null), i = H(null);
const [n, r] = L(!1), [a, c] = L(!1), [u, o] = L({ label: "", value: "" }), [g, b] = L(""), [d, y] = L(), { data: S, ...h } = e, w = H(null), i = H(null);
z(() => {

@@ -493,16 +493,16 @@ if (a) {

}
if (d != null && d.length && m && b(void 0), y && typeof y == "function") {
const f = y(m.toLowerCase());
if (d != null && d.length && g && y(void 0), S && typeof S == "function") {
const f = S(g);
if (f instanceof Promise) {
f.then((v) => {
b(v);
y(v);
});
return;
}
b(f);
} else y && b(y);
y(f);
} else S && y(S);
}, [a]);
const s = (f) => {
const v = f.target;
S.current && !S.current.contains(v) && i.current && !i.current.contains(v) && r(!1);
w.current && !w.current.contains(v) && i.current && !i.current.contains(v) && r(!1);
};

@@ -515,3 +515,3 @@ return z(() => (document.addEventListener("mousedown", s), () => {

{
ref: S,
ref: w,
onFocus: () => r(!0),

@@ -522,3 +522,5 @@ className: "p-2 bg-gray-200 cursor-pointer focus:cursor-text",

onChange: (f) => {
p(f.target.value), c(!0), h.onChange && h.onChange(f);
var p;
const v = ((p = d == null ? void 0 : d.find((C) => C.value.toLowerCase() === f.target.value.toLowerCase())) == null ? void 0 : p.value) ?? u.value;
b(f.target.value.toLowerCase()), o({ label: f.target.value, value: v }), c(!0), h.onChange && h.onChange(f);
},

@@ -543,3 +545,3 @@ placeholder: h.placeholder,

),
n && d && d.length > 0 && /* @__PURE__ */ B(re, { children: /* @__PURE__ */ B("div", { ref: i, className: "absolute z-10 w-full bg-white border border-gray-300 rounded mt-1", children: d.filter((f) => String(f.label).toLowerCase().indexOf(m.toLowerCase() ?? "") > -1).map((f, v) => /* @__PURE__ */ B("div", { className: "p-2 cursor-pointer hover:bg-gray-100", onClick: () => {
n && d && d.length > 0 && /* @__PURE__ */ B(re, { children: /* @__PURE__ */ B("div", { ref: i, className: "absolute z-10 w-full bg-white border border-gray-300 rounded mt-1", children: d.filter((f) => f.label.toLowerCase().indexOf(g ?? "") > -1).map((f, v) => /* @__PURE__ */ B("div", { className: "p-2 cursor-pointer hover:bg-gray-100", onClick: () => {
o(f), r(!1);

@@ -546,0 +548,0 @@ }, children: f.label }, v)) }) })

@@ -1,2 +0,2 @@

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

@@ -38,5 +38,5 @@ overflow: hidden `).concat(r,`;

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

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

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