@walkover/autosuggest-custom
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";var e={649:function(e,t,n){var r=n(81),o=n.n(r),i=n(645),a=n.n(i)()(o());a.push([e.id,"/* COMMON CLASSES FOR BOTH GROUPED AND SIMPLE AUTOSUGGEST */\r\n.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: 70vh;\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\n.suggestionMainContainer {\r\n width: 100%;\r\n height: 100%;\r\n}\r\n\r\n.hoverValueContainer {\r\n min-width: 100px !important;\r\n max-width: 200px !important;\r\n padding: 10px !important;\r\n word-wrap: break-word;\r\n color: white;\r\n background-color: rgb(31, 32, 30);\r\n font-size: 14px !important;\r\n border-radius: 5px;\r\n z-index: 30;\r\n min-height: 20px !important;\r\n max-height: fit-content !important;\r\n}\r\n\r\n.hoverValueContainer::-webkit-scrollbar {\r\n display: none !important;\r\n}\r\n\r\n/* SIMPLE AUTO-SUGGESTIONS CLASSES */\r\n.listSuggestionContainerForSimpleAutosuggest {\r\n list-style-type: none;\r\n font-size: 16px;\r\n padding: 5px;\r\n}\r\n\r\n.listSuggestionContainerForSimpleAutosuggest:hover {\r\n background-color: rgb(128, 128, 128, 0.5);\r\n}\r\n\r\n.listSuggestionTag{\r\n font-size: 16px !important;\r\n}\r\n\r\n.listSuggestionTagContent{\r\n font-size: 12px !important;\r\n}\r\n\r\n/* GROUPED SUGGESTIONS CLASSES */\r\n.listSuggestions {\r\n list-style-type: none;\r\n font-size: 16px !important;\r\n padding: 0px 0px 0px 17px;\r\n}\r\n\r\n.valueContent {\r\n font-size: 12px !important;\r\n list-style-type: none;\r\n margin: 0px 0px 0px 17px;\r\n}\r\n\r\n.ulTag {\r\n font-size: 21px !important;\r\n padding: 5px;\r\n background-color: black;\r\n color: white;\r\n width: 100% !important;\r\n}\r\n\r\n.listSuggestionContainer {\r\n display: flex;\r\n flex-direction: column;\r\n padding: 5px;\r\n}\r\n\r\n.listSuggestionContainer:hover {\r\n background-color: rgb(128, 128, 128, 0.5);\r\n}",""]),t.Z=a},645:function(e){e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,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),n&&(s[2]?(s[1]="@media ".concat(s[2]," {").concat(s[1],"}"),s[2]=n):s[2]=n),o&&(s[4]?(s[1]="@supports (".concat(s[4],") {").concat(s[1],"}"),s[4]=o):s[4]="".concat(o)),t.push(s))}},t}},81:function(e){e.exports=function(e){return e[1]}},379:function(e){var t=[];function n(e){for(var n=-1,r=0;r<t.length;r++)if(t[r].identifier===e){n=r;break}return n}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=n(f),p={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==d)t[d].references++,t[d].updater(p);else{var g=o(p,r);r.byIndex=u,t.splice(u,0,{identifier:f,updater:g,references:1})}a.push(f)}return a}function o(e,t){var n=t.domAPI(t);return n.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.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=n(i[a]);t[u].references--}for(var c=r(e,o),l=0;l<i.length;l++){var s=n(i[l]);0===t[s].references&&(t[s].updater(),t.splice(s,1))}i=c}}},569:function(e){var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[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(n)}},216:function(e){e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},565:function(e,t,n){e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},795:function(e){e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},589:function(e){e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nc=void 0;var r={};!function(){n.r(r),n.d(r,{default:function(){return A}});var e=require("react"),t=n.n(e);function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,u=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e,t)||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 a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function u(n){var r,a=n.id,u=n.editableDivRef,c=n.suggestion,l=n.chipClass,s=n.editableDivClass,f=n.suggestionBoxClass,d=n.onEnterBtnEvent,p=n.getInputValueWithContext,g=n.setHtml,v=n.setText,m=n.defaultValue,b=n.disable,h=n.valueContainerPosition,y=c||[],x=(0,e.useRef)(),S=(0,e.useRef)(),w=i((0,e.useState)([]),2),E=w[0],C=w[1],N=i((0,e.useState)(-1),2),T=N[0],A=N[1],O=i((0,e.useState)(),2),k=O[0],R=O[1],D=i((0,e.useState)({left:0,top:0}),2),j=D[0],M=D[1],B=i((0,e.useState)(""),2),I=B[0],L=B[1];(0,e.useEffect)((function(){u.current&&(u.current.innerHTML=m||"")}),[u]),(0,e.useEffect)((function(){var e=l||"chip",t=document.getElementsByClassName(e),n=Array.from(t);n.forEach((function(e){P(e)})),n.forEach((function(e){V(e)}))}),[null==u||null===(r=u.current)||void 0===r?void 0:r.innerText.length,l]);var P=function(e){e.addEventListener("mouseenter",(function(e){e.target.getAttribute("walkover-attribute")?L(e.target.getAttribute("walkover-attribute")):L("")}))},V=function(e){e.addEventListener("mouseleave",(function(){L("")}))},z=function(){if(u.current){var e=u.current.innerHTML,t=document.createElement("div");t.innerHTML=e,function(e){for(var t=e.length-1;t>=0;t--){var n=e[t];if(n.getAttribute("walkover-attribute")){var r=n.getAttribute("data-attribute")+" ",o=document.createTextNode(r);n.parentNode.replaceChild(o,n)}}}(t.getElementsByTagName("span")),function(e,t){g&&g((function(){return t})),v&&v(e),p&&p(e,t)}(t.innerText,e)}},H=function(e){var t,n,r,o=window.getSelection(),i=o.anchorNode,a=o.anchorOffset;if(i&&i.nodeType===Node.TEXT_NODE){var c,s,f,d=document.createElement("span");d.className=l||"chip",d.contentEditable="false",d.textContent=e.name,d.setAttribute("walkover-attribute",e.content),d.setAttribute("data-attribute",e.content);var p=i.nodeValue.substring(0,a),g=i.nodeValue.substring(a,i.nodeValue.length),v=p.lastIndexOf(k),m=i.nodeValue.substring(0,v),b=document.createTextNode(m);i.parentNode.insertBefore(b,i),i.parentNode.insertBefore(d,i),(1===(null===(c=g.substring(0,1))||void 0===c?void 0:c.length)&&" "!==(null===(s=g)||void 0===s?void 0:s.substring(0,1))||0===(null===(f=g.substring(0,1))||void 0===f?void 0:f.length))&&(g=" "+g);var h=document.createTextNode(g);i.parentNode.insertBefore(h,i),t=h,0,e.name.length,n=document.createRange(),r=window.getSelection(),n.setStart(t,0),n.collapse(!0),r.removeAllRanges(),r.addRange(n),i.parentNode.removeChild(i)}z(),C([]),setTimeout((function(){u.current&&u.current.focus()}))},U={ref:S,className:"suggestionMainContainer"},G={id:a||"",contentEditable:!0!==b,ref:u,className:s||"editable-div",suppressContentEditableWarning:!0,onKeyDown:function(e){var t,n,r,o,i;"ArrowUp"===e.key?(e.preventDefault(),A((function(e){return-1===e?E.length-1:Math.max(0,e-1)}))):"ArrowDown"===e.key?(e.preventDefault(),A((function(e){return e===E.length-1?0:Math.min(E.length-1,e+1)}))):"Enter"===e.key&&(e.preventDefault(),(t=E[T])?(H(t),A(-1)):d?d():(n=u.current,r=window.getSelection(),o=r.getRangeAt(0),i=document.createElement("br"),o.insertNode(i),o.setStartAfter(i),o.collapse(!0),r.removeAllRanges(),r.addRange(o),n.normalize(),n.focus()))},onInput:function(e){!function(e){if(u.current&&0===u.current.innerText.length)return C([]);z();var t=window.getSelection(),n=t.anchorOffset,r=t.anchorNode.textContent.substring(0,n).trim(),o=function(){if(S.current||u.current){var e=S.current,t=u.current,n=window.getSelection(),r=document.createRange();r.selectNodeContents(t),r.setEnd(n.anchorNode,n.anchorOffset);var o=r.cloneRange();o.collapse(!1);var i=o.getBoundingClientRect(),a=e.getBoundingClientRect(),c=o.getBoundingClientRect().height;return{left:i.left-a.left,top:i.top-a.top+c}}}();M(o);var i=r.split(/ |\u00A0/),a=i[i.length-1];if(0!==a.length){R(a);var c=y.filter((function(e){var t;return null==e||null===(t=e.name)||void 0===t?void 0:t.toLowerCase().startsWith(a.trim().toLowerCase())}));C(c),A(-1)}}()},onPaste:function(e){!function(e){e.preventDefault();var t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)}(e)}},F={position:"absolute",left:j.left,top:j.top,opacity:Object.entries(E).length>0?1:0,zIndex:100},_=function(e){return{background:T===e?"#D3D3D3":"",cursor:"pointer"}};return t().createElement("div",o({},U,{style:{position:"relative"}}),t().createElement("div",G),I.length>0&&t().createElement("div",{ref:x,style:function(){switch(h){case"top":return{position:"absolute",top:void setTimeout((function(){if(x.current)return"-".concat(x.current.offsetHeight,"px")}))};case"bottom":return{position:"absolute",bottom:"100%",top:"100%"};case"left":return{position:"absolute",right:"100%",top:"0px"};case"right":return{position:"absolute",left:"100%",top:"0px"}}}(),className:"hoverValueContainer"},I),t().createElement("div",{className:f||"suggestionBox",style:F},null==E?void 0:E.map((function(e,n){return function(e,n){return t().createElement("div",o({},function(e,t){return{key:t,className:"listSuggestionContainerForSimpleAutosuggest",onMouseDown:function(){return H(e)},onClick:function(){return H(e)}}}(e,n),{style:_(n)}),t().createElement("div",{className:"listSuggestionTag"}," ",e.name," "),t().createElement("div",{className:"listSuggestionTagContent"}," ",e.content," "))}(e,n)}))))}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,u=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(e,t)||s(e,t)||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 s(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f(e,t):void 0}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function d(n){var r,o=n.id,i=n.editableDivRef,a=n.suggestion,u=n.chipClass,f=n.editableDivClass,d=n.suggestionBoxClass,p=n.onEnterBtnEvent,g=n.getInputValueWithContext,v=n.setHtml,m=n.setText,b=n.defaultValue,h=n.disable,y=n.valueContainerPosition,x=a||[],S=(0,e.useRef)(),w=(0,e.useRef)(),E=l((0,e.useState)({}),2),C=E[0],N=E[1],T=l((0,e.useState)(-1),2),A=T[0],O=T[1],k=l((0,e.useState)(),2),R=k[0],D=k[1],j=l((0,e.useState)({left:0,top:0}),2),M=j[0],B=j[1],I=l((0,e.useState)(""),2),L=I[0],P=I[1],V=l((0,e.useState)(),2),z=V[0],H=V[1];(0,e.useEffect)((function(){i.current&&(i.current.innerHTML=b||"")}),[i]),(0,e.useEffect)((function(){var e=u||"chip",t=document.getElementsByClassName(e),n=Array.from(t);n.forEach((function(e){U(e)})),n.forEach((function(e){G(e)}))}),[null==i||null===(r=i.current)||void 0===r?void 0:r.innerText.length,u]);var U=function(e){e.addEventListener("mouseenter",(function(e){e.target.getAttribute("walkover-attribute")?P(e.target.getAttribute("walkover-attribute")):P("")}))},G=function(e){e.addEventListener("mouseleave",(function(){P("")}))},F=function(){if(i.current){var e=i.current.innerHTML,t=document.createElement("div");t.innerHTML=e,function(e){for(var t=e.length-1;t>=0;t--){var n=e[t];if(n.getAttribute("walkover-attribute")){var r=n.getAttribute("data-attribute")+" ",o=document.createTextNode(r);n.parentNode.replaceChild(o,n)}}}(t.getElementsByTagName("span")),function(e,t){v&&v((function(){return t})),m&&m(e),g&&g(e,t)}(t.innerText,e)}};var _=function(e){if(i.current&&0===i.current.innerText.length)return N([]);F();var t=window.getSelection(),n=t.anchorOffset,r=t.anchorNode.textContent.substring(0,n).trim(),o=function(){if(w.current||i.current){var e=w.current,t=i.current,n=window.getSelection(),r=document.createRange();r.selectNodeContents(t),r.setEnd(n.anchorNode,n.anchorOffset);var o=r.cloneRange();o.collapse(!1);var a=o.getBoundingClientRect(),u=e.getBoundingClientRect(),c=o.getBoundingClientRect().height;return{left:a.left-u.left,top:a.top-u.top+c}}}();B(o);var a=r.split(/ |\u00A0/),u=a[a.length-1];if(0!==u.length){D(u);var c=function(e,t){var n,r={},o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=s(e))){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}(e);try{for(o.s();!(n=o.n()).done;){var i=n.value;i.name.toLowerCase().includes(t)&&(r[i.groupName]||(r[i.groupName]=[]),r[i.groupName].push(i))}}catch(e){o.e(e)}finally{o.f()}return r}(x,u.trim().toLowerCase());N(c),O(-1)}},W=function(e){var t,n,r,o=window.getSelection(),a=o.anchorNode,c=o.anchorOffset;if(a&&a.nodeType===Node.TEXT_NODE){var l,s,f,d=document.createElement("span");d.className=u||"chip",d.contentEditable="false",d.textContent=e.name,d.setAttribute("walkover-attribute",e.content),d.setAttribute("data-attribute",e.content);var p=a.nodeValue.substring(0,c),g=a.nodeValue.substring(c,a.nodeValue.length),v=p.lastIndexOf(R),m=a.nodeValue.substring(0,v),b=document.createTextNode(m);a.parentNode.insertBefore(b,a),a.parentNode.insertBefore(d,a),(1===(null===(l=g.substring(0,1))||void 0===l?void 0:l.length)&&" "!==(null===(s=g)||void 0===s?void 0:s.substring(0,1))||0===(null===(f=g.substring(0,1))||void 0===f?void 0:f.length))&&(g=" "+g);var h=document.createTextNode(g);a.parentNode.insertBefore(h,a),t=h,0,e.name.length,n=document.createRange(),r=window.getSelection(),n.setStart(t,0),n.collapse(!0),r.removeAllRanges(),r.addRange(n),a.parentNode.removeChild(a)}F(),N([]),setTimeout((function(){i.current&&i.current.focus()}))},Z={ref:w,className:"suggestionMainContainer"},q={id:o||"",contentEditable:!0!==h,ref:i,className:f||"editable-div",suppressContentEditableWarning:!0,onKeyDown:function(e){"ArrowUp"===e.key?function(){var e=Object.keys(C),t=e.length-1;if(-1===A){var n=e[t],r=C[n];return H({key:n,index:t}),void O(r.length-1)}if(0===A){var o=z.index-1,i=e[o]||e[t],a=C[i];H({key:i,index:o}),O(a.length-1)}else O((function(e){return e-1}))}():"ArrowDown"===e.key?function(){if(-1===A){var e=Object.keys(C)[0];H({key:e,index:0}),O(0)}else{var t=C[null==z?void 0:z.key];if((null==t?void 0:t.length)-1===A){var n=z.index+1,r=Object.keys(C)[n];r||(r=Object.keys(C)[0],n=0),H({key:r,index:n}),O(0)}else O((function(e){return e+1}))}}():"Enter"===e.key&&(e.preventDefault(),function(){if(0!==Object.keys(C).length&&-1!==A){var e=C[z.key][A];e&&(W(e),O(-1))}else p?p():(t=i.current,n=window.getSelection(),r=n.getRangeAt(0),o=document.createElement("br"),r.insertNode(o),r.setStartAfter(o),r.collapse(!0),n.removeAllRanges(),n.addRange(r),t.normalize(),t.focus());var t,n,r,o}())},onInput:function(e){_()},onPaste:function(e){!function(e){e.preventDefault();var t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)}(e)}},K={position:"absolute",left:M.left,top:M.top,opacity:Object.entries(C).length>0?1:0,zIndex:100},X=function(e,t){return{key:t,className:"listSuggestionContainer",onMouseDown:function(){return W(e)},onClick:function(){return W(e)}}},$=function(e,t){return{background:A===e&&t===z.key?"#D3D3D3":"",cursor:"pointer"}};return t().createElement("div",c({},Z,{style:{position:"relative"}}),t().createElement("div",q),L.length>0&&t().createElement("div",{ref:S,style:function(){switch(y){case"top":return{position:"absolute",top:void setTimeout((function(){if(S.current)return"-".concat(S.current.offsetHeight,"px")}))};case"bottom":return{position:"absolute",bottom:"100%",top:"100%"};case"left":return{position:"absolute",right:"100%",top:"0px"};case"right":return{position:"absolute",left:"100%",top:"0px"}}}(),className:"hoverValueContainer"},L),t().createElement("div",{className:d||"suggestionBox",style:K},Object.entries(C).map((function(e){var n=l(e,2);return function(e,n){return t().createElement("div",{className:"groupBlock",key:e},t().createElement("div",{className:"ulTag"},e),function(e,n){return e.map((function(e,r){return t().createElement("div",c({},X(e,r),{style:$(r,n)}),t().createElement("span",{className:"listSuggestions"},e.name),t().createElement("span",{className:"valueContent"},e.content))}))}(n,e))}(n[0],n[1])}))))}var p=n(379),g=n.n(p),v=n(795),m=n.n(v),b=n(569),h=n.n(b),y=n(565),x=n.n(y),S=n(216),w=n.n(S),E=n(589),C=n.n(E),N=n(649),T={};T.styleTagTransform=C(),T.setAttributes=x(),T.insert=h().bind(null,"head"),T.domAPI=m(),T.insertStyleElement=w(),g()(N.Z,T),N.Z&&N.Z.locals&&N.Z.locals;var A=function(e){return null!=e&&e.groupByGroupName?t().createElement(d,e):t().createElement(u,e)}}(),module.exports=r}(); | ||
!function(){"use strict";var e={649:function(e,t,n){var r=n(81),o=n.n(r),i=n(645),a=n.n(i)()(o());a.push([e.id,"/* COMMON CLASSES FOR BOTH GROUPED AND SIMPLE AUTOSUGGEST */\r\n.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: 70vh;\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\n.suggestionMainContainer {\r\n width: 100%;\r\n height: 100%;\r\n}\r\n\r\n.hoverValueContainer {\r\n min-width: 100px !important;\r\n max-width: 200px !important;\r\n padding: 10px !important;\r\n word-wrap: break-word;\r\n color: white;\r\n background-color: rgb(31, 32, 30);\r\n font-size: 14px !important;\r\n border-radius: 5px;\r\n z-index: 30;\r\n min-height: 20px !important;\r\n max-height: fit-content !important;\r\n}\r\n\r\n.hoverValueContainer::-webkit-scrollbar {\r\n display: none !important;\r\n}\r\n\r\n/* SIMPLE AUTO-SUGGESTIONS CLASSES */\r\n.listSuggestionContainerForSimpleAutosuggest {\r\n list-style-type: none;\r\n font-size: 16px;\r\n padding: 5px;\r\n}\r\n\r\n.listSuggestionContainerForSimpleAutosuggest:hover {\r\n background-color: rgb(128, 128, 128, 0.5);\r\n}\r\n\r\n.listSuggestionTag{\r\n font-size: 16px !important;\r\n}\r\n\r\n.listSuggestionTagContent{\r\n font-size: 12px !important;\r\n}\r\n\r\n/* GROUPED SUGGESTIONS CLASSES */\r\n.listSuggestions {\r\n list-style-type: none;\r\n font-size: 16px !important;\r\n padding: 0px 0px 0px 17px;\r\n}\r\n\r\n.valueContent {\r\n font-size: 12px !important;\r\n list-style-type: none;\r\n margin: 0px 0px 0px 17px;\r\n}\r\n\r\n.ulTag {\r\n font-size: 21px !important;\r\n padding: 5px;\r\n background-color: black;\r\n color: white;\r\n width: 100% !important;\r\n}\r\n\r\n.listSuggestionContainer {\r\n display: flex;\r\n flex-direction: column;\r\n padding: 5px;\r\n}\r\n\r\n.listSuggestionContainer:hover {\r\n background-color: rgb(128, 128, 128, 0.5);\r\n}",""]),t.Z=a},645:function(e){e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,r,o,i){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(r)for(var u=0;u<this.length;u++){var l=this[u][0];null!=l&&(a[l]=!0)}for(var c=0;c<e.length;c++){var s=[].concat(e[c]);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),n&&(s[2]?(s[1]="@media ".concat(s[2]," {").concat(s[1],"}"),s[2]=n):s[2]=n),o&&(s[4]?(s[1]="@supports (".concat(s[4],") {").concat(s[1],"}"),s[4]=o):s[4]="".concat(o)),t.push(s))}},t}},81:function(e){e.exports=function(e){return e[1]}},379:function(e){var t=[];function n(e){for(var n=-1,r=0;r<t.length;r++)if(t[r].identifier===e){n=r;break}return n}function r(e,r){for(var i={},a=[],u=0;u<e.length;u++){var l=e[u],c=r.base?l[0]+r.base:l[0],s=i[c]||0,f="".concat(c," ").concat(s);i[c]=s+1;var d=n(f),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)t[d].references++,t[d].updater(p);else{var g=o(p,r);r.byIndex=u,t.splice(u,0,{identifier:f,updater:g,references:1})}a.push(f)}return a}function o(e,t){var n=t.domAPI(t);return n.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.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=n(i[a]);t[u].references--}for(var l=r(e,o),c=0;c<i.length;c++){var s=n(i[c]);0===t[s].references&&(t[s].updater(),t.splice(s,1))}i=l}}},569:function(e){var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[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(n)}},216:function(e){e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},565:function(e,t,n){e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},795:function(e){e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},589:function(e){e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nc=void 0;var r={};!function(){n.r(r),n.d(r,{default:function(){return A}});var e=require("react"),t=n.n(e);function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,u=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e,t)||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 a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function u(n){var r,a=n.id,u=n.editableDivRef,l=n.suggestion,c=n.chipClass,s=n.editableDivClass,f=n.suggestionBoxClass,d=n.onEnterBtnEvent,p=n.getInputValueWithContext,g=n.setHtml,v=n.setText,m=n.defaultValue,b=n.disable,h=n.valueContainerPosition,y=n.symbolForSearching,x=l||[],S=(0,e.useRef)(),w=(0,e.useRef)(),E=i((0,e.useState)([]),2),C=E[0],N=E[1],T=i((0,e.useState)(-1),2),A=T[0],O=T[1],k=i((0,e.useState)(),2),R=k[0],D=k[1],j=i((0,e.useState)({left:0,top:0}),2),M=j[0],B=j[1],I=i((0,e.useState)(""),2),L=I[0],P=I[1];(0,e.useEffect)((function(){u.current&&(u.current.innerHTML=m||"")}),[u]),(0,e.useEffect)((function(){var e=c||"chip",t=document.getElementsByClassName(e),n=Array.from(t);n.forEach((function(e){V(e)})),n.forEach((function(e){z(e)}))}),[null==u||null===(r=u.current)||void 0===r?void 0:r.innerText.length,c]);var V=function(e){e.addEventListener("mouseenter",(function(e){e.target.getAttribute("walkover-attribute")?P(e.target.getAttribute("walkover-attribute")):P("")}))},z=function(e){e.addEventListener("mouseleave",(function(){P("")}))},H=function(){if(u.current){var e=u.current.innerHTML,t=document.createElement("div");t.innerHTML=e,function(e){for(var t=e.length-1;t>=0;t--){var n=e[t];if(n.getAttribute("walkover-attribute")){var r=n.getAttribute("data-attribute")+" ",o=document.createTextNode(r);n.parentNode.replaceChild(o,n)}}}(t.getElementsByTagName("span")),function(e,t){g&&g((function(){return t})),v&&v(e),p&&p(e,t)}(t.innerText,e)}},U=function(e){var t,n,r,o=window.getSelection(),i=o.anchorNode,a=o.anchorOffset;if(i&&i.nodeType===Node.TEXT_NODE){var l,s,f,d=document.createElement("span");d.className=c||"chip",d.contentEditable="false",d.textContent=e.name,d.setAttribute("walkover-attribute",e.content),d.setAttribute("data-attribute",e.content);var p=i.nodeValue.substring(0,a),g=i.nodeValue.substring(a,i.nodeValue.length),v=p.lastIndexOf(R),m=i.nodeValue.substring(0,v),b=document.createTextNode(m);i.parentNode.insertBefore(b,i),i.parentNode.insertBefore(d,i),(1===(null===(l=g.substring(0,1))||void 0===l?void 0:l.length)&&" "!==(null===(s=g)||void 0===s?void 0:s.substring(0,1))||0===(null===(f=g.substring(0,1))||void 0===f?void 0:f.length))&&(g=" "+g);var h=document.createTextNode(g);i.parentNode.insertBefore(h,i),t=h,0,e.name.length,n=document.createRange(),r=window.getSelection(),n.setStart(t,0),n.collapse(!0),r.removeAllRanges(),r.addRange(n),i.parentNode.removeChild(i)}H(),N([]),setTimeout((function(){u.current&&u.current.focus()}))},G={ref:w,className:"suggestionMainContainer"},F={id:a||"",contentEditable:!0!==b,ref:u,className:s||"editable-div",suppressContentEditableWarning:!0,onKeyDown:function(e){var t,n,r,o,i;"ArrowUp"===e.key?(e.preventDefault(),O((function(e){return-1===e?C.length-1:Math.max(0,e-1)}))):"ArrowDown"===e.key?(e.preventDefault(),O((function(e){return e===C.length-1?0:Math.min(C.length-1,e+1)}))):"Enter"===e.key&&(e.preventDefault(),(t=C[A])?(U(t),O(-1)):d?d():(n=u.current,r=window.getSelection(),o=r.getRangeAt(0),i=document.createElement("br"),o.insertNode(i),o.setStartAfter(i),o.collapse(!0),r.removeAllRanges(),r.addRange(o),n.normalize(),n.focus()))},onInput:function(e){!function(e){if(u.current&&0===u.current.innerText.length)return N([]);H();var t=window.getSelection(),n=t.anchorOffset,r=t.anchorNode.textContent.substring(0,n).trim(),o=function(){if(w.current||u.current){var e=w.current,t=u.current,n=window.getSelection(),r=document.createRange();r.selectNodeContents(t),r.setEnd(n.anchorNode,n.anchorOffset);var o=r.cloneRange();o.collapse(!1);var i=o.getBoundingClientRect(),a=e.getBoundingClientRect(),l=o.getBoundingClientRect().height;return{left:i.left-a.left,top:i.top-a.top+l}}}();B(o);var i=r.split(/ |\u00A0/),a=i[i.length-1],l=a.includes(y);if(a.length>0&&l){var c=a.split(y);c=c[c.length-1],D(y+c);var s=x.filter((function(e){var t;return null==e||null===(t=e.name)||void 0===t?void 0:t.toLowerCase().startsWith(c.trim().toLowerCase())}));N(s),O(-1)}else N([]),O(-1)}()},onPaste:function(e){!function(e){e.preventDefault();var t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)}(e)}},_={position:"absolute",left:M.left,top:M.top,opacity:Object.entries(C).length>0?1:0,zIndex:100},W=function(e){return{background:A===e?"#D3D3D3":"",cursor:"pointer"}};return t().createElement("div",o({},G,{style:{position:"relative"}}),t().createElement("div",F),L.length>0&&t().createElement("div",{ref:S,style:function(){switch(h){case"top":return{position:"absolute",top:void setTimeout((function(){if(S.current)return"-".concat(S.current.offsetHeight,"px")}))};case"bottom":return{position:"absolute",bottom:"100%",top:"100%"};case"left":return{position:"absolute",right:"100%",top:"0px"};case"right":return{position:"absolute",left:"100%",top:"0px"}}}(),className:"hoverValueContainer"},L),t().createElement("div",{className:f||"suggestionBox",style:_},null==C?void 0:C.map((function(e,n){return function(e,n){return t().createElement("div",o({},function(e,t){return{key:t,className:"listSuggestionContainerForSimpleAutosuggest",onMouseDown:function(){return U(e)},onClick:function(){return U(e)}}}(e,n),{style:W(n)}),t().createElement("div",{className:"listSuggestionTag"}," ",e.name," "),t().createElement("div",{className:"listSuggestionTagContent"}," ",e.content," "))}(e,n)}))))}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l.apply(this,arguments)}function c(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,u=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(e,t)||s(e,t)||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 s(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f(e,t):void 0}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function d(n){var r,o=n.id,i=n.editableDivRef,a=n.suggestion,u=n.chipClass,f=n.editableDivClass,d=n.suggestionBoxClass,p=n.onEnterBtnEvent,g=n.getInputValueWithContext,v=n.setHtml,m=n.setText,b=n.defaultValue,h=n.disable,y=n.valueContainerPosition,x=n.symbolForSearching,S=a||[],w=(0,e.useRef)(),E=(0,e.useRef)(),C=c((0,e.useState)({}),2),N=C[0],T=C[1],A=c((0,e.useState)(-1),2),O=A[0],k=A[1],R=c((0,e.useState)(),2),D=R[0],j=R[1],M=c((0,e.useState)({left:0,top:0}),2),B=M[0],I=M[1],L=c((0,e.useState)(""),2),P=L[0],V=L[1],z=c((0,e.useState)(),2),H=z[0],U=z[1];(0,e.useEffect)((function(){i.current&&(i.current.innerHTML=b||"")}),[i]),(0,e.useEffect)((function(){var e=u||"chip",t=document.getElementsByClassName(e),n=Array.from(t);n.forEach((function(e){G(e)})),n.forEach((function(e){F(e)}))}),[null==i||null===(r=i.current)||void 0===r?void 0:r.innerText.length,u]);var G=function(e){e.addEventListener("mouseenter",(function(e){e.target.getAttribute("walkover-attribute")?V(e.target.getAttribute("walkover-attribute")):V("")}))},F=function(e){e.addEventListener("mouseleave",(function(){V("")}))},_=function(){if(i.current){var e=i.current.innerHTML,t=document.createElement("div");t.innerHTML=e,function(e){for(var t=e.length-1;t>=0;t--){var n=e[t];if(n.getAttribute("walkover-attribute")){var r=n.getAttribute("data-attribute")+" ",o=document.createTextNode(r);n.parentNode.replaceChild(o,n)}}}(t.getElementsByTagName("span")),function(e,t){v&&v((function(){return t})),m&&m(e),g&&g(e,t)}(t.innerText,e)}};var W=function(e){if(i.current&&0===i.current.innerText.length)return T([]);_();var t=window.getSelection(),n=t.anchorOffset,r=t.anchorNode.textContent.substring(0,n).trim(),o=function(){if(E.current||i.current){var e=E.current,t=i.current,n=window.getSelection(),r=document.createRange();r.selectNodeContents(t),r.setEnd(n.anchorNode,n.anchorOffset);var o=r.cloneRange();o.collapse(!1);var a=o.getBoundingClientRect(),u=e.getBoundingClientRect(),l=o.getBoundingClientRect().height;return{left:a.left-u.left,top:a.top-u.top+l}}}();I(o);var a=r.split(/ |\u00A0/),u=a[a.length-1],l=u.includes(x);if(u.length>0&&l){var c=u.split(x);c=c[c.length-1],j(x+c);var f=function(e,t){var n,r={},o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=s(e))){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}(e);try{for(o.s();!(n=o.n()).done;){var i=n.value;i.name.toLowerCase().includes(t)&&(r[i.groupName]||(r[i.groupName]=[]),r[i.groupName].push(i))}}catch(e){o.e(e)}finally{o.f()}return r}(S,c.trim().toLowerCase());T(f),k(-1)}else T([]),k(-1)},Z=function(e){var t,n,r,o=window.getSelection(),a=o.anchorNode,l=o.anchorOffset;if(a&&a.nodeType===Node.TEXT_NODE){var c,s,f,d=document.createElement("span");d.className=u||"chip",d.contentEditable="false",d.textContent=e.name,d.setAttribute("walkover-attribute",e.content),d.setAttribute("data-attribute",e.content);var p=a.nodeValue.substring(0,l),g=a.nodeValue.substring(l,a.nodeValue.length),v=p.lastIndexOf(D),m=a.nodeValue.substring(0,v),b=document.createTextNode(m);a.parentNode.insertBefore(b,a),a.parentNode.insertBefore(d,a),(1===(null===(c=g.substring(0,1))||void 0===c?void 0:c.length)&&" "!==(null===(s=g)||void 0===s?void 0:s.substring(0,1))||0===(null===(f=g.substring(0,1))||void 0===f?void 0:f.length))&&(g=" "+g);var h=document.createTextNode(g);a.parentNode.insertBefore(h,a),t=h,0,e.name.length,n=document.createRange(),r=window.getSelection(),n.setStart(t,0),n.collapse(!0),r.removeAllRanges(),r.addRange(n),a.parentNode.removeChild(a)}_(),T([]),setTimeout((function(){i.current&&i.current.focus()}))},q={ref:E,className:"suggestionMainContainer"},K={id:o||"",contentEditable:!0!==h,ref:i,className:f||"editable-div",suppressContentEditableWarning:!0,onKeyDown:function(e){"ArrowUp"===e.key?function(){var e=Object.keys(N),t=e.length-1;if(-1===O){var n=e[t],r=N[n];return U({key:n,index:t}),void k(r.length-1)}if(0===O){var o=H.index-1,i=e[o]||e[t],a=N[i];U({key:i,index:o}),k(a.length-1)}else k((function(e){return e-1}))}():"ArrowDown"===e.key?function(){if(-1===O){var e=Object.keys(N)[0];U({key:e,index:0}),k(0)}else{var t=N[null==H?void 0:H.key];if((null==t?void 0:t.length)-1===O){var n=H.index+1,r=Object.keys(N)[n];r||(r=Object.keys(N)[0],n=0),U({key:r,index:n}),k(0)}else k((function(e){return e+1}))}}():"Enter"===e.key&&(e.preventDefault(),function(){if(0!==Object.keys(N).length&&-1!==O){var e=N[H.key][O];e&&(Z(e),k(-1))}else p?p():(t=i.current,n=window.getSelection(),r=n.getRangeAt(0),o=document.createElement("br"),r.insertNode(o),r.setStartAfter(o),r.collapse(!0),n.removeAllRanges(),n.addRange(r),t.normalize(),t.focus());var t,n,r,o}())},onInput:function(e){W()},onPaste:function(e){!function(e){e.preventDefault();var t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)}(e)}},X={position:"absolute",left:B.left,top:B.top,opacity:Object.entries(N).length>0?1:0,zIndex:100},$=function(e,t){return{key:t,className:"listSuggestionContainer",onMouseDown:function(){return Z(e)},onClick:function(){return Z(e)}}},J=function(e,t){return{background:O===e&&t===H.key?"#D3D3D3":"",cursor:"pointer"}};return t().createElement("div",l({},q,{style:{position:"relative"}}),t().createElement("div",K),P.length>0&&t().createElement("div",{ref:w,style:function(){switch(y){case"top":return{position:"absolute",top:void setTimeout((function(){if(w.current)return"-".concat(w.current.offsetHeight,"px")}))};case"bottom":return{position:"absolute",bottom:"100%",top:"100%"};case"left":return{position:"absolute",right:"100%",top:"0px"};case"right":return{position:"absolute",left:"100%",top:"0px"}}}(),className:"hoverValueContainer"},P),t().createElement("div",{className:d||"suggestionBox",style:X},Object.entries(N).map((function(e){var n=c(e,2);return function(e,n){return t().createElement("div",{className:"groupBlock",key:e},t().createElement("div",{className:"ulTag"},e),function(e,n){return e.map((function(e,r){return t().createElement("div",l({},$(e,r),{style:J(r,n)}),t().createElement("span",{className:"listSuggestions"},e.name),t().createElement("span",{className:"valueContent"},e.content))}))}(n,e))}(n[0],n[1])}))))}var p=n(379),g=n.n(p),v=n(795),m=n.n(v),b=n(569),h=n.n(b),y=n(565),x=n.n(y),S=n(216),w=n.n(S),E=n(589),C=n.n(E),N=n(649),T={};T.styleTagTransform=C(),T.setAttributes=x(),T.insert=h().bind(null,"head"),T.domAPI=m(),T.insertStyleElement=w(),g()(N.Z,T),N.Z&&N.Z.locals&&N.Z.locals;var A=function(e){return null!=e&&e.groupByGroupName?t().createElement(d,e):t().createElement(u,e)}}(),module.exports=r}(); |
{ | ||
"name": "@walkover/autosuggest-custom", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"author": "walkover-web", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -42,2 +42,3 @@ ## CustomAutoSuggest | ||
groupByGroupName={false} | ||
symbolForSearching={'$'} | ||
/> | ||
@@ -52,6 +53,8 @@ | ||
- editableDivRef (Required) : Editable-Div reference which is mandatory to pass in props. | ||
- symbolForSearching (Required) - This prop is required for searching within the suggestions. The field allows you to perform searches only when you have provided a symbol or character to search with. | ||
- id (optional) : CSS id for the Editable-Div. | ||
- editableDivRef (Required) : Editable-Div reference which is mandatory to pass in props. | ||
- chipClass (optional): CSS class name for the suggestion chips. Defaults to 'chip'. | ||
@@ -77,2 +80,3 @@ | ||
### Example | ||
@@ -128,2 +132,3 @@ Here's an example usage of the Simple CustomAutoSuggest component: | ||
groupByGroupName={false} | ||
symbolForSearching={'$'} | ||
/> | ||
@@ -250,2 +255,3 @@ </div> | ||
groupByGroupName={true} | ||
symbolForSearching={'$'} | ||
/> | ||
@@ -252,0 +258,0 @@ </div> |
import React, { useState, useEffect, useRef } from 'react' | ||
export default function GroupedSuggestion({ id, editableDivRef, suggestion, chipClass, editableDivClass, suggestionBoxClass, onEnterBtnEvent, getInputValueWithContext, setHtml, setText, defaultValue, disable, valueContainerPosition }) { | ||
export default function GroupedSuggestion({ id, editableDivRef, suggestion, chipClass, editableDivClass, suggestionBoxClass, onEnterBtnEvent, getInputValueWithContext, setHtml, setText, defaultValue, disable, valueContainerPosition, symbolForSearching }) { | ||
@@ -187,7 +187,14 @@ let suggestions = suggestion || []; | ||
const currentWord = words[words.length - 1]; | ||
if (currentWord.length === 0) return; | ||
setcurrentValuee(currentWord); | ||
const filtered = searchKeys(suggestions, currentWord.trim().toLowerCase()); | ||
setFilteredSuggestions(filtered); | ||
setSelectedSuggestionIndex(-1); | ||
const lastWord = currentWord.includes(symbolForSearching) | ||
if (currentWord.length > 0 && lastWord) { | ||
let searchQuery = currentWord.split(symbolForSearching) | ||
searchQuery = searchQuery[searchQuery.length - 1] | ||
setcurrentValuee(symbolForSearching + searchQuery); | ||
const filtered = searchKeys(suggestions, searchQuery.trim().toLowerCase()); | ||
setFilteredSuggestions(filtered); | ||
setSelectedSuggestionIndex(-1); | ||
} else { | ||
setFilteredSuggestions([]); | ||
setSelectedSuggestionIndex(-1); | ||
} | ||
}; | ||
@@ -194,0 +201,0 @@ |
import React, { useState, useRef, useEffect } from 'react'; | ||
export default function SimpleAutoSuggest({ id, editableDivRef, suggestion, chipClass, editableDivClass, suggestionBoxClass, onEnterBtnEvent, getInputValueWithContext, setHtml, setText, defaultValue, disable, valueContainerPosition }) { | ||
export default function SimpleAutoSuggest({ id, editableDivRef, suggestion, chipClass, editableDivClass, suggestionBoxClass, onEnterBtnEvent, getInputValueWithContext, setHtml, setText, defaultValue, disable, valueContainerPosition,symbolForSearching }) { | ||
@@ -138,3 +138,5 @@ let suggestions = suggestion || []; | ||
const handleInputChange = (e) => { | ||
if (editableDivRef.current && editableDivRef.current.innerText.length === 0) return setFilteredSuggestions([]); | ||
if (editableDivRef.current && editableDivRef.current.innerText.length === 0) { | ||
return setFilteredSuggestions([]); | ||
} | ||
getInputValueWithContent(); | ||
@@ -148,7 +150,16 @@ const sel = window.getSelection(); | ||
const currentWord = words[words.length - 1]; | ||
if (currentWord.length === 0) return | ||
setcurrentValuee(currentWord); | ||
const filtered = suggestions.filter((suggestion) => suggestion?.name?.toLowerCase().startsWith(currentWord.trim().toLowerCase())) | ||
setFilteredSuggestions(filtered); | ||
setSelectedSuggestionIndex(-1); | ||
const lastWord = currentWord.includes(symbolForSearching) | ||
if (currentWord.length > 0 && lastWord) { | ||
let searchQuery = currentWord.split(symbolForSearching) | ||
searchQuery = searchQuery[searchQuery.length - 1] | ||
setcurrentValuee(symbolForSearching+searchQuery); | ||
const filtered = suggestions.filter((suggestion) => | ||
suggestion?.name?.toLowerCase().startsWith(searchQuery.trim().toLowerCase()) | ||
); | ||
setFilteredSuggestions(filtered); | ||
setSelectedSuggestionIndex(-1); | ||
} else { | ||
setFilteredSuggestions([]); | ||
setSelectedSuggestionIndex(-1); | ||
} | ||
}; | ||
@@ -164,3 +175,2 @@ | ||
} | ||
const insertSuggestion = (replace) => { | ||
@@ -167,0 +177,0 @@ const sel = window.getSelection(); |
84615
740
264