dropdowns-js 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dropdowns-js.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),z=require("react");function _e(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var oe={exports:{}},ie={exports:{}},U={};var he;function Ie(){if(he)return U;he=1;var i=typeof Symbol=="function"&&Symbol.for,T=i?Symbol.for("react.element"):60103,A=i?Symbol.for("react.portal"):60106,v=i?Symbol.for("react.fragment"):60107,j=i?Symbol.for("react.strict_mode"):60108,p=i?Symbol.for("react.profiler"):60114,w=i?Symbol.for("react.provider"):60109,y=i?Symbol.for("react.context"):60110,S=i?Symbol.for("react.async_mode"):60111,g=i?Symbol.for("react.concurrent_mode"):60111,x=i?Symbol.for("react.forward_ref"):60112,m=i?Symbol.for("react.suspense"):60113,$=i?Symbol.for("react.suspense_list"):60120,O=i?Symbol.for("react.memo"):60115,B=i?Symbol.for("react.lazy"):60116,C=i?Symbol.for("react.block"):60121,q=i?Symbol.for("react.fundamental"):60117,W=i?Symbol.for("react.responder"):60118,X=i?Symbol.for("react.scope"):60119;function D(s){if(typeof s=="object"&&s!==null){var G=s.$$typeof;switch(G){case T:switch(s=s.type,s){case S:case g:case v:case p:case j:case m:return s;default:switch(s=s&&s.$$typeof,s){case y:case x:case B:case O:case w:return s;default:return G}}case A:return G}}}function R(s){return D(s)===g}return U.AsyncMode=S,U.ConcurrentMode=g,U.ContextConsumer=y,U.ContextProvider=w,U.Element=T,U.ForwardRef=x,U.Fragment=v,U.Lazy=B,U.Memo=O,U.Portal=A,U.Profiler=p,U.StrictMode=j,U.Suspense=m,U.isAsyncMode=function(s){return R(s)||D(s)===S},U.isConcurrentMode=R,U.isContextConsumer=function(s){return D(s)===y},U.isContextProvider=function(s){return D(s)===w},U.isElement=function(s){return typeof s=="object"&&s!==null&&s.$$typeof===T},U.isForwardRef=function(s){return D(s)===x},U.isFragment=function(s){return D(s)===v},U.isLazy=function(s){return D(s)===B},U.isMemo=function(s){return D(s)===O},U.isPortal=function(s){return D(s)===A},U.isProfiler=function(s){return D(s)===p},U.isStrictMode=function(s){return D(s)===j},U.isSuspense=function(s){return D(s)===m},U.isValidElementType=function(s){return typeof s=="string"||typeof s=="function"||s===v||s===g||s===p||s===j||s===m||s===$||typeof s=="object"&&s!==null&&(s.$$typeof===B||s.$$typeof===O||s.$$typeof===w||s.$$typeof===y||s.$$typeof===x||s.$$typeof===q||s.$$typeof===W||s.$$typeof===X||s.$$typeof===C)},U.typeOf=D,U}var F={};var ye;function De(){return ye||(ye=1,process.env.NODE_ENV!=="production"&&(function(){var i=typeof Symbol=="function"&&Symbol.for,T=i?Symbol.for("react.element"):60103,A=i?Symbol.for("react.portal"):60106,v=i?Symbol.for("react.fragment"):60107,j=i?Symbol.for("react.strict_mode"):60108,p=i?Symbol.for("react.profiler"):60114,w=i?Symbol.for("react.provider"):60109,y=i?Symbol.for("react.context"):60110,S=i?Symbol.for("react.async_mode"):60111,g=i?Symbol.for("react.concurrent_mode"):60111,x=i?Symbol.for("react.forward_ref"):60112,m=i?Symbol.for("react.suspense"):60113,$=i?Symbol.for("react.suspense_list"):60120,O=i?Symbol.for("react.memo"):60115,B=i?Symbol.for("react.lazy"):60116,C=i?Symbol.for("react.block"):60121,q=i?Symbol.for("react.fundamental"):60117,W=i?Symbol.for("react.responder"):60118,X=i?Symbol.for("react.scope"):60119;function D(d){return typeof d=="string"||typeof d=="function"||d===v||d===g||d===p||d===j||d===m||d===$||typeof d=="object"&&d!==null&&(d.$$typeof===B||d.$$typeof===O||d.$$typeof===w||d.$$typeof===y||d.$$typeof===x||d.$$typeof===q||d.$$typeof===W||d.$$typeof===X||d.$$typeof===C)}function R(d){if(typeof d=="object"&&d!==null){var te=d.$$typeof;switch(te){case T:var ne=d.type;switch(ne){case S:case g:case v:case p:case j:case m:return ne;default:var pe=ne&&ne.$$typeof;switch(pe){case y:case x:case B:case O:case w:return pe;default:return te}}case A:return te}}}var s=S,G=g,Q=y,Z=w,e=T,t=x,a=v,o=B,r=O,u=A,c=p,M=j,K=m,h=!1;function H(d){return h||(h=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),n(d)||R(d)===S}function n(d){return R(d)===g}function f(d){return R(d)===y}function k(d){return R(d)===w}function _(d){return typeof d=="object"&&d!==null&&d.$$typeof===T}function E(d){return R(d)===x}function N(d){return R(d)===v}function P(d){return R(d)===B}function I(d){return R(d)===O}function L(d){return R(d)===A}function V(d){return R(d)===p}function Y(d){return R(d)===j}function ee(d){return R(d)===m}F.AsyncMode=s,F.ConcurrentMode=G,F.ContextConsumer=Q,F.ContextProvider=Z,F.Element=e,F.ForwardRef=t,F.Fragment=a,F.Lazy=o,F.Memo=r,F.Portal=u,F.Profiler=c,F.StrictMode=M,F.Suspense=K,F.isAsyncMode=H,F.isConcurrentMode=n,F.isContextConsumer=f,F.isContextProvider=k,F.isElement=_,F.isForwardRef=E,F.isFragment=N,F.isLazy=P,F.isMemo=I,F.isPortal=L,F.isProfiler=V,F.isStrictMode=Y,F.isSuspense=ee,F.isValidElementType=D,F.typeOf=R})()),F}var ge;function Te(){return ge||(ge=1,process.env.NODE_ENV==="production"?ie.exports=Ie():ie.exports=De()),ie.exports}var se,me;function Me(){if(me)return se;me=1;var i=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;function v(p){if(p==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(p)}function j(){try{if(!Object.assign)return!1;var p=new String("abc");if(p[5]="de",Object.getOwnPropertyNames(p)[0]==="5")return!1;for(var w={},y=0;y<10;y++)w["_"+String.fromCharCode(y)]=y;var S=Object.getOwnPropertyNames(w).map(function(x){return w[x]});if(S.join("")!=="0123456789")return!1;var g={};return"abcdefghijklmnopqrst".split("").forEach(function(x){g[x]=x}),Object.keys(Object.assign({},g)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return se=j()?Object.assign:function(p,w){for(var y,S=v(p),g,x=1;x<arguments.length;x++){y=Object(arguments[x]);for(var m in y)T.call(y,m)&&(S[m]=y[m]);if(i){g=i(y);for(var $=0;$<g.length;$++)A.call(y,g[$])&&(S[g[$]]=y[g[$]])}}return S},se}var ae,ve;function fe(){if(ve)return ae;ve=1;var i="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ae=i,ae}var ue,be;function Ee(){return be||(be=1,ue=Function.call.bind(Object.prototype.hasOwnProperty)),ue}var ce,we;function ke(){if(we)return ce;we=1;var i=function(){};if(process.env.NODE_ENV!=="production"){var T=fe(),A={},v=Ee();i=function(p){var w="Warning: "+p;typeof console<"u"&&console.error(w);try{throw new Error(w)}catch{}}}function j(p,w,y,S,g){if(process.env.NODE_ENV!=="production"){for(var x in p)if(v(p,x)){var m;try{if(typeof p[x]!="function"){var $=Error((S||"React class")+": "+y+" type `"+x+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof p[x]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw $.name="Invariant Violation",$}m=p[x](w,x,S,y,null,T)}catch(B){m=B}if(m&&!(m instanceof Error)&&i((S||"React class")+": type specification of "+y+" `"+x+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof m+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),m instanceof Error&&!(m.message in A)){A[m.message]=!0;var O=g?g():"";i("Failed "+y+" type: "+m.message+(O??""))}}}}return j.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(A={})},ce=j,ce}var le,Se;function qe(){if(Se)return le;Se=1;var i=Te(),T=Me(),A=fe(),v=Ee(),j=ke(),p=function(){};process.env.NODE_ENV!=="production"&&(p=function(y){var S="Warning: "+y;typeof console<"u"&&console.error(S);try{throw new Error(S)}catch{}});function w(){return null}return le=function(y,S){var g=typeof Symbol=="function"&&Symbol.iterator,x="@@iterator";function m(n){var f=n&&(g&&n[g]||n[x]);if(typeof f=="function")return f}var $="<<anonymous>>",O={array:W("array"),bigint:W("bigint"),bool:W("boolean"),func:W("function"),number:W("number"),object:W("object"),string:W("string"),symbol:W("symbol"),any:X(),arrayOf:D,element:R(),elementType:s(),instanceOf:G,node:t(),objectOf:Z,oneOf:Q,oneOfType:e,shape:o,exact:r};function B(n,f){return n===f?n!==0||1/n===1/f:n!==n&&f!==f}function C(n,f){this.message=n,this.data=f&&typeof f=="object"?f:{},this.stack=""}C.prototype=Error.prototype;function q(n){if(process.env.NODE_ENV!=="production")var f={},k=0;function _(N,P,I,L,V,Y,ee){if(L=L||$,Y=Y||I,ee!==A){if(S){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var te=L+":"+I;!f[te]&&k<3&&(p("You are manually calling a React.PropTypes validation function for the `"+Y+"` prop on `"+L+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),f[te]=!0,k++)}}return P[I]==null?N?P[I]===null?new C("The "+V+" `"+Y+"` is marked as required "+("in `"+L+"`, but its value is `null`.")):new C("The "+V+" `"+Y+"` is marked as required in "+("`"+L+"`, but its value is `undefined`.")):null:n(P,I,L,V,Y)}var E=_.bind(null,!1);return E.isRequired=_.bind(null,!0),E}function W(n){function f(k,_,E,N,P,I){var L=k[_],V=M(L);if(V!==n){var Y=K(L);return new C("Invalid "+N+" `"+P+"` of type "+("`"+Y+"` supplied to `"+E+"`, expected ")+("`"+n+"`."),{expectedType:n})}return null}return q(f)}function X(){return q(w)}function D(n){function f(k,_,E,N,P){if(typeof n!="function")return new C("Property `"+P+"` of component `"+E+"` has invalid PropType notation inside arrayOf.");var I=k[_];if(!Array.isArray(I)){var L=M(I);return new C("Invalid "+N+" `"+P+"` of type "+("`"+L+"` supplied to `"+E+"`, expected an array."))}for(var V=0;V<I.length;V++){var Y=n(I,V,E,N,P+"["+V+"]",A);if(Y instanceof Error)return Y}return null}return q(f)}function R(){function n(f,k,_,E,N){var P=f[k];if(!y(P)){var I=M(P);return new C("Invalid "+E+" `"+N+"` of type "+("`"+I+"` supplied to `"+_+"`, expected a single ReactElement."))}return null}return q(n)}function s(){function n(f,k,_,E,N){var P=f[k];if(!i.isValidElementType(P)){var I=M(P);return new C("Invalid "+E+" `"+N+"` of type "+("`"+I+"` supplied to `"+_+"`, expected a single ReactElement type."))}return null}return q(n)}function G(n){function f(k,_,E,N,P){if(!(k[_]instanceof n)){var I=n.name||$,L=H(k[_]);return new C("Invalid "+N+" `"+P+"` of type "+("`"+L+"` supplied to `"+E+"`, expected ")+("instance of `"+I+"`."))}return null}return q(f)}function Q(n){if(!Array.isArray(n))return process.env.NODE_ENV!=="production"&&(arguments.length>1?p("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):p("Invalid argument supplied to oneOf, expected an array.")),w;function f(k,_,E,N,P){for(var I=k[_],L=0;L<n.length;L++)if(B(I,n[L]))return null;var V=JSON.stringify(n,function(ee,d){var te=K(d);return te==="symbol"?String(d):d});return new C("Invalid "+N+" `"+P+"` of value `"+String(I)+"` "+("supplied to `"+E+"`, expected one of "+V+"."))}return q(f)}function Z(n){function f(k,_,E,N,P){if(typeof n!="function")return new C("Property `"+P+"` of component `"+E+"` has invalid PropType notation inside objectOf.");var I=k[_],L=M(I);if(L!=="object")return new C("Invalid "+N+" `"+P+"` of type "+("`"+L+"` supplied to `"+E+"`, expected an object."));for(var V in I)if(v(I,V)){var Y=n(I,V,E,N,P+"."+V,A);if(Y instanceof Error)return Y}return null}return q(f)}function e(n){if(!Array.isArray(n))return process.env.NODE_ENV!=="production"&&p("Invalid argument supplied to oneOfType, expected an instance of array."),w;for(var f=0;f<n.length;f++){var k=n[f];if(typeof k!="function")return p("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+h(k)+" at index "+f+"."),w}function _(E,N,P,I,L){for(var V=[],Y=0;Y<n.length;Y++){var ee=n[Y],d=ee(E,N,P,I,L,A);if(d==null)return null;d.data&&v(d.data,"expectedType")&&V.push(d.data.expectedType)}var te=V.length>0?", expected one of type ["+V.join(", ")+"]":"";return new C("Invalid "+I+" `"+L+"` supplied to "+("`"+P+"`"+te+"."))}return q(_)}function t(){function n(f,k,_,E,N){return u(f[k])?null:new C("Invalid "+E+" `"+N+"` supplied to "+("`"+_+"`, expected a ReactNode."))}return q(n)}function a(n,f,k,_,E){return new C((n||"React class")+": "+f+" type `"+k+"."+_+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+E+"`.")}function o(n){function f(k,_,E,N,P){var I=k[_],L=M(I);if(L!=="object")return new C("Invalid "+N+" `"+P+"` of type `"+L+"` "+("supplied to `"+E+"`, expected `object`."));for(var V in n){var Y=n[V];if(typeof Y!="function")return a(E,N,P,V,K(Y));var ee=Y(I,V,E,N,P+"."+V,A);if(ee)return ee}return null}return q(f)}function r(n){function f(k,_,E,N,P){var I=k[_],L=M(I);if(L!=="object")return new C("Invalid "+N+" `"+P+"` of type `"+L+"` "+("supplied to `"+E+"`, expected `object`."));var V=T({},k[_],n);for(var Y in V){var ee=n[Y];if(v(n,Y)&&typeof ee!="function")return a(E,N,P,Y,K(ee));if(!ee)return new C("Invalid "+N+" `"+P+"` key `"+Y+"` supplied to `"+E+"`.\nBad object: "+JSON.stringify(k[_],null," ")+`
|
|
2
2
|
Valid keys: `+JSON.stringify(Object.keys(n),null," "));var d=ee(I,Y,E,N,P+"."+Y,A);if(d)return d}return null}return q(f)}function u(n){switch(typeof n){case"number":case"string":case"undefined":return!0;case"boolean":return!n;case"object":if(Array.isArray(n))return n.every(u);if(n===null||y(n))return!0;var f=m(n);if(f){var k=f.call(n),_;if(f!==n.entries){for(;!(_=k.next()).done;)if(!u(_.value))return!1}else for(;!(_=k.next()).done;){var E=_.value;if(E&&!u(E[1]))return!1}}else return!1;return!0;default:return!1}}function c(n,f){return n==="symbol"?!0:f?f["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&f instanceof Symbol:!1}function M(n){var f=typeof n;return Array.isArray(n)?"array":n instanceof RegExp?"object":c(f,n)?"symbol":f}function K(n){if(typeof n>"u"||n===null)return""+n;var f=M(n);if(f==="object"){if(n instanceof Date)return"date";if(n instanceof RegExp)return"regexp"}return f}function h(n){var f=K(n);switch(f){case"array":case"object":return"an "+f;case"boolean":case"date":case"regexp":return"a "+f;default:return f}}function H(n){return!n.constructor||!n.constructor.name?$:n.constructor.name}return O.checkPropTypes=j,O.resetWarningCache=j.resetWarningCache,O.PropTypes=O,O},le}var de,xe;function Ae(){if(xe)return de;xe=1;var i=fe();function T(){}function A(){}return A.resetWarningCache=T,de=function(){function v(w,y,S,g,x,m){if(m!==i){var $=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw $.name="Invariant Violation",$}}v.isRequired=v;function j(){return v}var p={array:v,bigint:v,bool:v,func:v,number:v,object:v,string:v,symbol:v,any:v,arrayOf:j,element:v,elementType:v,instanceOf:j,node:v,objectOf:j,oneOf:j,oneOfType:j,shape:j,exact:j,checkPropTypes:A,resetWarningCache:T};return p.PropTypes=p,p},de}var je;function ze(){if(je)return oe.exports;if(je=1,process.env.NODE_ENV!=="production"){var i=Te(),T=!0;oe.exports=qe()(i.isElement,T)}else oe.exports=Ae()();return oe.exports}var Ne=ze();const l=_e(Ne);var J={},Ce;function Le(){if(Ce)return J;Ce=1;function i(e){return e?/^[a-zA-Z][a-zA-Z0-9_-]{2,50}$/.test(e):!1}J.isValidUserName=i;function T(e){return e?/^[A-Za-z' -]{2,50}$/.test(e):!1}J.isValidName=T;function A(e){return e?/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e):!1}J.isValidEmail=A;function v(e){return e?/^[0-9]{10,15}$/g.test(e):!1}J.isValidPhoneNum=v;function j(e){return e?/^[a-zA-Z0-9.\-\(\) ]{2,}$/.test(e):!1}J.isValidOrganisationName=j;function p(e){return!(!e||e.length<6||/[A-Z]/.test(e)===!1||/[a-z]/.test(e)===!1||/[0-9]/.test(e)===!1||/[\s]/.test(e)||/[\][!"#$%&'()*+,./:;<=>?@^\\_`{|}~-]/.test(e)===!1)}J.isValidPassword=p;function w(e){let t=e.getFullYear(),a=e.getMonth()+1;a=S(a,2);let o=e.getDate();return o=S(o,2),`${t}-${a}-${o}`}J.timeStampYyyyMmDd=w;function y(e){let t=S(e.getHours(),2),a=S(e.getMinutes(),2),o=S(e.getSeconds(),2),r=S(e.getMilliseconds(),3);return`${w(e)}T${t}:${a}:${o}.${r}`}J.timeStampString=y;function S(e,t){let a=e+"";const o=t-a.length;for(let r=1;r<=o;r++)a="0"+a;return a}J.addLeadingZeros=S;function g(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"ZAR"}).format(e).replace(/ZAR/gi,"R")}J.toZarCurrencyFormat=g;function x(e){if(Object.prototype.toString.call(e)!=="[object Object]")return e instanceof Date?new Date(e):(["string","number","boolean"].includes(typeof e),e);const t=[{...e}];let a=0;for(;a<t.length;){let o=t[a];if(Object.prototype.toString.call(o)==="[object Object]")for(let r in o)o[r]instanceof Date?o[r]=new Date(o[r]):Object.prototype.toString.call(o[r])==="[object Object]"&&(o[r]={...o[r]}),t.push(o[r]);a++}return t[0]}J.deepClone=x;function m(e){const t=[{value:e}];let a=0;for(;a<t.length;){const o=t[a];if(Object.prototype.toString.call(o.value)==="[object Object]"){for(const r in o.value){let u=o.path?o.path+"."+r:r;t.push({value:o.value[r],path:u})}o.remove=!0}a++}return t.filter(o=>!o.remove).map(o=>o.path)}J.getPaths=m;function $(e){let t=x(e),a=0;const o=m(t).toSorted();sortedObj={};for(a in o){const r=o[a],u=O(t,r);B(sortedObj,r,u)}return sortedObj}J.getSortedObject=$;function O(e,t,a=void 0){let o=t.split("."),r=e;for(let u in o){let c=o[u];if(r[c]===void 0||(r=r[c],r===void 0))return a}return r}J.get=O;function B(e,t,a){let o=e,r=t.split(".");for(let u in r){let c=r[u];u<r.length-1?(c in o||(o[c]={}),o=o[c]):o[c]=a}}J.set=B;function C(e,t){let a=t.split("."),o=e;for(let r in a){let u=a[r];if(Object.prototype.toString.call(o)!=="[object Object]"||o[u]===void 0)return;r<a.length-1?o=o[u]:delete o[u]}}J.unset=C;function q(e,...t){if(!t||!t.length)throw new Error("fields must be specified");const a=m(e);let o=0;for(const r in a){const u=a[r];if(t.includes(u))o++;else return!1}return o>0}J.hasOnly=q;function W(e,...t){if(!t||!t.length)throw new Error("fields must be specified");const a=m(e);let o=0;for(const r in t){const u=t[r];if(a.includes(u))o++;else return!1}return o===t.length}J.hasAll=W;function X(e,...t){return q(e,...t)&&W(e,...t)}J.hasOnlyAll=X;function D(e,t,a=0,o="asc"){const r=["asc","desc"];if(!["asc","desc"].includes(o))throw new Error(`arraySortDir must be one of ${r}`);if(e.length===0)return-1;let u=a,c=e.length-1;for(;u<c;){if(R(e[u],t)===0)return u;if(R(e[c],t)===0)return c;const M=Math.trunc((u+c)/2),K=R(e[M],t,o);if(K<0)u=M+1;else if(K>0)c=M-1;else return M}return u}J.binarySearch=D;function R(e,t,a="asc"){if(!["asc","desc"].includes(a))throw new Error(`sortDir must be one of ${a}`);const o=a==="desc"?-1:1;return e>t?o:e<t?-o:0}J.compare=R;function s(e,t,a=0,...o){if(e.length===0)return-1;let r=a,u=e.length-1;for(;r<u;){if(Z(e[r],t,...o)===0)return r;if(Z(e[u],t,...o)===0)return u;let c=Math.trunc((r+u)/2);if(Z(e[c],t,...o)<0)r=c+1;else if(Z(e[c],t,...o)>0)u=c-1;else return c}return r}J.binarySearchObj=s;function G(e,t,a,...o){let r=a,u=e.length-1;if(r>=e.length)throw new Error("startFrom is outside the bounds of the array.");if(Z(t,e[r],...o)>0)throw new Error("targetObj is to the right ('greater than') objArray[startFrom].");for(;r<u;){let c=Math.trunc((r+u)/2);Z(t,e[c],...o)===0?r=c+1:Z(t,e[c],...o)<0&&(u=c)}return Z(t,e[r],...o)===0?-1:r}J.getNextDifferent=G;function Q(e,t,...a){if(e.length<=1)return[...e];if(typeof t!="boolean")throw new Error("firstOfDuplicates must be boolean true or false.");const o=[];let r=0;for(;r<e.length-1&&(t&&o.push(e[r]),r=G(e,e[r],r+1,...a),!(r<0));){let u=r-1;t||o.push(e[u])}return o.length===0?t?o.push(e[0]):o.push(e[e.length-1]):Z(o[o.length-1],e[e.length-1],...a)!==0&&o.push(e[e.length-1]),o}J.getObjArrayWithNoDuplicates=Q;function Z(e,t,...a){if(a.length===0)throw new Error("comparisonFields not supplied!");const o=["","asc","desc"];for(const r in a){const u=a[r].split(" "),c=u[0];let M="";if(u.length===2&&(M=u[1]),!o.includes(M))throw new Error("Sort direction must be one of "+o.toString());const K=O(e,c),h=O(t,c),H=M==="desc"?-1:1;if(K>h)return H;if(K<h)return-H}return 0}return J.objCompare=Z,J}var re=Le();function Oe({label:i,data:T,sortOrder:A="asc",onItemSelected:v=null,selected:j=null,dropdownStyle:p,isDisabled:w=!1}){const[y,S]=z.useState(!1),[g,x]=z.useState(""),m=z.useMemo(()=>T.toSorted(R),[T]),$=z.useMemo(()=>{if(g.length===0)return[];const t=g.toUpperCase();return m.filter(a=>a.toUpperCase().includes(t))},[m,g]),O=z.useMemo(()=>g.length===0?m:$,[m,g]),[B,C]=z.useState(""),[q,W]=z.useState(null);z.useMemo(()=>{let t="";if(q)t=q;else if(j){const a=T.findIndex(o=>o===j);a>=0&&(t=T[a])}return C(t),t},[j,q]);const X=(()=>{const t={backgroundColor:p?.backgroundColor,color:p?.color};return p?.fontSize&&(t.fontSize=p?.fontSize),t})(),D=p?.borderColor;function R(t,a){return re.compare(t,a,A)}function s(t){x(t.target.value),C(t.target.value),$.length===0?Z():e()}async function G(t){C(t),x(""),W(t),v!==null&&v(t),Z()}function Q(){y?Z():e()}function Z(){S(!1)}function e(){O.length>0&&S(!0)}return b.jsxs("div",{className:`dropdown-js dropdown-js-rounded
|
|
3
|
-
${D&&`dropdown-js-border ${D}`}`,style:{...w?{pointerEvents:"none"}:{}},children:[b.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:X,children:[b.jsx("input",{id:"dropdownSearch",name:"dropdownSearch",className:"dropdown-js-input dropdown-js-rounded",autoComplete:"off",type:"text",style:X,role:"combobox","aria-placeholder":`Type to Search for ${i}`,"aria-required":!0,"aria-controls":"dropdown","aria-autocomplete":"list","aria-haspopup":"listbox","aria-expanded":y,onChange:t=>s(t),disabled:w,placeholder:`Type to Search for ${i}`,value:B}),b.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-expanded":y,"aria-controls":"multiSelectionDropdown","aria-label":`${i} options`,onClick:t=>Q(),children:b.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding","aria-label":`${i} options`,"aria-expanded":y,children:y?"-":"+"})})]}),b.jsx("div",{className:`dropdown-js-padding dropdown-js-menu ${!y&&"dropdown-js-hide"}`,id:"dropDown",name:"dropDown",role:"listbox","aria-expanded":y,disabled:w,"aria-label":i,style:{...X,marginTop:"3.5px"},children:O.map((t,a)=>b.jsxs("div",{name:t,role:"option","aria-label":t,style:{cursor:"pointer"},onClick:o=>G(t),children:[t,a<O.length-1&&b.jsx("hr",{style:{borderColor:X.color}})]},`${a}#${t}`))})]})}Oe.propTypes={label:l.string.isRequired,data:l.array.isRequired,sortOrder:l.string,selected:l.any,isDisabled:l.bool,
|
|
3
|
+
${D&&`dropdown-js-border ${D}`}`,style:{...w?{pointerEvents:"none"}:{}},children:[b.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:X,children:[b.jsx("input",{id:"dropdownSearch",name:"dropdownSearch",className:"dropdown-js-input dropdown-js-rounded",autoComplete:"off",type:"text",style:X,role:"combobox","aria-placeholder":`Type to Search for ${i}`,"aria-required":!0,"aria-controls":"dropdown","aria-autocomplete":"list","aria-haspopup":"listbox","aria-expanded":y,onChange:t=>s(t),disabled:w,placeholder:`Type to Search for ${i}`,value:B}),b.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-expanded":y,"aria-controls":"multiSelectionDropdown","aria-label":`${i} options`,onClick:t=>Q(),children:b.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding","aria-label":`${i} options`,"aria-expanded":y,children:y?"-":"+"})})]}),b.jsx("div",{className:`dropdown-js-padding dropdown-js-menu ${!y&&"dropdown-js-hide"}`,id:"dropDown",name:"dropDown",role:"listbox","aria-expanded":y,disabled:w,"aria-label":i,style:{...X,marginTop:"3.5px"},children:O.map((t,a)=>b.jsxs("div",{name:t,role:"option","aria-label":t,style:{cursor:"pointer"},onClick:o=>G(t),children:[t,a<O.length-1&&b.jsx("hr",{style:{borderColor:X.color}})]},`${a}#${t}`))})]})}Oe.propTypes={label:l.string.isRequired,data:l.array.isRequired,sortOrder:l.string,selected:l.any,isDisabled:l.bool,onItemSelected:l.func,dropdownStyle:l.shape({color:l.string.isRequired,backgroundColor:l.string.isRequired,fontSize:l.string,borderColor:l.string}),buttonStyle:l.shape({color:l.string.isRequired,backgroundColor:l.string.isRequired,fontSize:l.string,borderColor:l.string})};function Re({label:i,data:T,sortFields:A,selected:v=null,displayName:j,valueName:p,isDisabled:w=!1,onItemSelected:y=null,dropdownStyle:S}){const[g,x]=z.useState(null),[m,$]=z.useState(""),[O,B]=z.useState(""),C=z.useMemo(()=>T.toSorted(e),[T]),q=z.useMemo(()=>{if(O.length===0)return[];const c=O.toUpperCase();return C.filter(M=>M[j].toUpperCase().toUpperCase().includes(c))},[O]),[W,X]=z.useState(""),[D,R]=z.useState(null);z.useMemo(()=>{let c;if(D)c={...D};else if(v){const M=t(),K=T.findIndex(h=>re.get(h,...M)===re.get(v,...M));K>=0&&(c=T[K])}return c&&X(c[j]),c},[v,D]);const s=z.useMemo(()=>O.length>0?q:C,[O,C]),G=(()=>{const c={backgroundColor:S?.backgroundColor,color:S?.color};return S?.fontSize&&(c.fontSize=S?.fontSize),c})(),Q=S?.borderColor;async function Z(c){B(M=>c.target.value),X(M=>c.target.value),q.length>0?u():r()}function e(c,M){return re.objCompare(c,M,...A)}function t(){let c=m;return c||(T.length>0&&(c=re.getPaths(T[0])),$(c)),c}function a(c){R(c),y!==null&&y(c),r()}function o(){g?r():u()}function r(){x(!1)}function u(){s.length>0&&x(!0)}return b.jsxs("div",{className:`dropdown-js dropdown-js-rounded
|
|
4
4
|
${Q&&`dropdown-js-border ${Q}`}`,style:{...w?{pointerEvents:"none"}:{}},children:[b.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:G,children:[b.jsx("input",{id:"dropdownObjSearch",name:"dropdownObjSearch",className:"dropdown-js-input dropdown-js-rounded",style:G,type:"text",autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-controls":"dropdownObj","aria-expanded":g,"aria-placeholder":`Type to Search for ${i}`,"aria-required":!0,onChange:c=>Z(c),disabled:w,placeholder:`Type to Search for ${i}`,value:W}),b.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-label":`${i} options`,"aria-expanded":g,onClick:c=>o(),children:b.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding",children:g?"-":"+"})})]}),b.jsx("div",{className:`dropdown-js-padding dropdown-js-menu ${!g&&"dropdown-js-hide"}`,id:"dropDownObj",name:"dropDownObj",role:"listbox","aria-expanded":g,style:{...G,marginTop:"3.5px"},children:s.map((c,M)=>b.jsxs("div",{name:c[j],role:"option","aria-label":c[j],style:{cursor:"pointer"},onClick:K=>a(c),children:[c[j],M<s.length-1&&b.jsx("hr",{style:{borderColor:G.color}})]},`${c[p]}${M}`))})]})}Re.propTypes={label:l.string.isRequired,data:l.arrayOf(l.object).isRequired,sortFields:l.arrayOf(l.string).isRequired,selected:l.object,displayName:l.string.isRequired,valueName:l.string.isRequired,isDisabled:l.bool,onItemSelected:l.func,dropdownStyle:l.shape({color:l.string.isRequired,backgroundColor:l.string.isRequired,fontSize:l.string,borderColor:l.string})};function Pe({label:i,data:T,sortFields:A,selectedData:v=[],maxNumSelections:j=null,displayName:p,valueName:w,isDisabled:y=!1,onItemsSelected:S=null,dropdownStyle:g,buttonStyle:x}){const[m,$]=z.useState(!1),[O,B]=z.useState(""),[C,q]=z.useState(""),W=z.useMemo(()=>T.toSorted(t),[T]),[X,D]=z.useState([]),R=z.useMemo(()=>X.length>0?X.filter(h=>W.findIndex(H=>{const n=e();return re.objCompare(h,H,...n)===0})>=0).toSorted(t):v.filter(h=>W.findIndex(H=>{const n=e();return re.objCompare(h,H,...n)===0})>=0).toSorted(t),[W,v,X]),s=z.useMemo(()=>{if(C.length===0)return[];const h=C.toUpperCase();return W.filter(H=>H[p].toUpperCase().includes(h))},[C]),G=z.useMemo(()=>C.length>0?s:W,[C,W]),Q=(()=>{const h={backgroundColor:g?.backgroundColor,color:g?.color};return g?.fontSize&&(h.fontSize=g?.fontSize),h})(),Z=g?.borderColor;z.useEffect(()=>{if(!p)throw new Error("displayName must be provided");if(!w)throw new Error("valueName must be provided")},[]);function e(){let h=O;return h||(T.length>0&&(h=re.getPaths(T[0])),B(h)),h}function t(h,H){return re.objCompare(h,H,...A)}function a(h){q(h.target.value),s.length>0?K():M()}function o(h){let H=[...R];if(r(h))H=H.filter(n=>{const f=e();return re.objCompare(n,h,...f)!==0});else{if(j!==null&&R.length>=j)return;H.push(h)}D(H)}function r(h){const H=e();return R.findIndex(n=>re.objCompare(n,h,...H)===0)>=0}function u(h){const H=e(),n=R.filter(f=>re.objCompare(f,h,...H)!==0);D(n),S!==null&&S(n)}function c(){m?M():K()}function M(){$(!1),S!==null&&S(R)}function K(){G.length>0&&$(!0)}return b.jsxs("div",{className:`dropdown-js dropdown-js-rounded
|
|
5
5
|
${Z&&`dropdown-js-border ${Z}`}`,style:{...y?{pointerEvents:"none"}:{}},children:[b.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:Q,children:[b.jsx("div",{children:b.jsx("input",{id:"multiSelectionDropdownObjSearch",name:"multiSelectionDropdownObjSearch",className:"dropdown-js-input dropdown-js-rounded",style:Q,"aria-label":i,"aria-autocomplete":"list","aria-controls":"multiSelectionDropdownObj",role:"combobox","aria-expanded":m,"aria-haspopup":"listbox",type:"text",autoComplete:"off","aria-placeholder":`Type to Search for ${i}`,onChange:h=>a(h),placeholder:`Type to Search for ${i}`,value:C})}),b.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-expanded":m,"aria-controls":"multiSelectionDropdownObj","aria-label":`${i} options`,onClick:h=>c(),children:b.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding",children:m?"-":"+"})})]}),b.jsx("div",{className:"dropdown-js-padding dropdown-js-selected-wrapper dropdown-js-selected-container",children:b.jsx("div",{id:"multiSelectionDropdownObj",className:"dropdown-js-selected-items","aria-label":`Selected ${i} options`,"aria-multiselectable":!0,"aria-live":"polite",children:R.map(h=>b.jsxs("span",{className:"dropdown-js-padding dropdown-js-rounded","aria-label":`${h[p]}`,style:{...Q,margin:"3.5px",marginRight:"0px"},children:[h[p]," ",b.jsx("span",{className:"dropdown-js-padding",style:{cursor:"pointer"},"aria-label":`Remove ${h[p]}`,onClick:H=>u(h),children:"×"})]},`${h[w]}${h[p]}`))})}),b.jsxs("div",{className:`dropdown-js-padding dropdown-js-menu dropdown-js-rounded ${!m&&"dropdown-js-hide"}`,style:Q,id:"multiSelectionDropdownObj",name:"multiSelectionDropdownObj",role:"listbox","aria-multiselectable":!0,"aria-expanded":m,children:[G.map(h=>b.jsxs("div",{children:[b.jsx("input",{id:`${h[w]}Checkbox`,type:"checkbox",name:`${h[p]}Checkbox`,role:"option","aria-label":`${h[p]}`,"aria-checked":r(h),style:{cursor:"pointer"},checked:r(h),onChange:H=>o(h),value:h[w]}),b.jsx("label",{style:{marginLeft:"5px"},htmlFor:`${h[w]}`,children:h[p]}),b.jsx("hr",{style:{backgroundColor:Q.color,border:"none",height:"0.5px"}})]},`${h[w]}${h[p]}`)),b.jsx("button",{className:"dropdown-js-padding dropdown-js-round",style:x,title:"Done",disabled:G.length===0,"aria-label":`Close ${i} options`,onClick:h=>M(),type:"button",children:"Done"})]})]})}Pe.propTypes={label:l.string.isRequired,data:l.arrayOf(l.object).isRequired,sortFields:l.arrayOf(l.string).isRequired,selectedData:l.arrayOf(l.object),maxNumSelections:l.number,displayName:l.string.isRequired,valueName:l.string.isRequired,isDisabled:l.bool,onItemsSelected:l.func,dropdownStyle:l.shape({color:l.string.isRequired,backgroundColor:l.string.isRequired,fontSize:l.string,borderColor:l.string}),buttonStyle:l.shape({color:l.string.isRequired,backgroundColor:l.string.isRequired,fontSize:l.string,borderColor:l.string})};function $e({label:i,data:T,sortOrder:A="asc",selectedData:v=[],maxNumSelections:j=null,isDisabled:p=!1,onItemsSelected:w=null,dropdownStyle:y,buttonStyle:S}){const[g,x]=z.useState(!1),m=z.useMemo(()=>T.toSorted(s),[T]),[$,O]=z.useState(""),[B,C]=z.useState([]),q=z.useMemo(()=>B.length>0?B.filter(r=>m.findIndex(u=>u===r)>=0).toSorted(s):v.filter(r=>m.findIndex(u=>u===r)>=0).toSorted(s),[m,v,B]),W=z.useMemo(()=>{if($.length===0)return[];const r=$.toUpperCase();return m.filter(u=>u.toUpperCase().includes(r))},[$]),X=z.useMemo(()=>$.length>0?W:m,[$,m]),D=(()=>{const r={backgroundColor:y?.backgroundColor,color:y?.color};return y?.fontSize&&(r.fontSize=y?.fontSize),r})(),R=y?.borderColor;function s(r,u){return re.compare(r,u,A)}function G(r){const u=r.target.value;O(u),X.length>0?o():a()}function Q(r){let u=[...q];if(Z(r))u=u.filter(c=>c!==r);else{if(j!==null&&u.length>=j)return;u.push(r)}C(u)}function Z(r){return q.findIndex(u=>u===r)>=0}function e(r){const u=q.filter(c=>c!==r);C(c=>u),w!==null&&w(u)}function t(){g?a():o()}function a(){x(!1),w!==null&&w(q)}function o(){X.length>0&&x(!0)}return b.jsxs("div",{className:`dropdown-js dropdown-js-rounded
|
|
6
6
|
${R&&`dropdown-js-border ${R}`}`,style:{...p?{pointerEvents:"none"}:{}},children:[b.jsxs("div",{className:"dropdown-js-input-wrapper dropdown-js-rounded",style:D,children:[b.jsx("div",{children:b.jsx("input",{className:"dropdown-js-input dropdown-js-rounded",id:"multiselectionDropdownSearch",name:"multiselectionDropdownSearch",style:D,type:"text",autoComplete:"off",role:"combobox","aria-label":i,"aria-placeholder":`Type to search for ${i}`,"aria-autocomplete":"list","aria-controls":"multiSelectionDropdown","aria-expanded":g,"aria-haspopup":"listbox",onChange:r=>G(r),placeholder:`Type to Search for ${i}`,value:$})}),b.jsx("div",{className:"dropdown-js-arrow-container dropdown-js-padding dropdown-js-rounded","aria-expanded":g,"aria-controls":"multiSelectionDropdown","aria-label":`${i} options`,onClick:r=>t(),children:b.jsx("span",{className:"dropdown-js-arrow dropdown-js-padding",children:g?"-":"+"})})]}),b.jsx("div",{className:"dropdown-js-padding dropdown-js-selected-wrapper dropdown-js-selected-container",children:b.jsx("div",{id:"multiSelectionDropdown-selectedItems",className:"dropdown-js-selected-items","aria-label":`Selected ${i} options`,"aria-live":"polite",children:q.map(r=>b.jsxs("span",{className:"dropdown-js-padding dropdown-js-rounded","aria-label":`${r}`,style:{...D,margin:"3.5px",marginRight:"0px"},children:[r," ",b.jsx("span",{style:{cursor:"pointer"},"aria-label":`Remove ${r}`,onClick:u=>e(r),children:"×"})]},`${r}`))})}),b.jsxs("div",{className:`dropdown-js-padding dropdown-js-menu dropdown-js-rounded ${!g&&"dropdown-js-hide"}`,style:D,id:"multiSelectionDropdown",name:"multiSelectionDropdown",role:"listbox","aria-multiselectable":!0,"aria-expanded":g,children:[X.map((r,u)=>b.jsxs("div",{children:[b.jsx("input",{type:"checkbox",name:`${r}Checkbox`,role:"option","aria-label":r,"aria-checked":Z(r),style:{cursor:"pointer"},checked:Z(r),onChange:c=>Q(r),value:r}),b.jsx("label",{style:{marginLeft:"5px"},htmlFor:`${r}`,children:r}),b.jsx("hr",{style:{backgroundColor:D.color,border:"none",height:"0.5px"}})]},`${u}#${r}`)),b.jsx("button",{className:"dropdown-js-padding dropdown-js-round",style:S,"aria-label":`Click to collapse ${i} options`,title:"Done",disabled:X.length===0,onClick:r=>a(),type:"button",children:"Done"})]})]})}$e.propTypes={label:l.string.isRequired,data:l.array.isRequired,sortOrder:l.string,selectedData:l.array.isRequired,maxNumSelections:l.number,isDisabled:l.bool,onItemsSelected:l.func,dropdownStyle:l.shape({color:l.string.isRequired,backgroundColor:l.string.isRequired,fontSize:l.string,borderColor:l.string}),buttonStyle:l.shape({color:l.string.isRequired,backgroundColor:l.string.isRequired,fontSize:l.string,borderColor:l.string})};exports.Dropdown=Oe;exports.DropdownObj=Re;exports.MultiSelectionDropdown=$e;exports.MultiSelectionDropdownObj=Pe;
|
package/dist/dropdowns-js.es.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "ITA",
|
|
4
4
|
"description": "A React library providing customizable search dropdown components with single and multi-selection capabilities.",
|
|
5
5
|
"private": false,
|
|
6
|
-
"version": "1.1.
|
|
6
|
+
"version": "1.1.4",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/dropdowns-js.cjs.js",
|
|
9
9
|
"module": "./dist/dropdowns-js.es.js",
|