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

@nylas/components-contacts-search

Package Overview
Dependencies
Maintainers
5
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nylas/components-contacts-search - npm Package Compare versions

Comparing version 0.0.19-alpha.0 to 0.0.20-alpha.0

2

index.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).app=e()}(this,(function(){"use strict";function t(){}function e(t){return t()}function n(){return Object.create(null)}function o(t){t.forEach(e)}function r(t){return"function"==typeof t}function i(t,e){return t!=t?e==e:t!==e}function c(t,e){t.appendChild(e)}function l(t,e,n){t.insertBefore(e,n||null)}function a(t){t.parentNode.removeChild(t)}function s(t){return document.createElement(t)}function u(t){return document.createTextNode(t)}function d(){return u(" ")}function f(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function m(t){return function(e){return e.preventDefault(),t.call(this,e)}}function p(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function h(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function g(t,e){t.value=null==e?"":e}function y(t){const e={};for(const n of t)e[n.name]=n.value;return e}let $;function v(t){$=t}const b=[],x=[],w=[],k=[],_=Promise.resolve();let C=!1;function E(){C||(C=!0,_.then(z))}function T(t){w.push(t)}let A=!1;const L=new Set;function z(){if(!A){A=!0;do{for(let t=0;t<b.length;t+=1){const e=b[t];v(e),M(e.$$)}for(v(null),b.length=0;x.length;)x.pop()();for(let t=0;t<w.length;t+=1){const e=w[t];L.has(e)||(L.add(e),e())}w.length=0}while(b.length);for(;k.length;)k.pop()();C=!1,A=!1,L.clear()}}function M(t){if(null!==t.fragment){t.update(),o(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(T)}}const j=new Set;function N(t,e){t&&t.i&&(j.delete(t),t.i(e))}function S(t,e){t.d(1),e.delete(t.key)}function O(i,c,l,s,u,d,f=[-1]){const m=$;v(i);const p=c.props||{},h=i.$$={fragment:null,ctx:null,props:d,update:t,not_equal:u,bound:n(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(m?m.$$.context:[]),callbacks:n(),dirty:f,skip_bound:!1};let g=!1;if(h.ctx=l?l(i,p,((t,e,...n)=>{const o=n.length?n[0]:e;return h.ctx&&u(h.ctx[t],h.ctx[t]=o)&&(!h.skip_bound&&h.bound[t]&&h.bound[t](o),g&&function(t,e){-1===t.$$.dirty[0]&&(b.push(t),E(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}(i,t)),e})):[],h.update(),g=!0,o(h.before_update),h.fragment=!!s&&s(h.ctx),c.target){if(c.hydrate){const t=function(t){return Array.from(t.childNodes)}(c.target);h.fragment&&h.fragment.l(t),t.forEach(a)}else h.fragment&&h.fragment.c();c.intro&&N(i.$$.fragment),function(t,n,i){const{fragment:c,on_mount:l,on_destroy:a,after_update:s}=t.$$;c&&c.m(n,i),T((()=>{const n=l.map(e).filter(r);a?a.push(...n):o(n),t.$$.on_mount=[]})),s.forEach(T)}(i,c.target,c.anchor),z()}v(m)}let H;"function"==typeof HTMLElement&&(H=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(t,e,n){this[t]=n}$destroy(){!function(t,e){const n=t.$$;null!==n.fragment&&(o(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});var B=t=>{const e=[];return Object.keys(t).forEach((n=>{t[n]&&e.push(n)})),e.join(" ")};function D(t,e,n){const o=t.slice();return o[35]=e[n],o[37]=n,o}function P(t,e,n){const o=t.slice();return o[35]=e[n],o}function R(t){let e,n=t[35].email+"";return{c(){e=u(n)},m(t,n){l(t,e,n)},p(t,o){4&o[0]&&n!==(n=t[35].email+"")&&h(e,n)},d(t){t&&a(e)}}}function q(t){let e,n,o,r,i=t[35].name+"",f=`<${t[35].email}>`;return{c(){e=s("strong"),n=u(i),o=d(),r=u(f)},m(t,i){l(t,e,i),c(e,n),l(t,o,i),l(t,r,i)},p(t,e){4&e[0]&&i!==(i=t[35].name+"")&&h(n,i),4&e[0]&&f!==(f=`<${t[35].email}>`)&&h(r,f)},d(t){t&&a(e),t&&a(o),t&&a(r)}}}function U(t,e){let n,o,r,i,u,m,h;function g(t,e){return t[35].name?q:R}let y=g(e),$=y(e);function v(){return e[21](e[35])}return{key:t,first:null,c(){n=s("div"),o=s("span"),$.c(),r=d(),i=s("button"),i.textContent="×",u=d(),p(o,"class","contact-item__name"),p(i,"type","button"),p(i,"name","term"),p(n,"class","contact-item"),this.first=n},m(t,e){l(t,n,e),c(n,o),$.m(o,null),c(n,r),c(n,i),c(n,u),m||(h=f(i,"click",v),m=!0)},p(t,n){y===(y=g(e=t))&&$?$.p(e,n):($.d(1),$=y(e),$&&($.c(),$.m(o,null)))},d(t){t&&a(n),$.d(),m=!1,h()}}}function F(t){let e,n,r,i;return{c(){e=s("form"),n=s("input"),p(n,"type","text"),p(n,"name","email"),p(n,"autocomplete","off"),p(n,"class","search-field"),p(e,"class","search-form")},m(o,a){l(o,e,a),c(e,n),t[24](n),g(n,t[3]),r||(i=[f(n,"keydown",t[14]),f(n,"blur",t[13]),f(n,"input",t[25]),f(e,"submit",m(t[16]))],r=!0)},p(t,e){8&e[0]&&n.value!==t[3]&&g(n,t[3])},d(n){n&&a(e),t[24](null),r=!1,o(i)}}}function G(t){let e,n,r,i;return{c(){e=s("form"),n=s("input"),p(n,"type","text"),p(n,"name","email"),p(n,"autocomplete","off"),p(n,"class","search-field"),p(e,"class","search-form")},m(o,a){l(o,e,a),c(e,n),t[22](n),g(n,t[3]),r||(i=[f(n,"keydown",t[14]),f(n,"blur",t[13]),f(n,"input",t[23]),f(e,"submit",m(t[16]))],r=!0)},p(t,e){8&e[0]&&n.value!==t[3]&&g(n,t[3])},d(n){n&&a(e),t[22](null),r=!1,o(i)}}}function I(t){let e,n,o=t[5]&&!t[9].length&&J();function r(t,e){return t[5]||t[9].length?K:Q}let i=r(t),u=i(t);return{c(){e=s("div"),o&&o.c(),n=d(),u.c(),p(e,"class","dropdown-content")},m(t,r){l(t,e,r),o&&o.m(e,null),c(e,n),u.m(e,null)},p(t,c){t[5]&&!t[9].length?o||(o=J(),o.c(),o.m(e,n)):o&&(o.d(1),o=null),i===(i=r(t))&&u?u.p(t,c):(u.d(1),u=i(t),u&&(u.c(),u.m(e,null)))},d(t){t&&a(e),o&&o.d(),u.d()}}}function J(t){let e;return{c(){e=s("p"),e.textContent="Loading...",p(e,"class","dropdown-item")},m(t,n){l(t,e,n)},d(t){t&&a(e)}}}function K(t){let e,n=t[9],o=[];for(let e=0;e<n.length;e+=1)o[e]=X(D(t,n,e));return{c(){for(let t=0;t<o.length;t+=1)o[t].c();e=u("")},m(t,n){for(let e=0;e<o.length;e+=1)o[e].m(t,n);l(t,e,n)},p(t,r){if(166416&r[0]){let i;for(n=t[9],i=0;i<n.length;i+=1){const c=D(t,n,i);o[i]?o[i].p(c,r):(o[i]=X(c),o[i].c(),o[i].m(e.parentNode,e))}for(;i<o.length;i+=1)o[i].d(1);o.length=n.length}},d(t){!function(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}(o,t),t&&a(e)}}}function Q(e){let n;return{c(){n=s("p"),n.textContent="No results found",p(n,"class","dropdown-item")},m(t,e){l(t,n,e)},p:t,d(t){t&&a(n)}}}function V(t){let e,n,o=t[35].email+"";return{c(){e=s("div"),n=u(o),p(e,"class","dropdown-item__name")},m(t,o){l(t,e,o),c(e,n)},p(t,e){512&e[0]&&o!==(o=t[35].email+"")&&h(n,o)},d(t){t&&a(e)}}}function W(t){let e,n,o,r,i,f=t[35].name+"",m=t[35].email+"";return{c(){e=s("div"),n=u(f),o=d(),r=s("div"),i=u(m),p(e,"class","dropdown-item__name"),p(r,"class","dropdown-item__email")},m(t,a){l(t,e,a),c(e,n),l(t,o,a),l(t,r,a),c(r,i)},p(t,e){512&e[0]&&f!==(f=t[35].name+"")&&h(n,f),512&e[0]&&m!==(m=t[35].email+"")&&h(i,m)},d(t){t&&a(e),t&&a(o),t&&a(r)}}}function X(t){let e,n,r,i,u;function m(t,e){return t[35].name?W:V}let h=m(t),g=h(t);function y(){return t[26](t[35])}function $(){return t[27](t[37])}return{c(){e=s("div"),g.c(),n=d(),p(e,"class",r=B({"dropdown-item":!0,active:t[4]===t[37],selected:t[17](t[35].email)}))},m(t,o){l(t,e,o),g.m(e,null),c(e,n),i||(u=[f(e,"mousedown",y),f(e,"mouseenter",$)],i=!0)},p(o,i){h===(h=m(t=o))&&g?g.p(t,i):(g.d(1),g=h(t),g&&(g.c(),g.m(e,n))),528&i[0]&&r!==(r=B({"dropdown-item":!0,active:t[4]===t[37],selected:t[17](t[35].email)}))&&p(e,"class",r)},d(t){t&&a(e),g.d(),i=!1,o(u)}}}function Y(e){let n,o,r,i,m,g,y,$,v,b,x,w=[],k=new Map,_=e[2];const C=t=>t[35].email;for(let t=0;t<_.length;t+=1){let n=P(e,_,t),o=C(n);k.set(o,w[t]=U(o,n))}function E(t,e){return t[1]&&!t[2].length?G:t[1]?void 0:F}let T=E(e),A=T&&T(e),L=e[8]&&I(e);return{c(){n=s("div"),o=s("div"),r=s("div"),i=s("div"),m=u(e[0]),g=d(),y=s("div");for(let t=0;t<w.length;t+=1)w[t].c();$=d(),A&&A.c(),v=d(),L&&L.c(),this.c=t,p(i,"class","contacts-placeholder"),p(y,"class","contacts-results-inner"),p(r,"class","contacts-results"),p(o,"class","contacts-container"),p(n,"class","dropdown")},m(t,a){l(t,n,a),c(n,o),c(o,r),c(r,i),c(i,m),c(r,g),c(r,y);for(let t=0;t<w.length;t+=1)w[t].m(y,null);c(o,$),A&&A.m(o,null),c(n,v),L&&L.m(n,null),e[28](n),b||(x=f(o,"click",e[12]),b=!0)},p(t,e){if(1&e[0]&&h(m,t[0]),1028&e[0]){const n=t[2];w=function(t,e,n,o,r,i,c,l,a,s,u,d){let f=t.length,m=i.length,p=f;const h={};for(;p--;)h[t[p].key]=p;const g=[],y=new Map,$=new Map;for(p=m;p--;){const t=d(r,i,p),l=n(t);let a=c.get(l);a?o&&a.p(t,e):(a=s(l,t),a.c()),y.set(l,g[p]=a),l in h&&$.set(l,Math.abs(p-h[l]))}const v=new Set,b=new Set;function x(t){N(t,1),t.m(l,u),c.set(t.key,t),u=t.first,m--}for(;f&&m;){const e=g[m-1],n=t[f-1],o=e.key,r=n.key;e===n?(u=e.first,f--,m--):y.has(r)?!c.has(o)||v.has(o)?x(e):b.has(r)?f--:$.get(o)>$.get(r)?(b.add(o),x(e)):(v.add(r),f--):(a(n,c),f--)}for(;f--;){const e=t[f];y.has(e.key)||a(e,c)}for(;m;)x(g[m-1]);return g}(w,e,C,1,t,n,k,y,S,U,null,P)}T===(T=E(t))&&A?A.p(t,e):(A&&A.d(1),A=T&&T(t),A&&(A.c(),A.m(o,null))),t[8]?L?L.p(t,e):(L=I(t),L.c(),L.m(n,null)):L&&(L.d(1),L=null)},i:t,o:t,d(t){t&&a(n);for(let t=0;t<w.length;t+=1)w[t].d();A&&A.d(),L&&L.d(),e[28](null),b=!1,x()}}}function Z(t,e,n){var o=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function c(t){try{a(o.next(t))}catch(t){i(t)}}function l(t){try{a(o.throw(t))}catch(t){i(t)}}function a(t){t.done?r(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(c,l)}a((o=o.apply(t,e||[])).next())}))};let r,i,{contacts:c}=e,{value:l=[]}=e,{placeholder:a="To"}=e,{single:s=!1}=e,{change:u}=e,d=[],f="",m=0,p=!1,h=[],g=!1;const y=()=>[],$=((t,e)=>{let n;return function(...o){clearTimeout(n),n=setTimeout((()=>{clearTimeout(n),t(...o)}),e)}})((t=>o(void 0,void 0,void 0,(function*(){n(5,p=!0);const e="function"==typeof c?c:y;try{n(29,h=yield e(t)),n(5,p=!1)}catch(t){n(5,p=!1)}}))),350),v=t=>{n(2,d=d.filter((e=>e.email!==t))),w()},b=t=>{s&&1===d.length||(T(t.email)||n(2,d=[...d,t]),w())},w=()=>{r&&(r.focus(),n(8,g=!0))},k=(t=500)=>{setTimeout((()=>{n(8,g=!1),n(3,f=""),r&&r.blur()}),t)},C=t=>{n(4,m=t)},T=t=>d.map((t=>t.email)).includes(t);let A;return t.$$set=t=>{"contacts"in t&&n(18,c=t.contacts),"value"in t&&n(19,l=t.value),"placeholder"in t&&n(0,a=t.placeholder),"single"in t&&n(1,s=t.single),"change"in t&&n(20,u=t.change)},t.$$.update=()=>{1048580&t.$$.dirty[0]&&d&&u&&(E(),_).then((()=>{u(d)})),786432&t.$$.dirty[0]&&(c||l)&&(Array.isArray(c)&&n(29,h=c),l&&l.length&&n(2,d=l)),262408&t.$$.dirty[0]&&g&&"function"==typeof c&&(t=>{n(5,p=!0),n(29,h=[]),$(t)})(f),536870920&t.$$.dirty[0]&&n(9,A=h.filter((t=>{const e=f?f.toLowerCase():"",n=t.name?t.name.toLowerCase():"",o=t.email?t.email.toLowerCase():"",r=n.includes(e),i=o.includes(e);return(r||i)&&!T(t.email)}))),512&t.$$.dirty[0]&&A&&n(4,m=0)},[a,s,d,f,m,p,r,i,g,A,v,b,w,k,t=>{w(),"Backspace"===t.key&&d.length&&!f&&n(2,d=d.slice(0,d.length-1)),"ArrowDown"===t.key&&h.length&&m<=h.length&&n(4,m+=1),"ArrowUp"===t.key&&h.length&&0!=m&&n(4,m-=1),"Escape"===t.key&&h.length&&k()},C,()=>{s&&1===d.length||(A.length&&(T(A[m].email)||(n(2,d=[...d,A[m]]),n(4,m=0),k(0))),!T(f)&&f&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f)&&(n(2,d=[...d,{email:f}]),n(4,m=0),k(0)))},T,c,l,u,t=>v(t.email),function(t){x[t?"unshift":"push"]((()=>{r=t,n(6,r)}))},function(){f=this.value,n(3,f)},function(t){x[t?"unshift":"push"]((()=>{r=t,n(6,r)}))},function(){f=this.value,n(3,f)},t=>b(t),t=>C(t),function(t){x[t?"unshift":"push"]((()=>{i=t,n(7,i)}))}]}class tt extends H{constructor(t){super(),this.shadowRoot.innerHTML="<style>.nylas-contacts{--background:white;--text:black;--text-light:#6e6e7a;--font:sans-serif;--font-size:14px;--border:#f7f7f7}:root{font-family:sans-serif}.contacts-container{display:flex;align-items:center;flex-wrap:wrap;padding:0.4rem var(--outer-padding);border-bottom:1px solid var(--border)}.contacts-container>div{padding-bottom:0.1rem;padding-right:0.1rem}.contact-item{display:inline-flex;background:var(--primary-light);color:var(--primary);align-items:center;border-radius:calc(var(--border-radius) / 2);padding:0.2rem 0.8rem;margin-right:0.25rem;margin-top:2px;margin-bottom:2px}.contact-item>button{color:var(--text-secondary);border:none;background:none;padding:0;font-weight:bold;font-size:13px;cursor:pointer}.contact-item__name{color:var(--text-secondary);font-size:12px;padding-right:0.75rem}.dropdown{width:100%;position:relative;display:inline-block}.dropdown-content{display:block;position:absolute;max-height:350px;background:var(--background);left:calc(var(--outer-padding) / 2);right:calc(var(--outer-padding) / 2);overflow-y:auto;color:var(--text);box-shadow:var(--shadow);z-index:1;border-radius:calc(var(--border-radius) / 2)}.dropdown-item{cursor:pointer;padding:var(--outer-padding);font-size:var(--font-size-small)}.dropdown-item.active{background-color:var(--primary);color:white}.dropdown-item.active .dropdown-item__email{color:var(--bg) !important}.dropdown-item.selected{opacity:0.3}.dropdown-item__name{font-weight:bold;display:inline-flex}.dropdown-item__email{color:var(--text-light);display:inline-flex;margin-left:0.25rem}.search-field{border:none;color:var(--text);background:var(--bg);width:1px}.search-field:focus{width:100px;outline:none}.search-form{display:flex;padding-top:0.5rem;padding-bottom:0.5rem;align-items:center}.contacts-results{display:flex;align-items:center}.contacts-placeholder{font-size:var(--font-size-small);margin-right:10px;min-width:30px;display:flex;color:var(--text-light)}</style>",O(this,{target:this.shadowRoot,props:y(this.attributes)},Z,Y,i,{contacts:18,value:19,placeholder:0,single:1,change:20},[-1,-1]),t&&(t.target&&l(t.target,this,t.anchor),t.props&&(this.$set(t.props),z()))}static get observedAttributes(){return["contacts","value","placeholder","single","change"]}get contacts(){return this.$$.ctx[18]}set contacts(t){this.$set({contacts:t}),z()}get value(){return this.$$.ctx[19]}set value(t){this.$set({value:t}),z()}get placeholder(){return this.$$.ctx[0]}set placeholder(t){this.$set({placeholder:t}),z()}get single(){return this.$$.ctx[1]}set single(t){this.$set({single:t}),z()}get change(){return this.$$.ctx[20]}set change(t){this.$set({change:t}),z()}}return customElements.define("nylas-contacts-search",tt),tt}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).app=e()}(this,(function(){"use strict";function t(){}function e(t){return t()}function n(){return Object.create(null)}function o(t){t.forEach(e)}function r(t){return"function"==typeof t}function i(t,e){return t!=t?e==e:t!==e}function c(t,e){t.appendChild(e)}function l(t,e,n){t.insertBefore(e,n||null)}function a(t){t.parentNode.removeChild(t)}function s(t){return document.createElement(t)}function u(t){return document.createTextNode(t)}function d(){return u(" ")}function f(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function m(t){return function(e){return e.preventDefault(),t.call(this,e)}}function p(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function h(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function g(t,e){t.value=null==e?"":e}function $(t,e,n){t.classList[n?"add":"remove"](e)}function y(t){const e={};for(const n of t)e[n.name]=n.value;return e}let v;function b(t){v=t}const x=[],w=[],_=[],k=[],C=Promise.resolve();let T=!1;function E(){T||(T=!0,C.then(z))}function L(t){_.push(t)}let A=!1;const M=new Set;function z(){if(!A){A=!0;do{for(let t=0;t<x.length;t+=1){const e=x[t];b(e),N(e.$$)}for(b(null),x.length=0;w.length;)w.pop()();for(let t=0;t<_.length;t+=1){const e=_[t];M.has(e)||(M.add(e),e())}_.length=0}while(x.length);for(;k.length;)k.pop()();T=!1,A=!1,M.clear()}}function N(t){if(null!==t.fragment){t.update(),o(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(L)}}const S=new Set;function j(t,e){t&&t.i&&(S.delete(t),t.i(e))}function H(t,e){t.d(1),e.delete(t.key)}function I(i,c,l,s,u,d,f=[-1]){const m=v;b(i);const p=c.props||{},h=i.$$={fragment:null,ctx:null,props:d,update:t,not_equal:u,bound:n(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(m?m.$$.context:[]),callbacks:n(),dirty:f,skip_bound:!1};let g=!1;if(h.ctx=l?l(i,p,((t,e,...n)=>{const o=n.length?n[0]:e;return h.ctx&&u(h.ctx[t],h.ctx[t]=o)&&(!h.skip_bound&&h.bound[t]&&h.bound[t](o),g&&function(t,e){-1===t.$$.dirty[0]&&(x.push(t),E(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}(i,t)),e})):[],h.update(),g=!0,o(h.before_update),h.fragment=!!s&&s(h.ctx),c.target){if(c.hydrate){const t=function(t){return Array.from(t.childNodes)}(c.target);h.fragment&&h.fragment.l(t),t.forEach(a)}else h.fragment&&h.fragment.c();c.intro&&j(i.$$.fragment),function(t,n,i){const{fragment:c,on_mount:l,on_destroy:a,after_update:s}=t.$$;c&&c.m(n,i),L((()=>{const n=l.map(e).filter(r);a?a.push(...n):o(n),t.$$.on_mount=[]})),s.forEach(L)}(i,c.target,c.anchor),z()}b(m)}let O;"function"==typeof HTMLElement&&(O=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(t,e,n){this[t]=n}$destroy(){!function(t,e){const n=t.$$;null!==n.fragment&&(o(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});function B(t,e,n){const o=t.slice();return o[37]=e[n],o[39]=n,o}function D(t,e,n){const o=t.slice();return o[37]=e[n],o}function P(t){let e,n=t[37].email+"";return{c(){e=u(n)},m(t,n){l(t,e,n)},p(t,o){4&o[0]&&n!==(n=t[37].email+"")&&h(e,n)},d(t){t&&a(e)}}}function R(t){let e,n,o,r,i=t[37].name+"",f=`<${t[37].email}>`;return{c(){e=s("strong"),n=u(i),o=d(),r=u(f)},m(t,i){l(t,e,i),c(e,n),l(t,o,i),l(t,r,i)},p(t,e){4&e[0]&&i!==(i=t[37].name+"")&&h(n,i),4&e[0]&&f!==(f=`<${t[37].email}>`)&&h(r,f)},d(t){t&&a(e),t&&a(o),t&&a(r)}}}function q(t,e){let n,o,r,i,u,m,h;function g(t,e){return t[37].name?R:P}let $=g(e),y=$(e);function v(){return e[21](e[37])}return{key:t,first:null,c(){n=s("div"),o=s("span"),y.c(),r=d(),i=s("button"),i.textContent="×",u=d(),p(o,"class","contact-item__name"),p(i,"type","button"),p(i,"name","term"),p(n,"class","contact-item"),this.first=n},m(t,e){l(t,n,e),c(n,o),y.m(o,null),c(n,r),c(n,i),c(n,u),m||(h=f(i,"click",v),m=!0)},p(t,n){$===($=g(e=t))&&y?y.p(e,n):(y.d(1),y=$(e),y&&(y.c(),y.m(o,null)))},d(t){t&&a(n),y.d(),m=!1,h()}}}function U(t){let e,n,r,i;return{c(){e=s("form"),n=s("input"),p(n,"type","text"),p(n,"name","email"),p(n,"autocomplete","off"),p(n,"class","search-field"),p(e,"class","search-form")},m(o,a){l(o,e,a),c(e,n),t[25](n),g(n,t[3]),r||(i=[f(n,"keydown",t[14]),f(n,"blur",t[26]),f(n,"input",t[27]),f(e,"submit",m(t[16]))],r=!0)},p(t,e){8&e[0]&&n.value!==t[3]&&g(n,t[3])},d(n){n&&a(e),t[25](null),r=!1,o(i)}}}function F(t){let e,n,r,i;return{c(){e=s("form"),n=s("input"),p(n,"type","text"),p(n,"name","email"),p(n,"autocomplete","off"),p(n,"class","search-field"),p(e,"class","search-form")},m(o,a){l(o,e,a),c(e,n),t[22](n),g(n,t[3]),r||(i=[f(n,"keydown",t[14]),f(n,"blur",t[23]),f(n,"input",t[24]),f(e,"submit",m(t[16]))],r=!0)},p(t,e){8&e[0]&&n.value!==t[3]&&g(n,t[3])},d(n){n&&a(e),t[22](null),r=!1,o(i)}}}function G(t){let e,n,o=t[5]&&!t[9].length&&J();function r(t,e){return t[5]||t[9].length?K:Q}let i=r(t),u=i(t);return{c(){e=s("div"),o&&o.c(),n=d(),u.c(),p(e,"class","dropdown-content")},m(t,r){l(t,e,r),o&&o.m(e,null),c(e,n),u.m(e,null)},p(t,c){t[5]&&!t[9].length?o||(o=J(),o.c(),o.m(e,n)):o&&(o.d(1),o=null),i===(i=r(t))&&u?u.p(t,c):(u.d(1),u=i(t),u&&(u.c(),u.m(e,null)))},d(t){t&&a(e),o&&o.d(),u.d()}}}function J(t){let e;return{c(){e=s("p"),e.textContent="Loading...",p(e,"class","dropdown-item")},m(t,n){l(t,e,n)},d(t){t&&a(e)}}}function K(t){let e,n=t[9],o=[];for(let e=0;e<n.length;e+=1)o[e]=X(B(t,n,e));return{c(){for(let t=0;t<o.length;t+=1)o[t].c();e=u("")},m(t,n){for(let e=0;e<o.length;e+=1)o[e].m(t,n);l(t,e,n)},p(t,r){if(166416&r[0]){let i;for(n=t[9],i=0;i<n.length;i+=1){const c=B(t,n,i);o[i]?o[i].p(c,r):(o[i]=X(c),o[i].c(),o[i].m(e.parentNode,e))}for(;i<o.length;i+=1)o[i].d(1);o.length=n.length}},d(t){!function(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}(o,t),t&&a(e)}}}function Q(e){let n;return{c(){n=s("p"),n.textContent="No results found",p(n,"class","dropdown-item")},m(t,e){l(t,n,e)},p:t,d(t){t&&a(n)}}}function V(t){let e,n,o=t[37].email+"";return{c(){e=s("div"),n=u(o),p(e,"class","dropdown-item__name")},m(t,o){l(t,e,o),c(e,n)},p(t,e){512&e[0]&&o!==(o=t[37].email+"")&&h(n,o)},d(t){t&&a(e)}}}function W(t){let e,n,o,r,i,f=t[37].name+"",m=t[37].email+"";return{c(){e=s("div"),n=u(f),o=d(),r=s("div"),i=u(m),p(e,"class","dropdown-item__name"),p(r,"class","dropdown-item__email")},m(t,a){l(t,e,a),c(e,n),l(t,o,a),l(t,r,a),c(r,i)},p(t,e){512&e[0]&&f!==(f=t[37].name+"")&&h(n,f),512&e[0]&&m!==(m=t[37].email+"")&&h(i,m)},d(t){t&&a(e),t&&a(o),t&&a(r)}}}function X(t){let e,n,r,i;function u(t,e){return t[37].name?W:V}let m=u(t),h=m(t);function g(){return t[28](t[37])}function y(){return t[29](t[39])}return{c(){e=s("div"),h.c(),n=d(),p(e,"class","dropdown-item"),$(e,"active",t[4]===t[39]),$(e,"selected",t[17](t[37].email))},m(t,o){l(t,e,o),h.m(e,null),c(e,n),r||(i=[f(e,"mousedown",g),f(e,"mouseenter",y)],r=!0)},p(o,r){m===(m=u(t=o))&&h?h.p(t,r):(h.d(1),h=m(t),h&&(h.c(),h.m(e,n))),16&r[0]&&$(e,"active",t[4]===t[39]),131584&r[0]&&$(e,"selected",t[17](t[37].email))},d(t){t&&a(e),h.d(),r=!1,o(i)}}}function Y(e){let n,o,r,i,m,g,$,y,v,b,x,w=[],_=new Map,k=e[2];const C=t=>t[37].email;for(let t=0;t<k.length;t+=1){let n=D(e,k,t),o=C(n);_.set(o,w[t]=q(o,n))}function T(t,e){return t[1]&&!t[2].length?F:t[1]?void 0:U}let E=T(e),L=E&&E(e),A=e[8]&&G(e);return{c(){n=s("div"),o=s("div"),r=s("div"),i=s("div"),m=u(e[0]),g=d(),$=s("div");for(let t=0;t<w.length;t+=1)w[t].c();y=d(),L&&L.c(),v=d(),A&&A.c(),this.c=t,p(i,"class","contacts-placeholder"),p($,"class","contacts-results-inner"),p(r,"class","contacts-results"),p(o,"class","contacts-container"),p(n,"class","dropdown")},m(t,a){l(t,n,a),c(n,o),c(o,r),c(r,i),c(i,m),c(r,g),c(r,$);for(let t=0;t<w.length;t+=1)w[t].m($,null);c(o,y),L&&L.m(o,null),c(n,v),A&&A.m(n,null),e[30](n),b||(x=f(o,"click",e[12]),b=!0)},p(t,e){if(1&e[0]&&h(m,t[0]),1028&e[0]){const n=t[2];w=function(t,e,n,o,r,i,c,l,a,s,u,d){let f=t.length,m=i.length,p=f;const h={};for(;p--;)h[t[p].key]=p;const g=[],$=new Map,y=new Map;for(p=m;p--;){const t=d(r,i,p),l=n(t);let a=c.get(l);a?o&&a.p(t,e):(a=s(l,t),a.c()),$.set(l,g[p]=a),l in h&&y.set(l,Math.abs(p-h[l]))}const v=new Set,b=new Set;function x(t){j(t,1),t.m(l,u),c.set(t.key,t),u=t.first,m--}for(;f&&m;){const e=g[m-1],n=t[f-1],o=e.key,r=n.key;e===n?(u=e.first,f--,m--):$.has(r)?!c.has(o)||v.has(o)?x(e):b.has(r)?f--:y.get(o)>y.get(r)?(b.add(o),x(e)):(v.add(r),f--):(a(n,c),f--)}for(;f--;){const e=t[f];$.has(e.key)||a(e,c)}for(;m;)x(g[m-1]);return g}(w,e,C,1,t,n,_,$,H,q,null,D)}E===(E=T(t))&&L?L.p(t,e):(L&&L.d(1),L=E&&E(t),L&&(L.c(),L.m(o,null))),t[8]?A?A.p(t,e):(A=G(t),A.c(),A.m(n,null)):A&&(A.d(1),A=null)},i:t,o:t,d(t){t&&a(n);for(let t=0;t<w.length;t+=1)w[t].d();L&&L.d(),A&&A.d(),e[30](null),b=!1,x()}}}function Z(t,e,n){var o=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function c(t){try{a(o.next(t))}catch(t){i(t)}}function l(t){try{a(o.throw(t))}catch(t){i(t)}}function a(t){t.done?r(t.value):function(t){return t instanceof n?t:new n((function(e){e(t)}))}(t.value).then(c,l)}a((o=o.apply(t,e||[])).next())}))};let r,i,{contacts:c}=e,{value:l=[]}=e,{placeholder:a="To"}=e,{single:s=!1}=e,{change:u}=e,d=[],f="",m=0,p=!1,h=[],g=!1;const $=()=>[],y=((t,e)=>{let n;return function(...o){clearTimeout(n),n=setTimeout((()=>{clearTimeout(n),t(...o)}),e)}})((t=>o(void 0,void 0,void 0,(function*(){n(5,p=!0);const e="function"==typeof c?c:$;try{n(31,h=yield e(t)),n(5,p=!1)}catch(t){n(5,p=!1)}}))),350),v=t=>{n(2,d=d.filter((e=>e.email!==t))),x()},b=t=>{if(s&&1===d.length)return n(2,d=[t]),void n(8,g=!1);L(t.email)||n(2,d=[...d,t]),x()},x=()=>{r&&(r.focus(),n(8,g=!0))},_=t=>{setTimeout((()=>{t.addContact&&!A.length&&f&&T(),n(8,g=!1),n(3,f=""),r&&r.blur()}),500|t.blurIn)},k=t=>{n(4,m=t)},T=()=>{s&&1===d.length||(A.length&&(L(A[m].email)||(n(2,d=[...d,A[m]]),n(4,m=0),_({blurIn:0}))),!L(f)&&f&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f)&&(n(2,d=[...d,{email:f}]),n(4,m=0),_({blurIn:0})))},L=t=>d.map((t=>t.email)).includes(t);let A;return t.$$set=t=>{"contacts"in t&&n(18,c=t.contacts),"value"in t&&n(19,l=t.value),"placeholder"in t&&n(0,a=t.placeholder),"single"in t&&n(1,s=t.single),"change"in t&&n(20,u=t.change)},t.$$.update=()=>{1048580&t.$$.dirty[0]&&d&&u&&(E(),C).then((()=>{u(d)})),786432&t.$$.dirty[0]&&(c||l)&&(Array.isArray(c)&&n(31,h=c),l&&l.length&&n(2,d=l)),262408&t.$$.dirty[0]&&g&&"function"==typeof c&&(t=>{n(5,p=!0),n(31,h=[]),y(t)})(f),8&t.$$.dirty[0]|1&t.$$.dirty[1]&&n(9,A=h.filter((t=>{const e=f?f.toLowerCase():"",n=t.name?t.name.toLowerCase():"",o=t.email?t.email.toLowerCase():"",r=n.includes(e),i=o.includes(e);return(r||i)&&!L(t.email)}))),512&t.$$.dirty[0]&&A&&n(4,m=0)},[a,s,d,f,m,p,r,i,g,A,v,b,x,_,t=>{x(),"Backspace"===t.key&&d.length&&!f&&n(2,d=d.slice(0,d.length-1)),"Tab"===t.key&&T(),"ArrowDown"===t.key&&h.length&&m<=h.length&&n(4,m+=1),"ArrowUp"===t.key&&h.length&&0!=m&&n(4,m-=1),"Escape"===t.key&&h.length&&_({})},k,T,L,c,l,u,t=>v(t.email),function(t){w[t?"unshift":"push"]((()=>{r=t,n(6,r)}))},()=>_({addContact:!0}),function(){f=this.value,n(3,f)},function(t){w[t?"unshift":"push"]((()=>{r=t,n(6,r)}))},()=>_({addContact:!0}),function(){f=this.value,n(3,f)},t=>b(t),t=>k(t),function(t){w[t?"unshift":"push"]((()=>{i=t,n(7,i)}))}]}class tt extends O{constructor(t){super(),this.shadowRoot.innerHTML="<style>:root{font-family:sans-serif}.contacts-container{display:flex;align-items:center;flex-wrap:wrap;padding:0.4rem var(--outer-padding);border-bottom:1px solid var(--border)}.contacts-container>div{padding-bottom:0.1rem;padding-right:0.1rem}.contact-item{display:inline-flex;background:var(--primary-light);color:var(--primary);align-items:center;border-radius:calc(var(--border-radius) / 2);padding:0.2rem 0.8rem;margin-right:0.25rem;margin-top:2px;margin-bottom:2px}.contact-item>button{color:var(--text-secondary);border:none;background:none;padding:0;font-weight:bold;font-size:13px;cursor:pointer}.contact-item__name{color:var(--text-secondary);font-size:12px;padding-right:0.75rem}.dropdown{width:100%;position:relative;display:inline-block}.dropdown-content{display:block;position:absolute;max-height:350px;background:var(--background);left:calc(var(--outer-padding) / 2);right:calc(var(--outer-padding) / 2);overflow-y:auto;color:var(--text);box-shadow:var(--shadow);z-index:1;border-radius:calc(var(--border-radius) / 2)}.dropdown-item{cursor:pointer;padding:var(--outer-padding);font-size:var(--font-size-small)}.dropdown-item.active{background-color:var(--primary);color:white}.dropdown-item.active .dropdown-item__email{color:var(--bg) !important}.dropdown-item.selected{opacity:0.3}.dropdown-item__name{font-weight:bold;display:inline-flex}.dropdown-item__email{color:var(--text-light);display:inline-flex;margin-left:0.25rem}.search-field{border:none;color:var(--text);background:var(--bg);width:1px}.search-field:focus{width:100px;outline:none}.search-form{display:flex;padding-top:0.5rem;padding-bottom:0.5rem;align-items:center}.contacts-results{display:flex;align-items:center}.contacts-placeholder{font-size:var(--font-size-small);margin-right:10px;min-width:30px;display:flex;color:var(--text-light)}</style>",I(this,{target:this.shadowRoot,props:y(this.attributes)},Z,Y,i,{contacts:18,value:19,placeholder:0,single:1,change:20},[-1,-1]),t&&(t.target&&l(t.target,this,t.anchor),t.props&&(this.$set(t.props),z()))}static get observedAttributes(){return["contacts","value","placeholder","single","change"]}get contacts(){return this.$$.ctx[18]}set contacts(t){this.$set({contacts:t}),z()}get value(){return this.$$.ctx[19]}set value(t){this.$set({value:t}),z()}get placeholder(){return this.$$.ctx[0]}set placeholder(t){this.$set({placeholder:t}),z()}get single(){return this.$$.ctx[1]}set single(t){this.$set({single:t}),z()}get change(){return this.$$.ctx[20]}set change(t){this.$set({change:t}),z()}}return customElements.define("nylas-contacts-search",tt),tt}));
//# sourceMappingURL=index.js.map

@@ -1,5 +0,5 @@

export const debounce = (func: ContactsSearch.CallbackDebounceFunction, wait: number):ContactsSearch.CallbackDebounceFunction => {
export const debounce = (func: ContactsSearch.CallbackDebounceFunction, wait: number): ContactsSearch.CallbackDebounceFunction => {
let timeout: ReturnType<typeof setTimeout>;
return function executedFunction(...args: any) {
return function executedFunction(...args: unknown[]): void {
const later = () => {

@@ -14,3 +14,3 @@ clearTimeout(timeout);

};
export const isValidEmail = (email: string) => {
export const isValidEmail = (email: string): boolean => {

@@ -17,0 +17,0 @@ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(

{
"name": "@nylas/components-contacts-search",
"version": "0.0.19-alpha.0",
"version": "0.0.20-alpha.0",
"scripts": {

@@ -12,5 +12,5 @@ "build": "rollup -c",

"dependencies": {
"@nylas/components-commons": "^0.0.19-alpha.0"
"@nylas/components-commons": "^0.0.20-alpha.0"
},
"gitHead": "44be09caa1dc73e0ab44224ad686c902bb1cfd67"
"gitHead": "714a6d3c4d94e1b05fff34770988d4ccf43cbf4e"
}

@@ -0,0 +0,0 @@ # Composer

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