adintel-lib-poc
Advanced tools
Comparing version 0.1.16 to 0.1.17
@@ -30,2 +30,5 @@ 'use strict'; | ||
} | ||
function _objectDestructuringEmpty(obj) { | ||
if (obj == null) throw new TypeError("Cannot destructure " + obj); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
@@ -964,3 +967,4 @@ if (!o) return; | ||
handleSearchData = _ref.handleSearchData, | ||
plainQuery = _ref.plainQuery; | ||
plainQuery = _ref.plainQuery, | ||
onChange = _ref.onChange; | ||
var _useState = React.useState(), | ||
@@ -970,6 +974,6 @@ customSearchData = _useState[0], | ||
React.useEffect(function () { | ||
console.log(searchData); | ||
setCustomSearchData(searchData); | ||
}, [searchData]); | ||
var handleOnChange = function handleOnChange() { | ||
var handleOnChange = function handleOnChange(_ref2) { | ||
var args = _extends({}, (_objectDestructuringEmpty(_ref2), _ref2)); | ||
var result = _extends({}, customSearchData, { | ||
@@ -979,2 +983,3 @@ searchResults: [] | ||
setCustomSearchData(result); | ||
onChange(args); | ||
}; | ||
@@ -981,0 +986,0 @@ return React.createElement("div", { |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=require("@fortawesome/react-fontawesome"),r=require("@fortawesome/free-regular-svg-icons");require("flatpickr/dist/themes/material_green.css");var o,a,i=e(require("react-flatpickr")),l=require("@fortawesome/free-solid-svg-icons"),u=require("canvas"),s=e(require("moment"));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}).apply(this,arguments)}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(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return f(e,void 0);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,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(o=exports.buttonSize||(exports.buttonSize={})).small="small",o.medium="medium",o.large="large",(a=exports.buttonVariant||(exports.buttonVariant={})).primary="primary",a.secondary="secondary";var p,m=function(e,t){var n=e.size,r=void 0===n?exports.buttonSize.medium:n,o=e.block,a=e.variant,i=void 0===a?exports.buttonVariant.primary:a,l="c_btn c_btn-"+r;return l=void 0!==o&&o?l+" c_btn-block":l,l=i?l+" c_btn-"+i:l,t?l+" "+t:l},v=function(e){var n=e.type,r=e.children,o=e.customClass,a=e.disabled,i=void 0!==a&&a,l=e.id,u=void 0===l?"":l,s=e.tabIndex,c=void 0===s?0:s,f=e.onKeyDown,d=e.onKeyUp,p=e.autoFocus,v=void 0!==p&&p,b=e.onFocus,h=e.onDoubleClick,C=e.testId;return t.createElement("button",{ref:e.btnRef,type:void 0===n?"button":n,name:e.name,onClick:e.onClick,className:m(e,o),disabled:i,id:u,"aria-label":u,tabIndex:c,onKeyDown:f,onKeyUp:d,autoFocus:v,onFocus:b,onDoubleClick:h,"data-test-id":C||u||"","data-test-class":o||""},r)};!function(e){e.left="left-tooltip",e.top="top-tooltip",e.bottom="bottom-tooltip",e.right="right-tooltip"}(p||(p={}));var b,h=function(e){var n=e.children,r=e.text,o=e.position,a=t.useRef(null),i=t.useRef(null),l=function(){return i.current.style.visibility="visible"},u=function(){return i.current.style.visibility="hidden"};return t.useEffect((function(){var e=a.current;if(e&&(e.addEventListener("mouseenter",l),e.addEventListener("mouseleave",u)),!o){var t=i.current;e&&t&&(t.getBoundingClientRect().top<0&&(e.className="bottom-tooltip"),e.getBoundingClientRect().left+t.getBoundingClientRect().width>screen.width&&(e.className="left-tooltip"))}return function(){return a.current&&a.current.removeEventListener("mouseenter",l)}}),[]),r?t.createElement("div",{ref:a,className:o||"top-tooltip",onClick:function(e){e.stopPropagation(),i.current.style.visibility="hidden"}},n,t.createElement("span",{ref:i,className:"tooltiptext",onMouseEnter:function(e){return e.preventDefault()}},r)):n};!function(e){e.text="text",e.email="email",e.number="number",e.password="password"}(b||(b={}));var C,g,y=function(e){var n=e.id,r=e.customClass,o=e.tabIndex,a=e.disabled,i=void 0!==a&&a,l=e.hasError,u=e.autofocus,s=e.spellCheck;return t.createElement(h,{text:e.title},t.createElement("input",{id:n,"aria-label":n,autoComplete:"off",name:e.name,placeholder:e.placeholder,value:e.value,type:e.type,className:"input "+(void 0!==l&&l?"input-error":"")+(r||"")+" "+(i?"disabled":""),onChange:e.onChange,tabIndex:void 0===o?0:o,disabled:i,autoFocus:void 0!==u&&u,ref:e.reference,onKeyUp:e.onKeyUp,onKeyDown:e.onKeyDown,spellCheck:void 0===s||s,onBlur:e.onBlur,onClick:e.onClick,"data-test-id":n||"","data-test-class":r||"",step:e.step,min:e.min,onKeyPress:e.onKeyPress,maxLength:e.maxLength}))},w=function(e){var o=e.id,a=e.date,u=e.onChange,s=e.clearDate,c=e.disabled;return t.createElement("div",{className:e.small?"date-picker-small":"date-picker"},t.createElement(i,{ref:e.reference,id:o,"data-test-id":o||"",name:e.name,className:e.customClass+" date-picker-input "+(c?" disabled":""),value:a,options:{minDate:e.minDate,maxDate:e.maxDate,dateFormat:"m-d-Y"},placeholder:e.placeholder,autocomplete:"off",disabled:c,"data-selected-date":a,onChange:function(e){u&&u(e[0])}}),t.createElement("div",{className:"icon-container"},a?t.createElement(v,{id:o,customClass:"cross",onClick:s,disabled:c},t.createElement(n.FontAwesomeIcon,{icon:l.faTimes,className:c?"cross-icon disabled":"cross-icon"})):t.createElement("label",{htmlFor:o,className:c?"calender-icon disabled":"calender-icon"},t.createElement(n.FontAwesomeIcon,{icon:r.faCalendarAlt}))))};!function(e){e.singleSelect="singleSelect",e.multiSelect="multiSelect",e.datePicker="datePicker"}(C||(C={})),function(e){e.date="date",e.string="string"}(g||(g={}));var E,k={label:"IN",value:"in",type:"any"},x={label:"BY",value:"by"},S=[{label:"=",value:"=",type:"any"},{label:"<",value:"<",type:"number"},{label:">",value:">",type:"number"},{label:"<=",value:"<=",type:"number"},{label:">=",value:">=",type:"number"},{label:"!=",value:">=",type:"any"},k,{label:"NOT IN",value:"not in",type:"any"}],L=[{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],R=[{label:"AND",value:"and"},{label:"OR",value:"or"},{label:"ORDER BY",value:"order by"}],W={label:"NOT",value:"not"},D=function(e){var n=e.option,r=e.onClick,o=e.focus,a=e.index,i=e.onkeyPressed,l=e.optionRef,u=n.value,s=n.label;return t.useEffect((function(){o&&l&&l.current&&l.current.focus()}),[o]),t.createElement(v,{key:u,btnRef:l,onClick:function(){return r(n)},customClass:"option",tabIndex:0,onKeyDown:function(e){i(e,a)}},t.createElement("div",null,s))};!function(e){e[e.Down=40]="Down",e[e.Up=38]="Up",e[e.Enter=13]="Enter",e[e.Tab=9]="Tab",e[e.Space=32]="Space",e[e.Ctrl=17]="Ctrl",e[e.Right=39]="Right",e[e.Left=37]="Left",e[e.One=49]="One",e[e.Two=50]="Two",e[e.Three=51]="Three",e[e.Period=46]="Period",e[e.Minus=45]="Minus"}(E||(E={}));var I=function(e){var n=e.options,r=e.onOptionClick,o=e.highlight,a=e.setShowResults,i=t.useState(),l=i[0],u=i[1],s=t.useRef([]);t.useEffect((function(){s.current=Array(n.length).fill(null).map((function(e,n){return s.current[n]||t.createRef()}))}),[n]);var c=function(e,t){e.keyCode===E.Down?u(t+1):e.keyCode===E.Up?u(t-1):e.keyCode===E.Tab&&a(!1),s.current[t]&&s.current[t].current&&s.current[t].current.scrollIntoView({block:"center",behavior:"auto"})};return t.createElement("div",{className:"search-body"},n&&n.length>0?t.createElement("div",null,t.createElement("div",{className:"options scroller"},n.map((function(e,n){return t.createElement(D,{key:n,option:e,onClick:r,index:n,focus:l===n,onkeyPressed:c,highlight:o,optionRef:s.current[n]})})))):null)},N=function(e){var n=e.searchResultType,r=e.searchResults,o=e.onOptionClick,a=void 0===o?function(){}:o,i=e.highlight,l=e.setShowResults,u=e.datePickerPosition,c=t.useRef(null),f=t.useState(!1),d=f[0],p=f[1];return t.useEffect((function(){c.current&&n===C.datePicker?(c.current.flatpickr.open(),p(!d)):p(!d)}),[u]),t.useEffect((function(){if(u&&n===C.datePicker&&c.current){var e=parseInt(u.left,10);c.current.flatpickr.calendarContainer.style.left=(e>u.inputLeft?u.inputLeft-50:e)+"px",c.current.flatpickr.open()}}),[d]),n===C.singleSelect?t.createElement(I,{options:r||[],onOptionClick:a,highlight:i,setShowResults:l}):n===C.datePicker?t.createElement(w,{reference:c,date:new Date,onChange:function(e){return a(s(e).format("MM-DD-YYYY"))}}):t.createElement(t.Fragment,null)},A=function(e){return!e||/^\(*(NOT )*(\(*((([A-Za-z]\s*)|('[^']*'\s*))+((?:^|\W)in\s*(\('[^']*'\s*([,]\s*'[^']*'\s*)*\))|(?:^|\W)not\s*in\s*([A-Za-z]+\s*)|(?:^|\W)in\s*([A-Za-z]+\s*)|(?:^|\W)= '[^']*'|(?:^|\W)!= '[^']*'|(?:^|\W)> '[^']*'|(?:^|\W)< '[^']*'|(?:^|\W)<= '[^']*'|(?:^|\W)>= '[^']*'|(?:^|\W)is '[^']*'|(?:^|\W)not is '[^']*')\)*((?:^|\W)AND\W|(?:^|\W)OR\W)+(NOT\W)*)*\(*((([A-Za-z])|('[^']*'))+((?:^|\W)in (\('[^']*' *([,] *'[^']*')*\))|(?:^|\W)in ([A-Za-z]+)|(?:^|\W)not in (\('[^']*'([,]'[^']*')*\))|(?:^|\W)not in ([A-Za-z]+)|(?:^|\W)= '[^']*'|(?:^|\W)!= '[^']*'|(?:^|\W)> '[^']*'|(?:^|\W)< '[^']*'|(?:^|\W)<= '[^']*'|(?:^|\W)>= '[^']*'|(?:^|\W)is '[^']*'|(?:^|\W)not is '[^']*'))*\)*)* *\(*(((ORDER BY '[^']*')*)|((ORDER BY [A-Za-z]*)*) *(ASC|DESC)*)*\)*\)*$/gi.test(e.trim())&&O(e)},O=function(e){for(var t,n=[],r={"(":")"},o=d(e);!(t=o()).done;){var a=t.value;if("("===a&&n.push(a),")"===a&&a!==r[n.pop()])return!1}return 0===n.length},j=function(e){var r=e.customSearchData,o=e.onSearch,a=e.onChange,i=e.onEnterButtonClick,s=e.planeQuery,c=e.onCheckBoxChecked,f=r.columns,p=r.searchResults,m=t.useState(!1),h=m[0],g=m[1],w=t.useState([]),D=w[0],I=w[1],O=t.useState(s?s.split(" "):[]),j=O[0],P=O[1],T=t.useState(null),B=T[0],F=T[1],K=t.useState(C.singleSelect),z=K[0],q=K[1],U=t.useState(null),Y=U[0],V=U[1],M=t.useState({status:!0,position:0}),Z=M[0],_=M[1],$=t.useState({left:0}),Q=$[0],J=$[1],G=t.useRef(),H=j.join(" ");t.useEffect((function(){return document.addEventListener("mousedown",ie),function(){return document.removeEventListener("mousedown",ie)}}),[]),t.useEffect((function(){var e=X();a(e||H,H,A(H))}),[c]),t.useEffect((function(){var e=X();a(e||H,H,A(H))}),[j]),t.useEffect((function(){if(Z&&Z.position&&j.length){var e=[].concat(j);e&&e.length&&(e.splice(Z.position+1,j.length-Z.position),oe(e.join(" ").length))}}),[Z]);var X=function(){var e=H.match(/'.*?'/g),t=e&&e.filter((function(e){return f&&f.find((function(t){return t.label.toLowerCase()===e.split("'").join("").toLowerCase()}))})),n=H.replace(/'.*?'/g,"$"),o=[];r.columns&&r.columns.forEach((function(e){var t=0;n=n.replace(new RegExp(e.label,"gi"),(function(){return t++,e.value.toString()})),t||o.push(e)}));var a=[],i=0;return n.split(" ").forEach((function(n){for(var r,l="",u=d(n);!(r=u()).done;){var s=r.value;if("$"===s){if(t.find((function(t){return t.toLowerCase()===e[i].toLowerCase()}))){var c=o.find((function(t){return e[i].split("'").join("").toLowerCase()===t.label.toLowerCase()}));l+=c?c.value:""}else l+=e[i].toUpperCase();i++}else l+=s}a.push(l)})),a.join(" ")};t.useEffect((function(){B&&p&&(I(p),g(!0))}),[JSON.stringify(r)]);var ee=function(e,t,n){var r=R.find((function(t){return e&&t.label.toLowerCase()===e.toLowerCase()}));if(!e||r)return[].concat(f,[W]);if((e===W.label||e===W.value)&&t)return[k];if(L.find((function(t){return e&&t.label.toLowerCase()===e.toLowerCase()})))return[];if("ORDER"===e||"order"===e)return[x];if(e===x.label||e===x.value)return f;if(e===W.label||e===W.value)return[].concat(f,[W]);var o=f.find((function(t){return t.label.toLowerCase()===re(e,["'","("]).toLowerCase()}));return!o||n!==x.label&&n!==x.value?o&&"string"===o.type?[].concat(S.filter((function(e){return"any"===e.type}))):o&&"date"===o.type?S:S.find((function(t){return t.label.toLowerCase()===e.toLowerCase()}))?[]:R:L},te=function(e){var t=[],n=e.match(/'.*?'/g),r=e.replace(/'.*?'/g,"$").split(" "),o=0;return r.forEach((function(e){for(var r,a="",i=d(e);!(r=i()).done;){var l=r.value;"$"===l?(a+=n[o],o++):a+=l}t.push(a)})),t},ne=function(e){var t=-1,n=0;return e.forEach((function(e,r){for(var o,a=d(e);!(o=a()).done;)"'"===o.value&&(t=r,n++)})),{incompleteWordIndex:t,status:n%2==0}},re=function(e,t){var n="";return t.forEach((function(t){n=n?n.split(t).join(""):e.split(t).join("")})),n},oe=function(e){G.current.setSelectionRange&&(G.current.focus(),G.current.setSelectionRange(e,e))},ae=function(e,t){return[].concat(R,S,[W]).find((function(e){return e.label.toLowerCase()===t.toLowerCase()}))?t:e&&e.toLowerCase()===k.label.toLowerCase()?"('"+t+"'":S.find((function(t){return t.label===e}))?"'"+t+"'":null},ie=function(e){var t=document.getElementById("dynamic-results"),n=document.getElementsByClassName("flatpickr-calendar");if(!t||!t.contains(e.target)){var r=!1;if(Array.from(n).forEach((function(t){t.contains(e.target)&&(r=!0)})),!r)return g(!1)}};return t.createElement("div",{className:"custom-search"},t.createElement(y,{type:b.text,customClass:"custom-search-input",reference:G,value:H,onChange:function(e){!function(e){" "===e&&(I(ee(null,null,null)),g(!0));var t,n,r=function(e){var t=ne(e);if(t.status)return e;var n=t.incompleteWordIndex,r=e.slice(n);return e.splice(n,e.length-n,r.join(" ")),e}(te(e)),a=function(e){var t=e.findIndex((function(e,t){return e!==te(j.join(" ").replace(/ +/g," "))[t]})),n=e[t-1],r=e[t-2];r!==W.label&&r!==W.value||(r=e[t-3]);var o=f.find((function(e){return r&&e.label.toLowerCase()===re(r,["("]).toLowerCase().replace(/\'/gi,"")}));return o&&F(o),{lastExpression:n,modifiedWord:e[t],currentColumn:o,modifiedWordIndex:t,newColumnValue:r}}(r),i=a.lastExpression,l=a.modifiedWord,s=a.currentColumn,c=a.modifiedWordIndex,d=a.newColumnValue;if(s&&"date"===s.type){q(C.datePicker),V({index:c,word:l});var p=r;return p.splice(c+1,r.length-(c+1)),P(r),J({left:(t=p.join(" "),n=u.createCanvas(0,0).getContext("2d"),(n?(n.font="12px system-ui",n.measureText(t).width):0)+76),inputLeft:parseInt(G.current.getBoundingClientRect().left,10)+parseInt(G.current.clientWidth,10)}),void(")"!==l.substr(-1)&&S.find((function(e){return e.label.toLowerCase()===i.toLowerCase()}))?g(!0):g(!1))}var m=r.filter((function(e){return""===e}));q(C.singleSelect);var v=m.length>1?[]:ee(i,s,d);if(!r[l]&&r[c-1]&&"("===r[c-1].substr(0,1)&&r[c-2]&&r[c-2].toLowerCase()===k.label.toLowerCase()&&")"!==r[c-1].substr(-1))r.pop(),I([]);else if(s&&!v.length&&l&&re(l,["'"]).length>=2&&"'"!==l.substr(-1))if("("===l.substr(0,1)){var b=l.replace("(","").split(","),h="",y=ne(b);h=y.status?b[b.length-1]:b[y.incompleteWordIndex],","!==l.substr(-1)&&")"!==l.substr(-1)&&h&&h.split("'").join("").length>=2&&o({searchText:btoa(h.split("'").join("")),id:s.id,currentValueKey:s.value})}else/[a-zA-z]/.test(l.substr(-1))&&o({searchText:btoa(l.split("'").join("")),id:s.id,currentValueKey:s.value});else I(v.filter((function(e){return e.label.toLowerCase().includes(l&&l.split("(").join("")&&l.split("(").join("").toLowerCase())}))),g(!0);V({index:c,word:l}),P(r)}(e.target.value)},onClick:function(){I([]),g(!1)},onKeyUp:function(e){e.keyCode===E.Enter&&A(H)&&H.length&&i()},placeholder:"Find records using search query"}),H.length?t.createElement(v,{customClass:"clear-query",onClick:function(){P([])},tabIndex:h?-1:0},t.createElement(n.FontAwesomeIcon,{icon:l.faTimes})):null,A(H)?t.createElement(n.FontAwesomeIcon,{className:"custom-search-query-status valid",icon:l.faCheckCircle}):t.createElement(n.FontAwesomeIcon,{className:"custom-search-query-status invalid",icon:l.faTimesCircle}),h&&t.createElement("div",{id:"dynamic-results",className:"custom-search-results"},t.createElement(N,{searchResultType:z,searchResults:H.length>0?D:[],onOptionClick:function(e){var t=j[j.length-2],n=null;Y&&(t&&t.toLowerCase()===k.label.toLowerCase()&&Y.word.includes("(")?P(j.map((function(t,r){return r===Y.index?(n=r,""+function(e,t){if("("===e.substr(0,1)){var n=e.replace("(","").split(",");return n.length?(n[n.length-1]="'"+t+"'","("+n):"("+[t]}return""}(Y.word,z===C.datePicker?e:e.label)):t}))):z===C.datePicker?n=function(e,t,n){return P(j.map((function(r,o){return o===Y.index?(n=o,ae(e,t)||(t.includes(" ")?"'"+t+"'":""+t)):r}))),n}(t,e,n):z===C.singleSelect&&(n=function(e,t,n){return P(j.map((function(r,o){return o===Y.index?(n=o,ae(e,t.label)||(f.find((function(e){return e.label.toLowerCase()===t.label.toLowerCase()}))?t.label.includes(" ")?"'"+t.label+"'":t.label:t.label.includes(" ")?"'"+t.label+"'":""+t.label)):r}))),n}(t,e,n))),n&&_({status:!Z.status,position:n}),g(!1),G.current.focus()},setShowResults:g,datePickerPosition:Q})))};exports.Button=v,exports.CustomSearchWrapper=function(e){var n=e.searchData,r=e.handleSearchData,o=e.plainQuery,a=t.useState(),i=a[0],l=a[1];return t.useEffect((function(){console.log(n),l(n)}),[n]),t.createElement("div",{className:"custom-wrapper"},i&&t.createElement(j,{customSearchData:i,onChange:function(){var e=c({},i,{searchResults:[]});l(e)},onCheckBoxChecked:!0,onEnterButtonClick:function(){},onSearch:r,planeQuery:o}))}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=require("@fortawesome/react-fontawesome"),r=require("@fortawesome/free-regular-svg-icons");require("flatpickr/dist/themes/material_green.css");var o,a,i=e(require("react-flatpickr")),l=require("@fortawesome/free-solid-svg-icons"),u=require("canvas"),s=e(require("moment"));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}).apply(this,arguments)}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(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return f(e,void 0);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,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(o=exports.buttonSize||(exports.buttonSize={})).small="small",o.medium="medium",o.large="large",(a=exports.buttonVariant||(exports.buttonVariant={})).primary="primary",a.secondary="secondary";var p,m=function(e,t){var n=e.size,r=void 0===n?exports.buttonSize.medium:n,o=e.block,a=e.variant,i=void 0===a?exports.buttonVariant.primary:a,l="c_btn c_btn-"+r;return l=void 0!==o&&o?l+" c_btn-block":l,l=i?l+" c_btn-"+i:l,t?l+" "+t:l},v=function(e){var n=e.type,r=e.children,o=e.customClass,a=e.disabled,i=void 0!==a&&a,l=e.id,u=void 0===l?"":l,s=e.tabIndex,c=void 0===s?0:s,f=e.onKeyDown,d=e.onKeyUp,p=e.autoFocus,v=void 0!==p&&p,b=e.onFocus,h=e.onDoubleClick,C=e.testId;return t.createElement("button",{ref:e.btnRef,type:void 0===n?"button":n,name:e.name,onClick:e.onClick,className:m(e,o),disabled:i,id:u,"aria-label":u,tabIndex:c,onKeyDown:f,onKeyUp:d,autoFocus:v,onFocus:b,onDoubleClick:h,"data-test-id":C||u||"","data-test-class":o||""},r)};!function(e){e.left="left-tooltip",e.top="top-tooltip",e.bottom="bottom-tooltip",e.right="right-tooltip"}(p||(p={}));var b,h=function(e){var n=e.children,r=e.text,o=e.position,a=t.useRef(null),i=t.useRef(null),l=function(){return i.current.style.visibility="visible"},u=function(){return i.current.style.visibility="hidden"};return t.useEffect((function(){var e=a.current;if(e&&(e.addEventListener("mouseenter",l),e.addEventListener("mouseleave",u)),!o){var t=i.current;e&&t&&(t.getBoundingClientRect().top<0&&(e.className="bottom-tooltip"),e.getBoundingClientRect().left+t.getBoundingClientRect().width>screen.width&&(e.className="left-tooltip"))}return function(){return a.current&&a.current.removeEventListener("mouseenter",l)}}),[]),r?t.createElement("div",{ref:a,className:o||"top-tooltip",onClick:function(e){e.stopPropagation(),i.current.style.visibility="hidden"}},n,t.createElement("span",{ref:i,className:"tooltiptext",onMouseEnter:function(e){return e.preventDefault()}},r)):n};!function(e){e.text="text",e.email="email",e.number="number",e.password="password"}(b||(b={}));var C,g,y=function(e){var n=e.id,r=e.customClass,o=e.tabIndex,a=e.disabled,i=void 0!==a&&a,l=e.hasError,u=e.autofocus,s=e.spellCheck;return t.createElement(h,{text:e.title},t.createElement("input",{id:n,"aria-label":n,autoComplete:"off",name:e.name,placeholder:e.placeholder,value:e.value,type:e.type,className:"input "+(void 0!==l&&l?"input-error":"")+(r||"")+" "+(i?"disabled":""),onChange:e.onChange,tabIndex:void 0===o?0:o,disabled:i,autoFocus:void 0!==u&&u,ref:e.reference,onKeyUp:e.onKeyUp,onKeyDown:e.onKeyDown,spellCheck:void 0===s||s,onBlur:e.onBlur,onClick:e.onClick,"data-test-id":n||"","data-test-class":r||"",step:e.step,min:e.min,onKeyPress:e.onKeyPress,maxLength:e.maxLength}))},w=function(e){var o=e.id,a=e.date,u=e.onChange,s=e.clearDate,c=e.disabled;return t.createElement("div",{className:e.small?"date-picker-small":"date-picker"},t.createElement(i,{ref:e.reference,id:o,"data-test-id":o||"",name:e.name,className:e.customClass+" date-picker-input "+(c?" disabled":""),value:a,options:{minDate:e.minDate,maxDate:e.maxDate,dateFormat:"m-d-Y"},placeholder:e.placeholder,autocomplete:"off",disabled:c,"data-selected-date":a,onChange:function(e){u&&u(e[0])}}),t.createElement("div",{className:"icon-container"},a?t.createElement(v,{id:o,customClass:"cross",onClick:s,disabled:c},t.createElement(n.FontAwesomeIcon,{icon:l.faTimes,className:c?"cross-icon disabled":"cross-icon"})):t.createElement("label",{htmlFor:o,className:c?"calender-icon disabled":"calender-icon"},t.createElement(n.FontAwesomeIcon,{icon:r.faCalendarAlt}))))};!function(e){e.singleSelect="singleSelect",e.multiSelect="multiSelect",e.datePicker="datePicker"}(C||(C={})),function(e){e.date="date",e.string="string"}(g||(g={}));var E,k={label:"IN",value:"in",type:"any"},x={label:"BY",value:"by"},S=[{label:"=",value:"=",type:"any"},{label:"<",value:"<",type:"number"},{label:">",value:">",type:"number"},{label:"<=",value:"<=",type:"number"},{label:">=",value:">=",type:"number"},{label:"!=",value:">=",type:"any"},k,{label:"NOT IN",value:"not in",type:"any"}],L=[{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],R=[{label:"AND",value:"and"},{label:"OR",value:"or"},{label:"ORDER BY",value:"order by"}],W={label:"NOT",value:"not"},D=function(e){var n=e.option,r=e.onClick,o=e.focus,a=e.index,i=e.onkeyPressed,l=e.optionRef,u=n.value,s=n.label;return t.useEffect((function(){o&&l&&l.current&&l.current.focus()}),[o]),t.createElement(v,{key:u,btnRef:l,onClick:function(){return r(n)},customClass:"option",tabIndex:0,onKeyDown:function(e){i(e,a)}},t.createElement("div",null,s))};!function(e){e[e.Down=40]="Down",e[e.Up=38]="Up",e[e.Enter=13]="Enter",e[e.Tab=9]="Tab",e[e.Space=32]="Space",e[e.Ctrl=17]="Ctrl",e[e.Right=39]="Right",e[e.Left=37]="Left",e[e.One=49]="One",e[e.Two=50]="Two",e[e.Three=51]="Three",e[e.Period=46]="Period",e[e.Minus=45]="Minus"}(E||(E={}));var I=function(e){var n=e.options,r=e.onOptionClick,o=e.highlight,a=e.setShowResults,i=t.useState(),l=i[0],u=i[1],s=t.useRef([]);t.useEffect((function(){s.current=Array(n.length).fill(null).map((function(e,n){return s.current[n]||t.createRef()}))}),[n]);var c=function(e,t){e.keyCode===E.Down?u(t+1):e.keyCode===E.Up?u(t-1):e.keyCode===E.Tab&&a(!1),s.current[t]&&s.current[t].current&&s.current[t].current.scrollIntoView({block:"center",behavior:"auto"})};return t.createElement("div",{className:"search-body"},n&&n.length>0?t.createElement("div",null,t.createElement("div",{className:"options scroller"},n.map((function(e,n){return t.createElement(D,{key:n,option:e,onClick:r,index:n,focus:l===n,onkeyPressed:c,highlight:o,optionRef:s.current[n]})})))):null)},N=function(e){var n=e.searchResultType,r=e.searchResults,o=e.onOptionClick,a=void 0===o?function(){}:o,i=e.highlight,l=e.setShowResults,u=e.datePickerPosition,c=t.useRef(null),f=t.useState(!1),d=f[0],p=f[1];return t.useEffect((function(){c.current&&n===C.datePicker?(c.current.flatpickr.open(),p(!d)):p(!d)}),[u]),t.useEffect((function(){if(u&&n===C.datePicker&&c.current){var e=parseInt(u.left,10);c.current.flatpickr.calendarContainer.style.left=(e>u.inputLeft?u.inputLeft-50:e)+"px",c.current.flatpickr.open()}}),[d]),n===C.singleSelect?t.createElement(I,{options:r||[],onOptionClick:a,highlight:i,setShowResults:l}):n===C.datePicker?t.createElement(w,{reference:c,date:new Date,onChange:function(e){return a(s(e).format("MM-DD-YYYY"))}}):t.createElement(t.Fragment,null)},A=function(e){return!e||/^\(*(NOT )*(\(*((([A-Za-z]\s*)|('[^']*'\s*))+((?:^|\W)in\s*(\('[^']*'\s*([,]\s*'[^']*'\s*)*\))|(?:^|\W)not\s*in\s*([A-Za-z]+\s*)|(?:^|\W)in\s*([A-Za-z]+\s*)|(?:^|\W)= '[^']*'|(?:^|\W)!= '[^']*'|(?:^|\W)> '[^']*'|(?:^|\W)< '[^']*'|(?:^|\W)<= '[^']*'|(?:^|\W)>= '[^']*'|(?:^|\W)is '[^']*'|(?:^|\W)not is '[^']*')\)*((?:^|\W)AND\W|(?:^|\W)OR\W)+(NOT\W)*)*\(*((([A-Za-z])|('[^']*'))+((?:^|\W)in (\('[^']*' *([,] *'[^']*')*\))|(?:^|\W)in ([A-Za-z]+)|(?:^|\W)not in (\('[^']*'([,]'[^']*')*\))|(?:^|\W)not in ([A-Za-z]+)|(?:^|\W)= '[^']*'|(?:^|\W)!= '[^']*'|(?:^|\W)> '[^']*'|(?:^|\W)< '[^']*'|(?:^|\W)<= '[^']*'|(?:^|\W)>= '[^']*'|(?:^|\W)is '[^']*'|(?:^|\W)not is '[^']*'))*\)*)* *\(*(((ORDER BY '[^']*')*)|((ORDER BY [A-Za-z]*)*) *(ASC|DESC)*)*\)*\)*$/gi.test(e.trim())&&O(e)},O=function(e){for(var t,n=[],r={"(":")"},o=d(e);!(t=o()).done;){var a=t.value;if("("===a&&n.push(a),")"===a&&a!==r[n.pop()])return!1}return 0===n.length},j=function(e){var r=e.customSearchData,o=e.onSearch,a=e.onChange,i=e.onEnterButtonClick,s=e.planeQuery,c=e.onCheckBoxChecked,f=r.columns,p=r.searchResults,m=t.useState(!1),h=m[0],g=m[1],w=t.useState([]),D=w[0],I=w[1],O=t.useState(s?s.split(" "):[]),j=O[0],P=O[1],T=t.useState(null),B=T[0],F=T[1],K=t.useState(C.singleSelect),z=K[0],q=K[1],U=t.useState(null),Y=U[0],V=U[1],M=t.useState({status:!0,position:0}),Z=M[0],_=M[1],$=t.useState({left:0}),Q=$[0],J=$[1],G=t.useRef(),H=j.join(" ");t.useEffect((function(){return document.addEventListener("mousedown",ie),function(){return document.removeEventListener("mousedown",ie)}}),[]),t.useEffect((function(){var e=X();a(e||H,H,A(H))}),[c]),t.useEffect((function(){var e=X();a(e||H,H,A(H))}),[j]),t.useEffect((function(){if(Z&&Z.position&&j.length){var e=[].concat(j);e&&e.length&&(e.splice(Z.position+1,j.length-Z.position),oe(e.join(" ").length))}}),[Z]);var X=function(){var e=H.match(/'.*?'/g),t=e&&e.filter((function(e){return f&&f.find((function(t){return t.label.toLowerCase()===e.split("'").join("").toLowerCase()}))})),n=H.replace(/'.*?'/g,"$"),o=[];r.columns&&r.columns.forEach((function(e){var t=0;n=n.replace(new RegExp(e.label,"gi"),(function(){return t++,e.value.toString()})),t||o.push(e)}));var a=[],i=0;return n.split(" ").forEach((function(n){for(var r,l="",u=d(n);!(r=u()).done;){var s=r.value;if("$"===s){if(t.find((function(t){return t.toLowerCase()===e[i].toLowerCase()}))){var c=o.find((function(t){return e[i].split("'").join("").toLowerCase()===t.label.toLowerCase()}));l+=c?c.value:""}else l+=e[i].toUpperCase();i++}else l+=s}a.push(l)})),a.join(" ")};t.useEffect((function(){B&&p&&(I(p),g(!0))}),[JSON.stringify(r)]);var ee=function(e,t,n){var r=R.find((function(t){return e&&t.label.toLowerCase()===e.toLowerCase()}));if(!e||r)return[].concat(f,[W]);if((e===W.label||e===W.value)&&t)return[k];if(L.find((function(t){return e&&t.label.toLowerCase()===e.toLowerCase()})))return[];if("ORDER"===e||"order"===e)return[x];if(e===x.label||e===x.value)return f;if(e===W.label||e===W.value)return[].concat(f,[W]);var o=f.find((function(t){return t.label.toLowerCase()===re(e,["'","("]).toLowerCase()}));return!o||n!==x.label&&n!==x.value?o&&"string"===o.type?[].concat(S.filter((function(e){return"any"===e.type}))):o&&"date"===o.type?S:S.find((function(t){return t.label.toLowerCase()===e.toLowerCase()}))?[]:R:L},te=function(e){var t=[],n=e.match(/'.*?'/g),r=e.replace(/'.*?'/g,"$").split(" "),o=0;return r.forEach((function(e){for(var r,a="",i=d(e);!(r=i()).done;){var l=r.value;"$"===l?(a+=n[o],o++):a+=l}t.push(a)})),t},ne=function(e){var t=-1,n=0;return e.forEach((function(e,r){for(var o,a=d(e);!(o=a()).done;)"'"===o.value&&(t=r,n++)})),{incompleteWordIndex:t,status:n%2==0}},re=function(e,t){var n="";return t.forEach((function(t){n=n?n.split(t).join(""):e.split(t).join("")})),n},oe=function(e){G.current.setSelectionRange&&(G.current.focus(),G.current.setSelectionRange(e,e))},ae=function(e,t){return[].concat(R,S,[W]).find((function(e){return e.label.toLowerCase()===t.toLowerCase()}))?t:e&&e.toLowerCase()===k.label.toLowerCase()?"('"+t+"'":S.find((function(t){return t.label===e}))?"'"+t+"'":null},ie=function(e){var t=document.getElementById("dynamic-results"),n=document.getElementsByClassName("flatpickr-calendar");if(!t||!t.contains(e.target)){var r=!1;if(Array.from(n).forEach((function(t){t.contains(e.target)&&(r=!0)})),!r)return g(!1)}};return t.createElement("div",{className:"custom-search"},t.createElement(y,{type:b.text,customClass:"custom-search-input",reference:G,value:H,onChange:function(e){!function(e){" "===e&&(I(ee(null,null,null)),g(!0));var t,n,r=function(e){var t=ne(e);if(t.status)return e;var n=t.incompleteWordIndex,r=e.slice(n);return e.splice(n,e.length-n,r.join(" ")),e}(te(e)),a=function(e){var t=e.findIndex((function(e,t){return e!==te(j.join(" ").replace(/ +/g," "))[t]})),n=e[t-1],r=e[t-2];r!==W.label&&r!==W.value||(r=e[t-3]);var o=f.find((function(e){return r&&e.label.toLowerCase()===re(r,["("]).toLowerCase().replace(/\'/gi,"")}));return o&&F(o),{lastExpression:n,modifiedWord:e[t],currentColumn:o,modifiedWordIndex:t,newColumnValue:r}}(r),i=a.lastExpression,l=a.modifiedWord,s=a.currentColumn,c=a.modifiedWordIndex,d=a.newColumnValue;if(s&&"date"===s.type){q(C.datePicker),V({index:c,word:l});var p=r;return p.splice(c+1,r.length-(c+1)),P(r),J({left:(t=p.join(" "),n=u.createCanvas(0,0).getContext("2d"),(n?(n.font="12px system-ui",n.measureText(t).width):0)+76),inputLeft:parseInt(G.current.getBoundingClientRect().left,10)+parseInt(G.current.clientWidth,10)}),void(")"!==l.substr(-1)&&S.find((function(e){return e.label.toLowerCase()===i.toLowerCase()}))?g(!0):g(!1))}var m=r.filter((function(e){return""===e}));q(C.singleSelect);var v=m.length>1?[]:ee(i,s,d);if(!r[l]&&r[c-1]&&"("===r[c-1].substr(0,1)&&r[c-2]&&r[c-2].toLowerCase()===k.label.toLowerCase()&&")"!==r[c-1].substr(-1))r.pop(),I([]);else if(s&&!v.length&&l&&re(l,["'"]).length>=2&&"'"!==l.substr(-1))if("("===l.substr(0,1)){var b=l.replace("(","").split(","),h="",y=ne(b);h=y.status?b[b.length-1]:b[y.incompleteWordIndex],","!==l.substr(-1)&&")"!==l.substr(-1)&&h&&h.split("'").join("").length>=2&&o({searchText:btoa(h.split("'").join("")),id:s.id,currentValueKey:s.value})}else/[a-zA-z]/.test(l.substr(-1))&&o({searchText:btoa(l.split("'").join("")),id:s.id,currentValueKey:s.value});else I(v.filter((function(e){return e.label.toLowerCase().includes(l&&l.split("(").join("")&&l.split("(").join("").toLowerCase())}))),g(!0);V({index:c,word:l}),P(r)}(e.target.value)},onClick:function(){I([]),g(!1)},onKeyUp:function(e){e.keyCode===E.Enter&&A(H)&&H.length&&i()},placeholder:"Find records using search query"}),H.length?t.createElement(v,{customClass:"clear-query",onClick:function(){P([])},tabIndex:h?-1:0},t.createElement(n.FontAwesomeIcon,{icon:l.faTimes})):null,A(H)?t.createElement(n.FontAwesomeIcon,{className:"custom-search-query-status valid",icon:l.faCheckCircle}):t.createElement(n.FontAwesomeIcon,{className:"custom-search-query-status invalid",icon:l.faTimesCircle}),h&&t.createElement("div",{id:"dynamic-results",className:"custom-search-results"},t.createElement(N,{searchResultType:z,searchResults:H.length>0?D:[],onOptionClick:function(e){var t=j[j.length-2],n=null;Y&&(t&&t.toLowerCase()===k.label.toLowerCase()&&Y.word.includes("(")?P(j.map((function(t,r){return r===Y.index?(n=r,""+function(e,t){if("("===e.substr(0,1)){var n=e.replace("(","").split(",");return n.length?(n[n.length-1]="'"+t+"'","("+n):"("+[t]}return""}(Y.word,z===C.datePicker?e:e.label)):t}))):z===C.datePicker?n=function(e,t,n){return P(j.map((function(r,o){return o===Y.index?(n=o,ae(e,t)||(t.includes(" ")?"'"+t+"'":""+t)):r}))),n}(t,e,n):z===C.singleSelect&&(n=function(e,t,n){return P(j.map((function(r,o){return o===Y.index?(n=o,ae(e,t.label)||(f.find((function(e){return e.label.toLowerCase()===t.label.toLowerCase()}))?t.label.includes(" ")?"'"+t.label+"'":t.label:t.label.includes(" ")?"'"+t.label+"'":""+t.label)):r}))),n}(t,e,n))),n&&_({status:!Z.status,position:n}),g(!1),G.current.focus()},setShowResults:g,datePickerPosition:Q})))};exports.Button=v,exports.CustomSearchWrapper=function(e){var n=e.searchData,r=e.handleSearchData,o=e.plainQuery,a=e.onChange,i=t.useState(),l=i[0],u=i[1];return t.useEffect((function(){u(n)}),[n]),t.createElement("div",{className:"custom-wrapper"},l&&t.createElement(j,{customSearchData:l,onChange:function(e){var t=c({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(e),e)),n=c({},l,{searchResults:[]});u(n),a(t)},onCheckBoxChecked:!0,onEnterButtonClick:function(){},onSearch:r,planeQuery:o}))}; | ||
//# sourceMappingURL=adintel-lib-poc.cjs.production.min.js.map |
@@ -24,2 +24,5 @@ import { createElement, useRef, useEffect, useState, createRef, Fragment } from 'react'; | ||
} | ||
function _objectDestructuringEmpty(obj) { | ||
if (obj == null) throw new TypeError("Cannot destructure " + obj); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
@@ -960,3 +963,4 @@ if (!o) return; | ||
handleSearchData = _ref.handleSearchData, | ||
plainQuery = _ref.plainQuery; | ||
plainQuery = _ref.plainQuery, | ||
onChange = _ref.onChange; | ||
var _useState = useState(), | ||
@@ -966,6 +970,6 @@ customSearchData = _useState[0], | ||
useEffect(function () { | ||
console.log(searchData); | ||
setCustomSearchData(searchData); | ||
}, [searchData]); | ||
var handleOnChange = function handleOnChange() { | ||
var handleOnChange = function handleOnChange(_ref2) { | ||
var args = _extends({}, (_objectDestructuringEmpty(_ref2), _ref2)); | ||
var result = _extends({}, customSearchData, { | ||
@@ -975,2 +979,3 @@ searchResults: [] | ||
setCustomSearchData(result); | ||
onChange(args); | ||
}; | ||
@@ -977,0 +982,0 @@ return createElement("div", { |
/// <reference types="react" /> | ||
import './search.scss'; | ||
export declare const CustomSearchWrapper: ({ searchData, handleSearchData, plainQuery }: { | ||
export interface CustomSearchWrapperProps { | ||
searchData: any; | ||
handleSearchData: any; | ||
plainQuery: string; | ||
}) => JSX.Element; | ||
onChange: any; | ||
} | ||
export declare const CustomSearchWrapper: ({ searchData, handleSearchData, plainQuery, onChange }: CustomSearchWrapperProps) => JSX.Element; |
{ | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
618775
3720