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

@walkover/autosuggest-custom

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walkover/autosuggest-custom - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

2

build/index.js

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

!function(){"use strict";var e={649:function(e,n,t){var r=t(81),o=t.n(r),i=t(645),a=t.n(i)()(o());a.push([e.id,".suggestionBox::-webkit-scrollbar {\r\n display: none;\r\n}\r\n\r\n.editable-div::-webkit-scrollbar {\r\n display: none;\r\n}\r\n\r\n.suggestionBox {\r\n display: absolute;\r\n width: auto;\r\n border: 1px solid #ccc;\r\n background-color: #f9f9f9;\r\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\r\n max-height: 200px;\r\n height: auto;\r\n overflow: auto;\r\n}\r\n\r\n.editable-div {\r\n border: 1px solid #ccc;\r\n width: 300px;\r\n height: 100px;\r\n font-family: Arial, sans-serif;\r\n font-size: 16px;\r\n border-radius: 0px;\r\n margin-bottom: 2px;\r\n padding-left: 5px;\r\n overflow: scroll;\r\n}\r\n\r\n.chip {\r\n display: inline-block;\r\n padding: 5px 10px;\r\n margin: 5px;\r\n background-color: #f1f1f1;\r\n border-radius: 20px;\r\n font-family: Arial, sans-serif;\r\n font-size: 14px;\r\n color: #555;\r\n}\r\n\r\nli {\r\n list-style-type: none;\r\n padding: 5px;\r\n}\r\n\r\n.suggestionMainContainer{\r\n display: relative;\r\n width: 100%;\r\n height: 100%;\r\n}\r\n",""]),n.Z=a},645:function(e){e.exports=function(e){var n=[];return n.toString=function(){return this.map((function(n){var t="",r=void 0!==n[5];return n[4]&&(t+="@supports (".concat(n[4],") {")),n[2]&&(t+="@media ".concat(n[2]," {")),r&&(t+="@layer".concat(n[5].length>0?" ".concat(n[5]):""," {")),t+=e(n),r&&(t+="}"),n[2]&&(t+="}"),n[4]&&(t+="}"),t})).join("")},n.i=function(e,t,r,o,i){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(r)for(var u=0;u<this.length;u++){var c=this[u][0];null!=c&&(a[c]=!0)}for(var l=0;l<e.length;l++){var s=[].concat(e[l]);r&&a[s[0]]||(void 0!==i&&(void 0===s[5]||(s[1]="@layer".concat(s[5].length>0?" ".concat(s[5]):""," {").concat(s[1],"}")),s[5]=i),t&&(s[2]?(s[1]="@media ".concat(s[2]," {").concat(s[1],"}"),s[2]=t):s[2]=t),o&&(s[4]?(s[1]="@supports (".concat(s[4],") {").concat(s[1],"}"),s[4]=o):s[4]="".concat(o)),n.push(s))}},n}},81:function(e){e.exports=function(e){return e[1]}},379:function(e){var n=[];function t(e){for(var t=-1,r=0;r<n.length;r++)if(n[r].identifier===e){t=r;break}return t}function r(e,r){for(var i={},a=[],u=0;u<e.length;u++){var c=e[u],l=r.base?c[0]+r.base:c[0],s=i[l]||0,f="".concat(l," ").concat(s);i[l]=s+1;var d=t(f),p={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==d)n[d].references++,n[d].updater(p);else{var v=o(p,r);r.byIndex=u,n.splice(u,0,{identifier:f,updater:v,references:1})}a.push(f)}return a}function o(e,n){var t=n.domAPI(n);return t.update(e),function(n){if(n){if(n.css===e.css&&n.media===e.media&&n.sourceMap===e.sourceMap&&n.supports===e.supports&&n.layer===e.layer)return;t.update(e=n)}else t.remove()}}e.exports=function(e,o){var i=r(e=e||[],o=o||{});return function(e){e=e||[];for(var a=0;a<i.length;a++){var u=t(i[a]);n[u].references--}for(var c=r(e,o),l=0;l<i.length;l++){var s=t(i[l]);0===n[s].references&&(n[s].updater(),n.splice(s,1))}i=c}}},569:function(e){var n={};e.exports=function(e,t){var r=function(e){if(void 0===n[e]){var t=document.querySelector(e);if(window.HTMLIFrameElement&&t instanceof window.HTMLIFrameElement)try{t=t.contentDocument.head}catch(e){t=null}n[e]=t}return n[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(t)}},216:function(e){e.exports=function(e){var n=document.createElement("style");return e.setAttributes(n,e.attributes),e.insert(n,e.options),n}},565:function(e,n,t){e.exports=function(e){var n=t.nc;n&&e.setAttribute("nonce",n)}},795:function(e){e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var n=e.insertStyleElement(e);return{update:function(t){!function(e,n,t){var r="";t.supports&&(r+="@supports (".concat(t.supports,") {")),t.media&&(r+="@media ".concat(t.media," {"));var o=void 0!==t.layer;o&&(r+="@layer".concat(t.layer.length>0?" ".concat(t.layer):""," {")),r+=t.css,o&&(r+="}"),t.media&&(r+="}"),t.supports&&(r+="}");var i=t.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),n.styleTagTransform(r,e,n.options)}(n,e,t)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)}}}},589:function(e){e.exports=function(e,n){if(n.styleSheet)n.styleSheet.cssText=e;else{for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(document.createTextNode(e))}}}},n={};function t(r){var o=n[r];if(void 0!==o)return o.exports;var i=n[r]={id:r,exports:{}};return e[r](i,i.exports,t),i.exports}t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.nc=void 0;var r={};!function(){t.r(r),t.d(r,{default:function(){return x}});var e=require("react"),n=t.n(e),o=t(379),i=t.n(o),a=t(795),u=t.n(a),c=t(569),l=t.n(c),s=t(565),f=t.n(s),d=t(216),p=t.n(d),v=t(589),g=t.n(v),m=t(649),h={};function y(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,i,a,u=[],c=!0,l=!1;try{if(i=(t=t.call(e)).next,0===n){if(Object(t)!==t)return;c=!1}else for(;!(c=(r=i.call(t)).done)&&(u.push(r.value),u.length!==n);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(e,n)||function(e,n){if(e){if("string"==typeof e)return b(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?b(e,n):void 0}}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}h.styleTagTransform=g(),h.setAttributes=f(),h.insert=l().bind(null,"head"),h.domAPI=u(),h.insertStyleElement=p(),i()(m.Z,h),m.Z&&m.Z.locals&&m.Z.locals;var x=function(t){var r=t.id,o=t.suggestion,i=t.chipClass,a=t.editableDivClass,u=t.suggestionBoxClass,c=t.onEnterBtnEvent,l=t.getInputValueWithContext,s=t.setHtml,f=t.setText,d=t.defaultValue,p=o||[],v=(0,e.useRef)(null),g=(0,e.useRef)(null),m=y((0,e.useState)([]),2),h=m[0],b=m[1],x=y((0,e.useState)(-1),2),w=x[0],C=x[1],S=y((0,e.useState)(),2),T=S[0],E=S[1],N=y((0,e.useState)({left:0,top:0}),2),A=N[0],M=N[1],O=function(){if(v.current){var e=v.current.innerHTML,n=document.createElement("div");n.innerHTML=e;for(var t=n.getElementsByTagName("span"),r=t.length-1;r>=0;r--){var o=t[r],i=o.getAttribute("data-attribute")+" ",a=document.createTextNode(i);o.parentNode.replaceChild(a,o)}var u=n.innerText;s&&s((function(){return e})),f&&f(u),l&&l(u,e)}},I=function(e){var n,t,r,o=window.getSelection(),a=o.anchorNode,u=o.anchorOffset;if(a&&a.nodeType===Node.TEXT_NODE){var c,l,s,f=document.createElement("span");f.className=i||"chip",f.contentEditable="false",f.textContent=e.name,f.setAttribute("data-attribute",e.content);var d=a.nodeValue.substring(0,u),p=a.nodeValue.substring(u,a.nodeValue.length),g=d.lastIndexOf(T),m=a.nodeValue.substring(0,g),h=document.createTextNode(m);a.parentNode.insertBefore(h,a),a.parentNode.insertBefore(f,a),(1===(null===(c=p.substring(0,1))||void 0===c?void 0:c.length)&&" "!==(null===(l=p)||void 0===l?void 0:l.substring(0,1))||0===(null===(s=p.substring(0,1))||void 0===s?void 0:s.length))&&(p=" "+p);var y=document.createTextNode(p);a.parentNode.insertBefore(y,a),n=y,0,e.name.length,t=document.createRange(),r=window.getSelection(),t.setStart(n,0),t.collapse(!0),r.removeAllRanges(),r.addRange(t),a.parentNode.removeChild(a)}O(),b([]),setTimeout((function(){v.current&&v.current.focus()}))};return(0,e.useEffect)((function(){v.current&&(v.current.innerHTML=d||"")}),[]),n().createElement("div",{ref:g,className:"suggestionMainContainer",style:{position:"relative"}},n().createElement("div",{id:r||"",contentEditable:!0,ref:v,onKeyDown:function(e){if("ArrowUp"===e.key)e.preventDefault(),C((function(e){return-1===e?h.length-1:Math.max(0,e-1)}));else if("ArrowDown"===e.key)e.preventDefault(),C((function(e){return e===h.length-1?-1:Math.min(h.length-1,e+1)}));else if("Enter"===e.key){e.preventDefault();var n=h[w];n?(I(n),C(-1)):c&&c()}},onInput:function(e){!function(e){if(v.current||0!==v.current.innerText.length){O();var n=window.getSelection(),t=n.anchorOffset,r=n.anchorNode.textContent.substring(0,t).trim(),o=r.trim(),i=function(){if(g.current||v.current){var e=g.current,n=v.current,t=window.getSelection(),r=document.createRange();r.selectNodeContents(n),r.setEnd(t.anchorNode,t.anchorOffset);var o=r.cloneRange();o.collapse(!1);var i=o.getBoundingClientRect(),a=e.getBoundingClientRect(),u=o.getBoundingClientRect().height;return{left:i.left-a.left,top:i.top-a.top+u}}}();M(i);var a=(o=r.split(/ |\u00A0/))[o.length-1];if(0!==a.length){E(a);var u=p.filter((function(e){var n;return null==e||null===(n=e.name)||void 0===n?void 0:n.toLowerCase().startsWith(a.trim().toLowerCase())}));b(u),C(-1)}}else b([])}()},className:a||"editable-div",suppressContentEditableWarning:!0}),n().createElement("div",{className:u||"suggestionBox",style:{position:"absolute",left:A.left,top:A.top,zIndex:100,opacity:h.length>0?1:0}},null==h?void 0:h.map((function(e,t){return n().createElement("li",{key:t,style:{background:w===t?"#D3D3D3":"",cursor:"pointer"},onMouseDown:function(){return I(e)},onClick:function(){return I(e)}},e.name)}))))}}(),module.exports=r}();
!function(){"use strict";var e={649:function(e,n,t){var r=t(81),o=t.n(r),i=t(645),a=t.n(i)()(o());a.push([e.id,".suggestionBox::-webkit-scrollbar {\r\n display: none;\r\n}\r\n\r\n.editable-div::-webkit-scrollbar {\r\n display: none;\r\n}\r\n\r\n.suggestionBox {\r\n display: absolute;\r\n width: auto;\r\n border: 1px solid #ccc;\r\n background-color: #f9f9f9;\r\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\r\n max-height: 200px;\r\n height: auto;\r\n overflow: auto;\r\n}\r\n\r\n.editable-div {\r\n border: 1px solid #ccc;\r\n width: 300px;\r\n height: 100px;\r\n font-family: Arial, sans-serif;\r\n font-size: 16px;\r\n border-radius: 0px;\r\n margin-bottom: 2px;\r\n padding-left: 5px;\r\n overflow: scroll;\r\n}\r\n\r\n.chip {\r\n display: inline-block;\r\n padding: 5px 10px;\r\n margin: 5px;\r\n background-color: #f1f1f1;\r\n border-radius: 20px;\r\n font-family: Arial, sans-serif;\r\n font-size: 14px;\r\n color: #555;\r\n}\r\n\r\nli {\r\n list-style-type: none;\r\n padding: 5px;\r\n}\r\n\r\n.suggestionMainContainer{\r\n display: relative;\r\n width: 100%;\r\n height: 100%;\r\n}\r\n",""]),n.Z=a},645:function(e){e.exports=function(e){var n=[];return n.toString=function(){return this.map((function(n){var t="",r=void 0!==n[5];return n[4]&&(t+="@supports (".concat(n[4],") {")),n[2]&&(t+="@media ".concat(n[2]," {")),r&&(t+="@layer".concat(n[5].length>0?" ".concat(n[5]):""," {")),t+=e(n),r&&(t+="}"),n[2]&&(t+="}"),n[4]&&(t+="}"),t})).join("")},n.i=function(e,t,r,o,i){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(r)for(var u=0;u<this.length;u++){var c=this[u][0];null!=c&&(a[c]=!0)}for(var l=0;l<e.length;l++){var s=[].concat(e[l]);r&&a[s[0]]||(void 0!==i&&(void 0===s[5]||(s[1]="@layer".concat(s[5].length>0?" ".concat(s[5]):""," {").concat(s[1],"}")),s[5]=i),t&&(s[2]?(s[1]="@media ".concat(s[2]," {").concat(s[1],"}"),s[2]=t):s[2]=t),o&&(s[4]?(s[1]="@supports (".concat(s[4],") {").concat(s[1],"}"),s[4]=o):s[4]="".concat(o)),n.push(s))}},n}},81:function(e){e.exports=function(e){return e[1]}},379:function(e){var n=[];function t(e){for(var t=-1,r=0;r<n.length;r++)if(n[r].identifier===e){t=r;break}return t}function r(e,r){for(var i={},a=[],u=0;u<e.length;u++){var c=e[u],l=r.base?c[0]+r.base:c[0],s=i[l]||0,f="".concat(l," ").concat(s);i[l]=s+1;var d=t(f),p={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==d)n[d].references++,n[d].updater(p);else{var v=o(p,r);r.byIndex=u,n.splice(u,0,{identifier:f,updater:v,references:1})}a.push(f)}return a}function o(e,n){var t=n.domAPI(n);return t.update(e),function(n){if(n){if(n.css===e.css&&n.media===e.media&&n.sourceMap===e.sourceMap&&n.supports===e.supports&&n.layer===e.layer)return;t.update(e=n)}else t.remove()}}e.exports=function(e,o){var i=r(e=e||[],o=o||{});return function(e){e=e||[];for(var a=0;a<i.length;a++){var u=t(i[a]);n[u].references--}for(var c=r(e,o),l=0;l<i.length;l++){var s=t(i[l]);0===n[s].references&&(n[s].updater(),n.splice(s,1))}i=c}}},569:function(e){var n={};e.exports=function(e,t){var r=function(e){if(void 0===n[e]){var t=document.querySelector(e);if(window.HTMLIFrameElement&&t instanceof window.HTMLIFrameElement)try{t=t.contentDocument.head}catch(e){t=null}n[e]=t}return n[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(t)}},216:function(e){e.exports=function(e){var n=document.createElement("style");return e.setAttributes(n,e.attributes),e.insert(n,e.options),n}},565:function(e,n,t){e.exports=function(e){var n=t.nc;n&&e.setAttribute("nonce",n)}},795:function(e){e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var n=e.insertStyleElement(e);return{update:function(t){!function(e,n,t){var r="";t.supports&&(r+="@supports (".concat(t.supports,") {")),t.media&&(r+="@media ".concat(t.media," {"));var o=void 0!==t.layer;o&&(r+="@layer".concat(t.layer.length>0?" ".concat(t.layer):""," {")),r+=t.css,o&&(r+="}"),t.media&&(r+="}"),t.supports&&(r+="}");var i=t.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),n.styleTagTransform(r,e,n.options)}(n,e,t)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)}}}},589:function(e){e.exports=function(e,n){if(n.styleSheet)n.styleSheet.cssText=e;else{for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(document.createTextNode(e))}}}},n={};function t(r){var o=n[r];if(void 0!==o)return o.exports;var i=n[r]={id:r,exports:{}};return e[r](i,i.exports,t),i.exports}t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.nc=void 0;var r={};!function(){t.r(r),t.d(r,{default:function(){return x}});var e=require("react"),n=t.n(e),o=t(379),i=t.n(o),a=t(795),u=t.n(a),c=t(569),l=t.n(c),s=t(565),f=t.n(s),d=t(216),p=t.n(d),v=t(589),g=t.n(v),m=t(649),h={};function y(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,i,a,u=[],c=!0,l=!1;try{if(i=(t=t.call(e)).next,0===n){if(Object(t)!==t)return;c=!1}else for(;!(c=(r=i.call(t)).done)&&(u.push(r.value),u.length!==n);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(e,n)||function(e,n){if(e){if("string"==typeof e)return b(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?b(e,n):void 0}}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}h.styleTagTransform=g(),h.setAttributes=f(),h.insert=l().bind(null,"head"),h.domAPI=u(),h.insertStyleElement=p(),i()(m.Z,h),m.Z&&m.Z.locals&&m.Z.locals;var x=function(t){var r=t.id,o=t.suggestion,i=t.chipClass,a=t.editableDivClass,u=t.suggestionBoxClass,c=t.onEnterBtnEvent,l=t.getInputValueWithContext,s=t.setHtml,f=t.setText,d=t.defaultValue,p=t.disAble,v=o||[],g=(0,e.useRef)(),m=(0,e.useRef)(),h=y((0,e.useState)([]),2),b=h[0],x=h[1],w=y((0,e.useState)(-1),2),C=w[0],S=w[1],T=y((0,e.useState)(),2),E=T[0],N=T[1],A=y((0,e.useState)({left:0,top:0}),2),M=A[0],O=A[1],I=function(){if(g.current){var e=g.current.innerHTML,n=document.createElement("div");n.innerHTML=e;for(var t=n.getElementsByTagName("span"),r=t.length-1;r>=0;r--){var o=t[r],i=o.getAttribute("data-attribute")+" ",a=document.createTextNode(i);o.parentNode.replaceChild(a,o)}var u=n.innerText;s&&s((function(){return e})),f&&f(u),l&&l(u,e)}},k=function(e){var n,t,r,o=window.getSelection(),a=o.anchorNode,u=o.anchorOffset;if(a&&a.nodeType===Node.TEXT_NODE){var c,l,s,f=document.createElement("span");f.className=i||"chip",f.contentEditable="false",f.textContent=e.name,f.setAttribute("data-attribute",e.content);var d=a.nodeValue.substring(0,u),p=a.nodeValue.substring(u,a.nodeValue.length),v=d.lastIndexOf(E),m=a.nodeValue.substring(0,v),h=document.createTextNode(m);a.parentNode.insertBefore(h,a),a.parentNode.insertBefore(f,a),(1===(null===(c=p.substring(0,1))||void 0===c?void 0:c.length)&&" "!==(null===(l=p)||void 0===l?void 0:l.substring(0,1))||0===(null===(s=p.substring(0,1))||void 0===s?void 0:s.length))&&(p=" "+p);var y=document.createTextNode(p);a.parentNode.insertBefore(y,a),n=y,0,e.name.length,t=document.createRange(),r=window.getSelection(),t.setStart(n,0),t.collapse(!0),r.removeAllRanges(),r.addRange(t),a.parentNode.removeChild(a)}I(),x([]),setTimeout((function(){g.current&&g.current.focus()}))};return(0,e.useEffect)((function(){g.current&&(g.current.innerHTML=d||"")}),[]),n().createElement("div",{ref:m,className:"suggestionMainContainer",style:{position:"relative"}},n().createElement("div",{id:r||"",contentEditable:!0!==p,ref:g,onKeyDown:function(e){if("ArrowUp"===e.key)e.preventDefault(),S((function(e){return-1===e?b.length-1:Math.max(0,e-1)}));else if("ArrowDown"===e.key)e.preventDefault(),S((function(e){return e===b.length-1?-1:Math.min(b.length-1,e+1)}));else if("Enter"===e.key){e.preventDefault();var n=b[C];n?(k(n),S(-1)):c&&c()}},onInput:function(e){!function(e){if(g.current||0!==g.current.innerText.length){I();var n=window.getSelection(),t=n.anchorOffset,r=n.anchorNode.textContent.substring(0,t).trim(),o=r.trim(),i=function(){if(m.current||g.current){var e=m.current,n=g.current,t=window.getSelection(),r=document.createRange();r.selectNodeContents(n),r.setEnd(t.anchorNode,t.anchorOffset);var o=r.cloneRange();o.collapse(!1);var i=o.getBoundingClientRect(),a=e.getBoundingClientRect(),u=o.getBoundingClientRect().height;return{left:i.left-a.left,top:i.top-a.top+u}}}();O(i);var a=(o=r.split(/ |\u00A0/))[o.length-1];if(0!==a.length){N(a);var u=v.filter((function(e){var n;return null==e||null===(n=e.name)||void 0===n?void 0:n.toLowerCase().startsWith(a.trim().toLowerCase())}));x(u),S(-1)}}else x([])}()},className:a||"editable-div",suppressContentEditableWarning:!0}),n().createElement("div",{className:u||"suggestionBox",style:{position:"absolute",left:M.left,top:M.top,zIndex:100,opacity:b.length>0?1:0}},null==b?void 0:b.map((function(e,t){return n().createElement("li",{key:t,style:{background:C===t?"#D3D3D3":"",cursor:"pointer"},onMouseDown:function(){return k(e)},onClick:function(){return k(e)}},e.name)}))))}}(),module.exports=r}();
{
"name": "@walkover/autosuggest-custom",
"version": "0.2.4",
"version": "0.2.5",
"author": "walkover-web",

@@ -5,0 +5,0 @@ "main": "build/index.js",

/* eslint-disable */
import React, { useState, useRef, useEffect, Suspense } from 'react';
import React, { useState, useRef, useEffect } from 'react';
import './customAutoSuggest.css';
const CustomAutoSuggest = ({ id, suggestion, chipClass, editableDivClass, suggestionBoxClass, onEnterBtnEvent, getInputValueWithContext, setHtml, setText, defaultValue }) => {
const CustomAutoSuggest = ({ id, suggestion, chipClass, editableDivClass, suggestionBoxClass, onEnterBtnEvent, getInputValueWithContext, setHtml, setText, defaultValue, disAble }) => {
let suggestions = suggestion || [];
const editableDivRef = useRef(null);
const parentDivRef = useRef(null);
const editableDivRef = useRef();
const parentDivRef = useRef();
const [filteredSuggestions, setFilteredSuggestions] = useState([]);

@@ -17,34 +17,34 @@ const [selectedSuggestionIndex, setSelectedSuggestionIndex] = useState(-1);

const handleGetCaretCoordinates = () => {
if (!parentDivRef.current && !editableDivRef.current) return;
if(!parentDivRef.current && !editableDivRef.current) return;
const parentDiv = parentDivRef.current;
const editableDiv = editableDivRef.current;
const parentDiv = parentDivRef.current;
const editableDiv = editableDivRef.current;
const selection = window.getSelection();
const range = document.createRange();
const selection = window.getSelection();
const range = document.createRange();
// Set the range to the editable div's contents
range.selectNodeContents(editableDiv);
// Set the range to the editable div's contents
range.selectNodeContents(editableDiv);
// Set the range's end to the current selection
range.setEnd(selection.anchorNode, selection.anchorOffset);
// Set the range's end to the current selection
range.setEnd(selection.anchorNode, selection.anchorOffset);
// Calculate the caret position
const caretRange = range.cloneRange();
caretRange.collapse(false);
// Calculate the caret position
const caretRange = range.cloneRange();
caretRange.collapse(false);
const caretRect = caretRange.getBoundingClientRect();
const parentRect = parentDiv.getBoundingClientRect();
const characterHeight = caretRange.getBoundingClientRect().height;
const caretRect = caretRange.getBoundingClientRect();
const parentRect = parentDiv.getBoundingClientRect();
const characterHeight = caretRange.getBoundingClientRect().height;
const caretCoordinates = {
left: caretRect.left - parentRect.left,
top: caretRect.top - parentRect.top + characterHeight,
};
const caretCoordinates = {
left: caretRect.left - parentRect.left,
top: caretRect.top - parentRect.top + characterHeight,
};
return caretCoordinates;
return caretCoordinates;
};
const getInputValueWithContent = () => {
if (!editableDivRef.current) return;
if(!editableDivRef.current) return;
let htmlCode = editableDivRef.current.innerHTML;

@@ -61,4 +61,4 @@ var temporaryElement = document.createElement('div');

var convertedHtmlCode = temporaryElement.innerText;
if (setHtml) setHtml(() => htmlCode);
if (setText) setText(convertedHtmlCode);
if(setHtml) setHtml(()=> htmlCode);
if(setText) setText(convertedHtmlCode);
if (getInputValueWithContext) {

@@ -100,3 +100,3 @@ getInputValueWithContext(convertedHtmlCode, htmlCode);

const handleInputChange = (e) => {
if (!editableDivRef.current && editableDivRef.current.innerText.length === 0) {
if ( !editableDivRef.current && editableDivRef.current.innerText.length === 0) {
setFilteredSuggestions([]);

@@ -162,3 +162,3 @@ return;

setTimeout(() => {
if (!editableDivRef.current) return;
if(!editableDivRef.current) return;
editableDivRef.current.focus();

@@ -170,3 +170,3 @@ },);

useEffect(() => {
if (!editableDivRef.current) return;
if(!editableDivRef.current) return;
editableDivRef.current.innerHTML = defaultValue || "";

@@ -178,11 +178,3 @@ }, [])

<div
id={id ? id : ''}
contentEditable={true}
ref={editableDivRef}
onKeyDown={handleKeyDown}
onInput={(e) => { handleInputChange(e); }}
className={editableDivClass || 'editable-div'}
suppressContentEditableWarning={true}
/>
<div id={id ? id : ''} contentEditable={disAble === true ? false : true} ref={editableDivRef} onKeyDown={handleKeyDown} onInput={(e) => { handleInputChange(e); }} className={editableDivClass || 'editable-div'} suppressContentEditableWarning={true} />

@@ -189,0 +181,0 @@ <div className={suggestionBoxClass || 'suggestionBox'}

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