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.2 to 0.1.3

22

dist/index.es.js

@@ -13,3 +13,3 @@ import { jsxs as ne, jsx as B } from "react/jsx-runtime";

};
function G(e, t) {
function U(e, t) {
var n = {};

@@ -135,4 +135,4 @@ for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);

}
var U = function(e) {
var t = e.sideCar, n = G(e, ["sideCar"]);
var $ = function(e) {
var t = e.sideCar, n = U(e, ["sideCar"]);
if (!t)

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

};
U.isSideCarExport = !0;
$.isSideCarExport = !0;
function he(e, t) {
return e.useMedium(t), U;
return e.useMedium(t), $;
}

@@ -156,3 +156,3 @@ var q = ve(), V = function() {

onTouchMoveCapture: V
}), 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);
}), 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 = U(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(

@@ -374,3 +374,3 @@ l.Fragment,

return [e.deltaX, e.deltaY];
}, $ = function(e) {
}, G = function(e) {
return e && "current" in e ? e.current : e;

@@ -392,3 +392,3 @@ }, Ae = function(e, t) {

document.body.classList.add("block-interactivity-".concat(a));
var i = oe([e.lockRef.current], (e.shards || []).map($), !0).filter(Boolean);
var i = oe([e.lockRef.current], (e.shards || []).map(G), !0).filter(Boolean);
return i.forEach(function(s) {

@@ -429,3 +429,3 @@ return s.classList.add("allow-interactivity-".concat(a));

if (!v) {
var p = (u.current.shards || []).map($).filter(Boolean).filter(function(m) {
var p = (u.current.shards || []).map(G).filter(Boolean).filter(function(m) {
return m.contains(s.target);

@@ -524,4 +524,4 @@ }), C = p.length > 0 ? o(s, p[0]) : !u.current.noIsolation;

{
id: `${h.name}-id`,
name: `${h.name}-id`,
id: h.name,
name: h.name,
onChange: h.onChange,

@@ -528,0 +528,0 @@ onBlur: h.onBlur,

@@ -38,5 +38,5 @@ (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"),`

}
`)},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`
`)},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"},q=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!xe(e)&&n[t]==="visible")},Le=function(e){return q(e,"overflowY")},Re=function(e){return q(e,"overflowX")},G=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=U(e,r);if(a){var c=$(e,r),u=c[1],o=c[2];if(u>o)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Te=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Ne=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},U=function(e,t){return e==="v"?Le(t):Re(t)},$=function(e,t){return e==="v"?Te(t):Ne(t)},Oe=function(e,t){return e==="h"&&t==="rtl"?-1:1},Me=function(e,t,n,r,a){var c=Oe(e,window.getComputedStyle(t).direction),u=c*r,o=n.target,g=t.contains(o),b=!1,d=u>0,S=0,w=0;do{var h=$(e,o),C=h[0],i=h[1],s=h[2],f=i-s-c*C;(C||f)&&U(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,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"})});
`)},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=G(O,N);if(!W)return!0;if(W?m=O:(m=O==="v"?"h":"v",W=G(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,name:h.name,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.2",
"version": "0.1.3",
"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