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.0.5 to 0.0.6

8

dist/components/SearchSelect.d.ts

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

import { default as React, ChangeEventHandler, FocusEventHandler } from 'react';
import { default as React } from 'react';
export interface SelectItem {

@@ -6,10 +6,6 @@ label: string;

}
export interface SelectProps {
export interface SelectProps extends React.InputHTMLAttributes<HTMLInputElement> {
data: SelectItem[] | ((search?: string) => SelectItem[]);
placeholder?: string;
name?: string;
onChange?: ChangeEventHandler<HTMLInputElement>;
onBlur?: FocusEventHandler<HTMLInputElement>;
}
declare const SearchSelect: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLInputElement>>;
export default SearchSelect;

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

import { jsxs as ne, jsx as B } from "react/jsx-runtime";
import { jsxs as ne, jsx as M } from "react/jsx-runtime";
import * as l from "react";

@@ -298,3 +298,3 @@ import ae, { useState as x, useRef as H, useEffect as z } from "react";

try {
var T = Object.defineProperty({}, "passive", {
var B = Object.defineProperty({}, "passive", {
get: function() {

@@ -304,3 +304,3 @@ return D = !0, !0;

});
window.addEventListener("test", T, T), window.removeEventListener("test", T, T);
window.addEventListener("test", B, B), window.removeEventListener("test", B, B);
} catch {

@@ -322,3 +322,3 @@ D = !1;

return K(e, "overflowY");
}, Be = function(e) {
}, Me = function(e) {
return K(e, "overflowX");

@@ -338,3 +338,3 @@ }, Z = function(e, t) {

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

@@ -346,3 +346,3 @@ return [

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

@@ -355,5 +355,5 @@ return [

}, ee = function(e, t) {
return e === "v" ? Ne(t) : Be(t);
return e === "v" ? Ne(t) : Me(t);
}, te = function(e, t) {
return e === "v" ? Me(t) : Te(t);
return e === "v" ? Te(t) : Be(t);
}, Oe = function(e, t) {

@@ -409,6 +409,6 @@ return e === "h" && t === "rtl" ? -1 : 1;

return !1;
var M = Z(N, R);
if (!M)
var T = Z(N, R);
if (!T)
return !0;
if (M ? v = N : (v = N === "v" ? "h" : "v", M = Z(N, R)), !M)
if (T ? v = N : (v = N === "v" ? "h" : "v", T = Z(N, R)), !T)
return !1;

@@ -504,3 +504,3 @@ if (!r.current && "changedTouches" in a && (b || E) && (r.current = v), !v)

}), []), /* @__PURE__ */ ne("div", { children: [
/* @__PURE__ */ B(
/* @__PURE__ */ M(
"input",

@@ -512,12 +512,12 @@ {

type: "text",
disabled: e.disabled,
placeholder: e.placeholder,
onBlur: e.onBlur,
value: (u == null ? void 0 : u.label) || d,
onChange: (a) => {
h(a.target.value.toLowerCase()), i(!0), e.onChange && e.onChange(a);
h(a.target.value.toLowerCase()), i(!0);
}
}
),
/* @__PURE__ */ B("input", { ref: t, name: e.name, disabled: !0, className: "hidden", type: "text", value: u == null ? void 0 : u.value }),
n && f && f.length > 0 && /* @__PURE__ */ B(re, { children: /* @__PURE__ */ B("div", { ref: y, className: "absolute z-10 w-full bg-white border border-gray-300 rounded mt-1", children: f.filter((a) => String(a.label).toLowerCase().indexOf(d ?? "") > -1).map((a, s) => /* @__PURE__ */ B("div", { className: "p-2 cursor-pointer hover:bg-gray-100", onClick: () => {
/* @__PURE__ */ M("input", { ref: t, ...e, disabled: !0, className: "hidden", type: "text", value: (u == null ? void 0 : u.value) ?? "" }),
n && f && f.length > 0 && /* @__PURE__ */ M(re, { children: /* @__PURE__ */ M("div", { ref: y, className: "absolute z-10 w-full bg-white border border-gray-300 rounded mt-1", children: f.filter((a) => String(a.label).toLowerCase().indexOf(d ?? "") > -1).map((a, s) => /* @__PURE__ */ M("div", { className: "p-2 cursor-pointer hover:bg-gray-100", onClick: () => {
c(a), r(!1);

@@ -524,0 +524,0 @@ }, children: a.label }, s)) }) })

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

(function(x,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],p):(x=typeof globalThis<"u"?globalThis:x||self,p(x["simple-search-dropdown"]={},x["react/jsx-runtime"],x.React))})(this,function(x,p,g){"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 u=re(g);var w=function(){return w=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},w.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 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 ne(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||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=g.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var ie=typeof window<"u"?u.useLayoutEffect:u.useEffect,H=new WeakMap;function ue(e,t){var n=ce(null,function(r){return e.forEach(function(o){return D(o,r)})});return ie(function(){var r=H.get(n);if(r){var o=new Set(r),i=new Set(e),l=n.current;o.forEach(function(c){i.has(c)||D(c,null)}),i.forEach(function(c){o.has(c)||D(c,l)})}H.set(n,e)},[e]),n}function le(e){return e}function se(e,t){t===void 0&&(t=le);var n=[],r=!1,o={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(i){var l=t(i,r);return n.push(l),function(){n=n.filter(function(c){return c!==l})}},assignSyncMedium:function(i){for(r=!0;n.length;){var l=n;n=[],l.forEach(i)}n={push:function(c){return i(c)},filter:function(){return n}}},assignMedium:function(i){r=!0;var l=[];if(n.length){var c=n;n=[],c.forEach(i),l=n}var d=function(){var f=l;l=[],f.forEach(i)},h=function(){return Promise.resolve().then(d)};h(),n={push:function(f){l.push(f),h()},filter:function(f){return l=l.filter(f),n}}}};return o}function fe(e){e===void 0&&(e={});var t=se(null);return t.options=w({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 u.createElement(r,w({},n))};_.isSideCarExport=!0;function de(e,t){return e.useMedium(t),_}var F=fe(),X=function(){},j=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:X,onWheelCapture:X,onTouchMoveCapture:X}),o=r[0],i=r[1],l=e.forwardProps,c=e.children,d=e.className,h=e.removeScrollBar,f=e.enabled,m=e.shards,C=e.sideCar,S=e.noIsolation,E=e.inert,a=e.allowPinchZoom,s=e.as,y=s===void 0?"div":s,k=e.gapMode,b=z(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=C,v=ue([n,t]),N=w(w({},b),o);return u.createElement(u.Fragment,null,f&&u.createElement(P,{sideCar:F,removeScrollBar:h,shards:m,noIsolation:S,inert:E,setCallbacks:i,allowPinchZoom:!!a,lockRef:n,gapMode:k}),l?u.cloneElement(u.Children.only(c),w(w({},N),{ref:v})):u.createElement(y,w({},N,{className:d,ref:v}),c))});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 ye=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)}}},Se=function(){var e=ye();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Z=function(){var e=Se(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},be={left:0,top:0,right:0,gap:0},Y=function(e){return parseInt(e||"",10)||0},pe=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[Y(n),Y(r),Y(o)]},we=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return be;var t=pe(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 o=e.left,i=e.top,l=e.right,c=e.gap;return n===void 0&&(n="margin"),`
(function(x,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],p):(x=typeof globalThis<"u"?globalThis:x||self,p(x["simple-search-dropdown"]={},x["react/jsx-runtime"],x.React))})(this,function(x,p,g){"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 u=re(g);var w=function(){return w=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},w.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 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 ne(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var M="right-scroll-bar-position",j="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=g.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var ie=typeof window<"u"?u.useLayoutEffect:u.useEffect,H=new WeakMap;function ue(e,t){var n=ce(null,function(r){return e.forEach(function(o){return D(o,r)})});return ie(function(){var r=H.get(n);if(r){var o=new Set(r),i=new Set(e),l=n.current;o.forEach(function(c){i.has(c)||D(c,null)}),i.forEach(function(c){o.has(c)||D(c,l)})}H.set(n,e)},[e]),n}function le(e){return e}function se(e,t){t===void 0&&(t=le);var n=[],r=!1,o={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(i){var l=t(i,r);return n.push(l),function(){n=n.filter(function(c){return c!==l})}},assignSyncMedium:function(i){for(r=!0;n.length;){var l=n;n=[],l.forEach(i)}n={push:function(c){return i(c)},filter:function(){return n}}},assignMedium:function(i){r=!0;var l=[];if(n.length){var c=n;n=[],c.forEach(i),l=n}var d=function(){var f=l;l=[],f.forEach(i)},h=function(){return Promise.resolve().then(d)};h(),n={push:function(f){l.push(f),h()},filter:function(f){return l=l.filter(f),n}}}};return o}function fe(e){e===void 0&&(e={});var t=se(null);return t.options=w({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 u.createElement(r,w({},n))};_.isSideCarExport=!0;function de(e,t){return e.useMedium(t),_}var F=fe(),X=function(){},B=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:X,onWheelCapture:X,onTouchMoveCapture:X}),o=r[0],i=r[1],l=e.forwardProps,c=e.children,d=e.className,h=e.removeScrollBar,f=e.enabled,m=e.shards,C=e.sideCar,S=e.noIsolation,E=e.inert,a=e.allowPinchZoom,s=e.as,y=s===void 0?"div":s,k=e.gapMode,b=z(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=C,v=ue([n,t]),N=w(w({},b),o);return u.createElement(u.Fragment,null,f&&u.createElement(P,{sideCar:F,removeScrollBar:h,shards:m,noIsolation:S,inert:E,setCallbacks:i,allowPinchZoom:!!a,lockRef:n,gapMode:k}),l?u.cloneElement(u.Children.only(c),w(w({},N),{ref:v})):u.createElement(y,w({},N,{className:d,ref:v}),c))});B.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},B.classNames={fullWidth:j,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 ye=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)}}},Se=function(){var e=ye();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Z=function(){var e=Se(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},be={left:0,top:0,right:0,gap:0},Y=function(e){return parseInt(e||"",10)||0},pe=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[Y(n),Y(r),Y(o)]},we=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return be;var t=pe(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 o=e.left,i=e.top,l=e.right,c=e.gap;return n===void 0&&(n="margin"),`
.`.concat(ae,` {

@@ -23,3 +23,3 @@ overflow: hidden `).concat(r,`;

.`).concat(B,` {
.`).concat(j,` {
margin-right: `).concat(c,"px ").concat(r,`;

@@ -32,3 +32,3 @@ }

.`).concat(B," .").concat(B,` {
.`).concat(j," .").concat(j,` {
margin-right: 0 `).concat(r,`;

@@ -40,5 +40,5 @@ }

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