react-dyn-tabs
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).useDynTabs=e(t.React)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(t){var e={exports:{}};return t(e,e.exports),e.exports}var i,a,s=function(t){return t&&t.Math==Math&&t},c=s("object"==typeof globalThis&&globalThis)||s("object"==typeof window&&window)||s("object"==typeof self&&self)||s("object"==typeof r&&r)||function(){return this}()||Function("return this")(),u=function(t){try{return!!t()}catch(t){return!0}},l=!u((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),f={}.propertyIsEnumerable,p=Object.getOwnPropertyDescriptor,d={f:p&&!f.call({1:2},1)?function(t){var e=p(this,t);return!!e&&e.enumerable}:f},h=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},v={}.toString,y=function(t){return v.call(t).slice(8,-1)},b="".split,g=u((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==y(t)?b.call(t,""):Object(t)}:Object,m=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},T=function(t){return g(m(t))},_=function(t){return"object"==typeof t?null!==t:"function"==typeof t},O=function(t,e){if(!_(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!_(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!_(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!_(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},S={}.hasOwnProperty,w=function(t,e){return S.call(t,e)},I=c.document,P=_(I)&&_(I.createElement),C=function(t){return P?I.createElement(t):{}},j=!l&&!u((function(){return 7!=Object.defineProperty(C("div"),"a",{get:function(){return 7}}).a})),A=Object.getOwnPropertyDescriptor,x={f:l?A:function(t,e){if(t=T(t),e=O(e,!0),j)try{return A(t,e)}catch(t){}if(w(t,e))return h(!d.f.call(t,e),t[e])}},E=/#|\.prototype\./,D=function(t,e){var n=M[L(t)];return n==k||n!=N&&("function"==typeof e?u(e):!!e)},L=D.normalize=function(t){return String(t).replace(E,".").toLowerCase()},M=D.data={},N=D.NATIVE="N",k=D.POLYFILL="P",F=D,R={},H=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t},U=function(t,e,n){if(H(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}},G=function(t){if(!_(t))throw TypeError(String(t)+" is not an object");return t},V=Object.defineProperty,B={f:l?V:function(t,e,n){if(G(t),e=O(e,!0),G(n),j)try{return V(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},W=l?function(t,e,n){return B.f(t,e,h(1,n))}:function(t,e,n){return t[e]=n,t},q=x.f,z=function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e.prototype=t.prototype,e},Y=function(t,e){var n,r,o,i,a,s,u,l,f=t.target,p=t.global,d=t.stat,h=t.proto,v=p?c:d?c[f]:(c[f]||{}).prototype,y=p?R:R[f]||(R[f]={}),b=y.prototype;for(o in e)n=!F(p?o:f+(d?".":"#")+o,t.forced)&&v&&w(v,o),a=y[o],n&&(s=t.noTargetGet?(l=q(v,o))&&l.value:v[o]),i=n&&s?s:e[o],n&&typeof a==typeof i||(u=t.bind&&n?U(i,c):t.wrap&&n?z(i):h&&"function"==typeof i?U(Function.call,i):i,(t.sham||i&&i.sham||a&&a.sham)&&W(u,"sham",!0),y[o]=u,h&&(w(R,r=f+"Prototype")||W(R,r,{}),R[r][o]=i,t.real&&b&&!b[o]&&W(b,o,i)))},K=function(t){return Object(m(t))},X=Math.ceil,J=Math.floor,Q=function(t){return isNaN(t=+t)?0:(t>0?J:X)(t)},Z=Math.min,$=function(t){return t>0?Z(Q(t),9007199254740991):0},tt=Array.isArray||function(t){return"Array"==y(t)},et="__core-js_shared__",nt=c[et]||function(t,e){try{W(c,t,e)}catch(n){c[t]=e}return e}(et,{}),rt=o((function(t){(t.exports=function(t,e){return nt[t]||(nt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.10.0",mode:"pure",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),ot=0,it=Math.random(),at=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++ot+it).toString(36)},st="process"==y(c.process),ct=function(t){return"function"==typeof t?t:void 0},ut=function(t,e){return arguments.length<2?ct(R[t])||ct(c[t]):R[t]&&R[t][e]||c[t]&&c[t][e]},lt=ut("navigator","userAgent")||"",ft=c.process,pt=ft&&ft.versions,dt=pt&&pt.v8;dt?a=(i=dt.split("."))[0]+i[1]:lt&&(!(i=lt.match(/Edge\/(\d+)/))||i[1]>=74)&&(i=lt.match(/Chrome\/(\d+)/))&&(a=i[1]);var ht=a&&+a,vt=!!Object.getOwnPropertySymbols&&!u((function(){return!Symbol.sham&&(st?38===ht:ht>37&&ht<41)})),yt=vt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,bt=rt("wks"),gt=c.Symbol,mt=yt?gt:gt&>.withoutSetter||at,Tt=function(t){return w(bt,t)&&(vt||"string"==typeof bt[t])||(vt&&w(gt,t)?bt[t]=gt[t]:bt[t]=mt("Symbol."+t)),bt[t]},_t=Tt("species"),Ot=function(t,e){var n;return tt(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!tt(n.prototype)?_(n)&&null===(n=n[_t])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)},St=[].push,wt=function(t){var e=1==t,n=2==t,r=3==t,o=4==t,i=6==t,a=7==t,s=5==t||i;return function(c,u,l,f){for(var p,d,h=K(c),v=g(h),y=U(u,l,3),b=$(v.length),m=0,T=f||Ot,_=e?T(c,b):n||a?T(c,0):void 0;b>m;m++)if((s||m in v)&&(d=y(p=v[m],m,h),t))if(e)_[m]=d;else if(d)switch(t){case 3:return!0;case 5:return p;case 6:return m;case 2:St.call(_,p)}else switch(t){case 4:return!1;case 7:St.call(_,p)}return i?-1:r||o?o:_}},It={forEach:wt(0),map:wt(1),filter:wt(2),some:wt(3),every:wt(4),find:wt(5),findIndex:wt(6),filterOut:wt(7)},Pt=Tt("species"),Ct=function(t){return ht>=51||!u((function(){var e=[];return(e.constructor={})[Pt]=function(){return{foo:1}},1!==e[t](Boolean).foo}))},jt=It.map,At=Ct("map");Y({target:"Array",proto:!0,forced:!At},{map:function(t){return jt(this,t,arguments.length>1?arguments[1]:void 0)}});var xt=function(t){return R[t+"Prototype"]},Et=xt("Array").map,Dt=Array.prototype,Lt=function(t){var e=t.map;return t===Dt||t instanceof Array&&e===Dt.map?Et:e},Mt=t.createContext({}),Nt=t.createContext({}),kt=t.createContext({}),Ft=Math.max,Rt=Math.min,Ht=function(t,e){var n=Q(t);return n<0?Ft(n+e,0):Rt(n,e)},Ut=function(t){return function(e,n,r){var o,i=T(e),a=$(i.length),s=Ht(r,a);if(t&&n!=n){for(;a>s;)if((o=i[s++])!=o)return!0}else for(;a>s;s++)if((t||s in i)&&i[s]===n)return t||s||0;return!t&&-1}},Gt={includes:Ut(!0),indexOf:Ut(!1)},Vt={},Bt=Gt.indexOf,Wt=function(t,e){var n,r=T(t),o=0,i=[];for(n in r)!w(Vt,n)&&w(r,n)&&i.push(n);for(;e.length>o;)w(r,n=e[o++])&&(~Bt(i,n)||i.push(n));return i},qt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],zt=Object.keys||function(t){return Wt(t,qt)},Yt={f:Object.getOwnPropertySymbols},Kt=Object.assign,Xt=Object.defineProperty,Jt=!Kt||u((function(){if(l&&1!==Kt({b:1},Kt(Xt({},"a",{enumerable:!0,get:function(){Xt(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach((function(t){e[t]=t})),7!=Kt({},t)[n]||zt(Kt({},e)).join("")!=r}))?function(t,e){for(var n=K(t),r=arguments.length,o=1,i=Yt.f,a=d.f;r>o;)for(var s,c=g(arguments[o++]),u=i?zt(c).concat(i(c)):zt(c),f=u.length,p=0;f>p;)s=u[p++],l&&!a.call(c,s)||(n[s]=c[s]);return n}:Kt;Y({target:"Object",stat:!0,forced:Object.assign!==Jt},{assign:Jt});var Qt=R.Object.assign,Zt=Qt;function $t(){return($t=Zt||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var te=function(t){var e=t.api,n=t.id,r=t.isSelected;this._api=e,this._id=n,this._isSelected=r,this._op=e.optionsManager.options,this._setting=e.optionsManager.setting,this._tabObj=e.getTab(n)};te.prototype.getTabProps=function(){var t={"tab-id":this._id,className:this._setting.tabClass,tabIndex:-1};return this._isSelected&&(t.tabIndex=0,t.className+=" "+this._setting.selectedClass),this._tabObj.disable&&(t.tabIndex=-1,t.className+=" "+this._setting.disableClass),this._op.accessibility&&(t.role="tab",t["aria-controls"]=this._setting.panelIdTemplate(this._id),t["aria-labelledby"]=this._setting.ariaLabelledbyIdTemplate(this._id),t["aria-selected"]=t["aria-expanded"]=this._isSelected),t},te.prototype.getTabInnerProps=function(){var t={id:this._id,isSelected:this._isSelected,api:this._api.userProxy,tabProps:{"tab-id":this._id,className:this._setting.titleClass,tabIndex:-1}};return this._tabObj.iconClass&&(t.iconProps={className:this._setting.iconClass+" "+this._tabObj.iconClass,role:"presentation"}),this._op.accessibility&&(t.tabProps.id=this._setting.ariaLabelledbyIdTemplate(this._id),t.tabProps.role="presentation"),t},te.prototype.getCloseIconProps=function(){var t={className:this._setting.closeClass};return this._op.accessibility&&(t.role="presentation"),t};var ee=t.memo((function(t){n.default.useContext(kt);var e=t.id,r=t.selectedTabID,o=n.default.useContext(Mt),i=o.getOption("tabComponent"),a=o.getTab(e),s=new te({api:o,id:e,isSelected:r===e});return n.default.createElement("li",$t({},s.getTabProps(),{onClick:function(t){!function(t){o.eventHandlerFactory({e:t,id:e})}(t)}}),n.default.createElement(i,s.getTabInnerProps(),a.title),a.closable?n.default.createElement("span",s.getCloseIconProps(),"×"):null)}),(function(t,e){var n=t.id,r=t.selectedTabID,o=e.selectedTabID;return r===o||n!==r&&n!==o}));var ne=t.memo((function(t){var e=n.default.useContext(Nt),r=e.openTabIDs,o=e.selectedTabID,i=function(t){var e=t.api,n=e.optionsManager.setting,r=e.optionsManager.options,o={className:n.tablistClass+" "+n[r.direction+"Class"]};return r.accessibility&&(o.role="tablist"),o}({api:n.default.useContext(Mt)});return n.default.createElement("ul",i,Lt(r).call(r,(function(t){return n.default.createElement(ee,{key:t,id:t,selectedTabID:o})})))}),(function(){return!0}));var re,oe,ie=t.memo((function(e){n.default.useContext(kt);var r=e.id,o=e.selectedTabID,i=t.useContext(Mt),a=function(t){var e=t.isSelected,n=t.api,r=t.id,o=n.optionsManager.options,i=n.optionsManager.setting,a={"tab-id":r,className:i.panelClass};return e&&(a.className+=" "+i.selectedClass),o.accessibility&&(a.role="tabpanel",a.id=i.panelIdTemplate(r),a["aria-hidden"]=!e,a["aria-labelledby"]=i.ariaLabelledbyIdTemplate(r)),a}({isSelected:r===o,api:i,id:r});return n.default.createElement("div",a,i.getTab(r).panelComponent)}),(function(t,e){var n=t.id,r=t.selectedTabID,o=e.selectedTabID;return r===o||n!==r&&n!==o})),ae=t.memo((function(t){var e=n.default.useContext(Nt),r=e.openTabIDs,o=e.selectedTabID,i=n.default.useContext(Mt),a=i.optionsManager.setting,s=a.panellistClass+" "+a[i.getOption("direction")+"class"];return n.default.createElement("div",{className:s},Lt(r).call(r,(function(t){return n.default.createElement(ie,{key:t,id:t,selectedTabID:o})})))}),(function(){return!0})),se=Gt.indexOf,ce=[].indexOf,ue=!!ce&&1/[1].indexOf(1,-0)<0,le=!!(oe=[]["indexOf"])&&u((function(){oe.call(null,re||function(){throw 1},1)}));Y({target:"Array",proto:!0,forced:ue||!le},{indexOf:function(t){return ue?ce.apply(this,arguments)||0:se(this,t,arguments.length>1?arguments[1]:void 0)}});var fe=xt("Array").indexOf,pe=Array.prototype,de=function(t){var e=t.indexOf;return t===pe||t instanceof Array&&e===pe.indexOf?fe:e},he=function(t,e,n){var r=O(e);r in t?B.f(t,r,h(0,n)):t[r]=n},ve=Ct("slice"),ye=Tt("species"),be=[].slice,ge=Math.max;Y({target:"Array",proto:!0,forced:!ve},{slice:function(t,e){var n,r,o,i=T(this),a=$(i.length),s=Ht(t,a),c=Ht(void 0===e?a:e,a);if(tt(i)&&("function"!=typeof(n=i.constructor)||n!==Array&&!tt(n.prototype)?_(n)&&null===(n=n[ye])&&(n=void 0):n=void 0,n===Array||void 0===n))return be.call(i,s,c);for(r=new(void 0===n?Array:n)(ge(c-s,0)),o=0;s<c;s++,o++)s in i&&he(r,o,i[s]);return r.length=o,r}});var me=xt("Array").slice,Te=Array.prototype,_e=function(t){var e=t.slice;return t===Te||t instanceof Array&&e===Te.slice?me:e},Oe=Ct("splice"),Se=Math.max,we=Math.min,Ie=9007199254740991,Pe="Maximum allowed length exceeded";Y({target:"Array",proto:!0,forced:!Oe},{splice:function(t,e){var n,r,o,i,a,s,c=K(this),u=$(c.length),l=Ht(t,u),f=arguments.length;if(0===f?n=r=0:1===f?(n=0,r=u-l):(n=f-2,r=we(Se(Q(e),0),u-l)),u+n-r>Ie)throw TypeError(Pe);for(o=Ot(c,r),i=0;i<r;i++)(a=l+i)in c&&he(o,i,c[a]);if(o.length=r,n<r){for(i=l;i<u-r;i++)s=i+n,(a=i+r)in c?c[s]=c[a]:delete c[s];for(i=u;i>u-r+n;i--)delete c[i-1]}else if(n>r)for(i=u-r;i>l;i--)s=i+n-1,(a=i+r-1)in c?c[s]=c[a]:delete c[s];for(i=0;i<n;i++)c[i+l]=arguments[i+2];return c.length=u-r+n,o}});var Ce=xt("Array").splice,je=Array.prototype,Ae=function(t){var e=t.splice;return t===je||t instanceof Array&&e===je.splice?Ce:e},xe="open",Ee="close",De="active",Le="refresh",Me=[].slice,Ne={},ke=function(t,e,n){if(!(e in Ne)){for(var r=[],o=0;o<e;o++)r[o]="a["+o+"]";Ne[e]=Function("C,a","return new C("+r.join(",")+")")}return Ne[e](t,n)},Fe=Function.bind||function(t){var e=H(this),n=Me.call(arguments,1),r=function(){var o=n.concat(Me.call(arguments));return this instanceof r?ke(e,o.length,o):e.apply(t,o)};return _(e.prototype)&&(r.prototype=e.prototype),r};Y({target:"Function",proto:!0},{bind:Fe});var Re,He=xt("Function").bind,Ue=Function.prototype,Ge=function(t){var e=t.bind;return t===Ue||t instanceof Function&&e===Ue.bind?He:e},Ve=rt("keys"),Be=function(t){return Ve[t]||(Ve[t]=at(t))},We=!u((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),qe=Be("IE_PROTO"),ze=Object.prototype,Ye=We?Object.getPrototypeOf:function(t){return t=K(t),w(t,qe)?t[qe]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?ze:null},Ke=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return G(n),function(t){if(!_(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype")}(r),e?t.call(n,r):n.__proto__=r,n}}():void 0),Xe=l?Object.defineProperties:function(t,e){G(t);for(var n,r=zt(e),o=r.length,i=0;o>i;)B.f(t,n=r[i++],e[n]);return t},Je=ut("document","documentElement"),Qe=Be("IE_PROTO"),Ze=function(){},$e=function(t){return"<script>"+t+"</"+"script>"},tn=function(){try{Re=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;tn=Re?function(t){t.write($e("")),t.close();var e=t.parentWindow.Object;return t=null,e}(Re):((e=C("iframe")).style.display="none",Je.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write($e("document.F=Object")),t.close(),t.F);for(var n=qt.length;n--;)delete tn.prototype[qt[n]];return tn()};Vt[Qe]=!0;var en=Object.create||function(t,e){var n;return null!==t?(Ze.prototype=G(t),n=new Ze,Ze.prototype=null,n[Qe]=t):n=tn(),void 0===e?n:Xe(n,e)},nn={},rn=Tt("iterator"),on=Array.prototype,an={};an[Tt("toStringTag")]="z";var sn="[object z]"===String(an),cn=Tt("toStringTag"),un="Arguments"==y(function(){return arguments}()),ln=sn?y:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),cn))?n:un?y(e):"Object"==(r=y(e))&&"function"==typeof e.callee?"Arguments":r},fn=Tt("iterator"),pn=function(t){var e=t.return;if(void 0!==e)return G(e.call(t)).value},dn=function(t,e){this.stopped=t,this.result=e},hn=function(t,e,n){var r,o,i,a,s,c,u,l,f=n&&n.that,p=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_ITERATOR),h=!(!n||!n.INTERRUPTED),v=U(e,f,1+p+h),y=function(t){return r&&pn(r),new dn(!0,t)},b=function(t){return p?(G(t),h?v(t[0],t[1],y):v(t[0],t[1])):h?v(t,y):v(t)};if(d)r=t;else{if("function"!=typeof(o=function(t){if(null!=t)return t[fn]||t["@@iterator"]||nn[ln(t)]}(t)))throw TypeError("Target is not iterable");if(void 0!==(l=o)&&(nn.Array===l||on[rn]===l)){for(i=0,a=$(t.length);a>i;i++)if((s=b(t[i]))&&s instanceof dn)return s;return new dn(!1)}r=o.call(t)}for(c=r.next;!(u=c.call(r)).done;){try{s=b(u.value)}catch(t){throw pn(r),t}if("object"==typeof s&&s&&s instanceof dn)return s}return new dn(!1)},vn=function(t,e){var n=this;if(!(n instanceof vn))return new vn(t,e);Ke&&(n=Ke(new Error(void 0),Ye(n))),void 0!==e&&W(n,"message",String(e));var r=[];return hn(t,r.push,{that:r}),W(n,"errors",r),n};vn.prototype=en(Error.prototype,{constructor:h(5,vn),message:h(5,""),name:h(5,"AggregateError")}),Y({global:!0},{AggregateError:vn});var yn=c.Promise,bn=function(t,e,n,r){r&&r.enumerable?t[e]=n:W(t,e,n)},gn=sn?{}.toString:function(){return"[object "+ln(this)+"]"},mn=B.f,Tn=Tt("toStringTag"),_n=function(t,e,n,r){if(t){var o=n?t:t.prototype;w(o,Tn)||mn(o,Tn,{configurable:!0,value:e}),r&&!sn&&W(o,"toString",gn)}},On=Tt("species"),Sn=Function.toString;"function"!=typeof nt.inspectSource&&(nt.inspectSource=function(t){return Sn.call(t)});var wn=nt.inspectSource,In=Tt("iterator"),Pn=!1;try{var Cn=0,jn={next:function(){return{done:!!Cn++}},return:function(){Pn=!0}};jn[In]=function(){return this},Array.from(jn,(function(){throw 2}))}catch(t){}var An,xn,En,Dn=Tt("species"),Ln=function(t,e){var n,r=G(t).constructor;return void 0===r||null==(n=G(r)[Dn])?e:H(n)},Mn=/(iphone|ipod|ipad).*applewebkit/i.test(lt),Nn=c.location,kn=c.setImmediate,Fn=c.clearImmediate,Rn=c.process,Hn=c.MessageChannel,Un=c.Dispatch,Gn=0,Vn={},Bn="onreadystatechange",Wn=function(t){if(Vn.hasOwnProperty(t)){var e=Vn[t];delete Vn[t],e()}},qn=function(t){return function(){Wn(t)}},zn=function(t){Wn(t.data)},Yn=function(t){c.postMessage(t+"",Nn.protocol+"//"+Nn.host)};kn&&Fn||(kn=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return Vn[++Gn]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},An(Gn),Gn},Fn=function(t){delete Vn[t]},st?An=function(t){Rn.nextTick(qn(t))}:Un&&Un.now?An=function(t){Un.now(qn(t))}:Hn&&!Mn?(En=(xn=new Hn).port2,xn.port1.onmessage=zn,An=U(En.postMessage,En,1)):c.addEventListener&&"function"==typeof postMessage&&!c.importScripts&&Nn&&"file:"!==Nn.protocol&&!u(Yn)?(An=Yn,c.addEventListener("message",zn,!1)):An=Bn in C("script")?function(t){Je.appendChild(C("script")).onreadystatechange=function(){Je.removeChild(this),Wn(t)}}:function(t){setTimeout(qn(t),0)});var Kn,Xn,Jn,Qn,Zn,$n,tr,er,nr={set:kn,clear:Fn},rr=/web0s(?!.*chrome)/i.test(lt),or=x.f,ir=nr.set,ar=c.MutationObserver||c.WebKitMutationObserver,sr=c.document,cr=c.process,ur=c.Promise,lr=or(c,"queueMicrotask"),fr=lr&&lr.value;fr||(Kn=function(){var t,e;for(st&&(t=cr.domain)&&t.exit();Xn;){e=Xn.fn,Xn=Xn.next;try{e()}catch(t){throw Xn?Qn():Jn=void 0,t}}Jn=void 0,t&&t.enter()},Mn||st||rr||!ar||!sr?ur&&ur.resolve?(tr=ur.resolve(void 0),er=tr.then,Qn=function(){er.call(tr,Kn)}):Qn=st?function(){cr.nextTick(Kn)}:function(){ir.call(c,Kn)}:(Zn=!0,$n=sr.createTextNode(""),new ar(Kn).observe($n,{characterData:!0}),Qn=function(){$n.data=Zn=!Zn}));var pr,dr,hr,vr=fr||function(t){var e={fn:t,next:void 0};Jn&&(Jn.next=e),Xn||(Xn=e,Qn()),Jn=e},yr=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=H(e),this.reject=H(n)},br={f:function(t){return new yr(t)}},gr=function(t,e){if(G(t),_(e)&&e.constructor===t)return e;var n=br.f(t);return(0,n.resolve)(e),n.promise},mr=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Tr=c.WeakMap,_r="function"==typeof Tr&&/native code/.test(wn(Tr)),Or=c.WeakMap;if(_r){var Sr=nt.state||(nt.state=new Or),wr=Sr.get,Ir=Sr.has,Pr=Sr.set;pr=function(t,e){return e.facade=t,Pr.call(Sr,t,e),e},dr=function(t){return wr.call(Sr,t)||{}},hr=function(t){return Ir.call(Sr,t)}}else{var Cr=Be("state");Vt[Cr]=!0,pr=function(t,e){return e.facade=t,W(t,Cr,e),e},dr=function(t){return w(t,Cr)?t[Cr]:{}},hr=function(t){return w(t,Cr)}}var jr={set:pr,get:dr,has:hr,enforce:function(t){return hr(t)?dr(t):pr(t,{})},getterFor:function(t){return function(e){var n;if(!_(e)||(n=dr(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},Ar=nr.set,xr=Tt("species"),Er="Promise",Dr=jr.get,Lr=jr.set,Mr=jr.getterFor(Er),Nr=yn,kr=c.TypeError,Fr=c.document,Rr=c.process;ut("fetch");var Hr,Ur,Gr,Vr=br.f,Br=Vr,Wr=!!(Fr&&Fr.createEvent&&c.dispatchEvent),qr="function"==typeof PromiseRejectionEvent,zr="unhandledrejection",Yr=F(Er,(function(){if(!(wn(Nr)!==String(Nr))){if(66===ht)return!0;if(!st&&!qr)return!0}if(!Nr.prototype.finally)return!0;if(ht>=51&&/native code/.test(Nr))return!1;var t=Nr.resolve(1),e=function(t){t((function(){}),(function(){}))};return(t.constructor={})[xr]=e,!(t.then((function(){}))instanceof e)})),Kr=Yr||!function(t,e){if(!e&&!Pn)return!1;var n=!1;try{var r={};r[In]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n}((function(t){Nr.all(t).catch((function(){}))})),Xr=function(t){var e;return!(!_(t)||"function"!=typeof(e=t.then))&&e},Jr=function(t,e){if(!t.notified){t.notified=!0;var n=t.reactions;vr((function(){for(var r=t.value,o=1==t.state,i=0;n.length>i;){var a,s,c,u=n[i++],l=o?u.ok:u.fail,f=u.resolve,p=u.reject,d=u.domain;try{l?(o||(2===t.rejection&&to(t),t.rejection=1),!0===l?a=r:(d&&d.enter(),a=l(r),d&&(d.exit(),c=!0)),a===u.promise?p(kr("Promise-chain cycle")):(s=Xr(a))?s.call(a,f,p):f(a)):p(r)}catch(t){d&&!c&&d.exit(),p(t)}}t.reactions=[],t.notified=!1,e&&!t.rejection&&Zr(t)}))}},Qr=function(t,e,n){var r,o;Wr?((r=Fr.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),c.dispatchEvent(r)):r={promise:e,reason:n},!qr&&(o=c["on"+t])?o(r):t===zr&&function(t,e){var n=c.console;n&&n.error&&(1===arguments.length?n.error(t):n.error(t,e))}("Unhandled promise rejection",n)},Zr=function(t){Ar.call(c,(function(){var e,n=t.facade,r=t.value;if($r(t)&&(e=mr((function(){st?Rr.emit("unhandledRejection",r,n):Qr(zr,n,r)})),t.rejection=st||$r(t)?2:1,e.error))throw e.value}))},$r=function(t){return 1!==t.rejection&&!t.parent},to=function(t){Ar.call(c,(function(){var e=t.facade;st?Rr.emit("rejectionHandled",e):Qr("rejectionhandled",e,t.value)}))},eo=function(t,e,n){return function(r){t(e,r,n)}},no=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,Jr(t,!0))},ro=function(t,e,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===e)throw kr("Promise can't be resolved itself");var r=Xr(e);r?vr((function(){var n={done:!1};try{r.call(e,eo(ro,n,t),eo(no,n,t))}catch(e){no(n,e,t)}})):(t.value=e,t.state=1,Jr(t,!1))}catch(e){no({done:!1},e,t)}}};Yr&&(Nr=function(t){!function(t,e,n){if(!(t instanceof e))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation")}(this,Nr,Er),H(t),Hr.call(this);var e=Dr(this);try{t(eo(ro,e),eo(no,e))}catch(t){no(e,t)}},(Hr=function(t){Lr(this,{type:Er,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=function(t,e,n){for(var r in e)n&&n.unsafe&&t[r]?t[r]=e[r]:bn(t,r,e[r],n);return t}(Nr.prototype,{then:function(t,e){var n=Mr(this),r=Vr(Ln(this,Nr));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=st?Rr.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&Jr(n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),Ur=function(){var t=new Hr,e=Dr(t);this.promise=t,this.resolve=eo(ro,e),this.reject=eo(no,e)},br.f=Vr=function(t){return t===Nr||t===Gr?new Ur(t):Br(t)}),Y({global:!0,wrap:!0,forced:Yr},{Promise:Nr}),_n(Nr,Er,!1,!0),function(t){var e=ut(t),n=B.f;l&&e&&!e[On]&&n(e,On,{configurable:!0,get:function(){return this}})}(Er),Gr=ut(Er),Y({target:Er,stat:!0,forced:Yr},{reject:function(t){var e=Vr(this);return e.reject.call(void 0,t),e.promise}}),Y({target:Er,stat:!0,forced:!0},{resolve:function(t){return gr(this===Gr?Nr:this,t)}}),Y({target:Er,stat:!0,forced:Kr},{all:function(t){var e=this,n=Vr(e),r=n.resolve,o=n.reject,i=mr((function(){var n=H(e.resolve),i=[],a=0,s=1;hn(t,(function(t){var c=a++,u=!1;i.push(void 0),s++,n.call(e,t).then((function(t){u||(u=!0,i[c]=t,--s||r(i))}),o)})),--s||r(i)}));return i.error&&o(i.value),n.promise},race:function(t){var e=this,n=Vr(e),r=n.reject,o=mr((function(){var o=H(e.resolve);hn(t,(function(t){o.call(e,t).then(n.resolve,r)}))}));return o.error&&r(o.value),n.promise}}),Y({target:"Promise",stat:!0},{allSettled:function(t){var e=this,n=br.f(e),r=n.resolve,o=n.reject,i=mr((function(){var n=H(e.resolve),o=[],i=0,a=1;hn(t,(function(t){var s=i++,c=!1;o.push(void 0),a++,n.call(e,t).then((function(t){c||(c=!0,o[s]={status:"fulfilled",value:t},--a||r(o))}),(function(t){c||(c=!0,o[s]={status:"rejected",reason:t},--a||r(o))}))})),--a||r(o)}));return i.error&&o(i.value),n.promise}});var oo="No one promise resolved";Y({target:"Promise",stat:!0},{any:function(t){var e=this,n=br.f(e),r=n.resolve,o=n.reject,i=mr((function(){var n=H(e.resolve),i=[],a=0,s=1,c=!1;hn(t,(function(t){var u=a++,l=!1;i.push(void 0),s++,n.call(e,t).then((function(t){l||c||(c=!0,r(t))}),(function(t){l||c||(l=!0,i[u]=t,--s||o(new(ut("AggregateError"))(i,oo)))}))})),--s||o(new(ut("AggregateError"))(i,oo))}));return i.error&&o(i.value),n.promise}});var io=!!yn&&u((function(){yn.prototype.finally.call({then:function(){}},(function(){}))}));Y({target:"Promise",proto:!0,real:!0,forced:io},{finally:function(t){var e=Ln(this,ut("Promise")),n="function"==typeof t;return this.then(n?function(n){return gr(e,t()).then((function(){return n}))}:t,n?function(n){return gr(e,t()).then((function(){throw n}))}:t)}});var ao,so,co,uo=function(t){return function(e,n){var r,o,i=String(m(e)),a=Q(n),s=i.length;return a<0||a>=s?t?"":void 0:(r=i.charCodeAt(a))<55296||r>56319||a+1===s||(o=i.charCodeAt(a+1))<56320||o>57343?t?i.charAt(a):r:t?i.slice(a,a+2):o-56320+(r-55296<<10)+65536}},lo={codeAt:uo(!1),charAt:uo(!0)},fo=Tt("iterator"),po=!1;[].keys&&("next"in(co=[].keys())?(so=Ye(Ye(co)))!==Object.prototype&&(ao=so):po=!0);var ho=null==ao||u((function(){var t={};return ao[fo].call(t)!==t}));ho&&(ao={}),ho&&!w(ao,fo)&&W(ao,fo,(function(){return this}));var vo={IteratorPrototype:ao,BUGGY_SAFARI_ITERATORS:po},yo=vo.IteratorPrototype,bo=function(){return this},go=vo.IteratorPrototype,mo=vo.BUGGY_SAFARI_ITERATORS,To=Tt("iterator"),_o="keys",Oo="values",So="entries",wo=function(){return this},Io=function(t,e,n,r,o,i,a){!function(t,e,n){var r=e+" Iterator";t.prototype=en(yo,{next:h(1,n)}),_n(t,r,!1,!0),nn[r]=bo}(n,e,r);var s,c,u,l=function(t){if(t===o&&y)return y;if(!mo&&t in d)return d[t];switch(t){case _o:case Oo:case So:return function(){return new n(this,t)}}return function(){return new n(this)}},f=e+" Iterator",p=!1,d=t.prototype,v=d[To]||d["@@iterator"]||o&&d[o],y=!mo&&v||l(o),b="Array"==e&&d.entries||v;if(b&&(s=Ye(b.call(new t)),go!==Object.prototype&&s.next&&(_n(s,f,!0,!0),nn[f]=wo)),o==Oo&&v&&v.name!==Oo&&(p=!0,y=function(){return v.call(this)}),a&&d[To]!==y&&W(d,To,y),nn[e]=y,o)if(c={values:l(Oo),keys:i?y:l(_o),entries:l(So)},a)for(u in c)(mo||p||!(u in d))&&bn(d,u,c[u]);else Y({target:e,proto:!0,forced:mo||p},c);return c},Po=lo.charAt,Co="String Iterator",jo=jr.set,Ao=jr.getterFor(Co);Io(String,"String",(function(t){jo(this,{type:Co,string:String(t),index:0})}),(function(){var t,e=Ao(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=Po(n,r),e.index+=t.length,{value:t,done:!1})}));var xo="Array Iterator",Eo=jr.set,Do=jr.getterFor(xo);Io(Array,"Array",(function(t,e){Eo(this,{type:xo,target:T(t),index:0,kind:e})}),(function(){var t=Do(this),e=t.target,n=t.kind,r=t.index++;return!e||r>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:e[r],done:!1}:{value:[r,e[r]],done:!1}}),"values"),nn.Arguments=nn.Array;var Lo=Tt("toStringTag");for(var Mo in{CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}){var No=c[Mo],ko=No&&No.prototype;ko&&ln(ko)!==Lo&&W(ko,Lo,Mo),nn[Mo]=nn.Array}var Fo=R.Promise,Ro=Tt("isConcatSpreadable"),Ho=9007199254740991,Uo="Maximum allowed index exceeded",Go=ht>=51||!u((function(){var t=[];return t[Ro]=!1,t.concat()[0]!==t})),Vo=Ct("concat"),Bo=function(t){if(!_(t))return!1;var e=t[Ro];return void 0!==e?!!e:tt(t)};Y({target:"Array",proto:!0,forced:!Go||!Vo},{concat:function(t){var e,n,r,o,i,a=K(this),s=Ot(a,0),c=0;for(e=-1,r=arguments.length;e<r;e++)if(Bo(i=-1===e?a:arguments[e])){if(c+(o=$(i.length))>Ho)throw TypeError(Uo);for(n=0;n<o;n++,c++)n in i&&he(s,c,i[n])}else{if(c>=Ho)throw TypeError(Uo);he(s,c++,i)}return s.length=c,s}});var Wo=xt("Array").concat,qo=Array.prototype,zo=function(t){var e=t.concat;return t===qo||t instanceof Array&&e===qo.concat?Wo:e},Yo=u((function(){zt(1)}));Y({target:"Object",stat:!0,forced:Yo},{keys:function(t){return zt(K(t))}});var Ko=R.Object.keys,Xo=qt.concat("length","prototype"),Jo={f:Object.getOwnPropertyNames||function(t){return Wt(t,Xo)}}.f,Qo={}.toString,Zo="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],$o=function(t){return Zo&&"[object Window]"==Qo.call(t)?function(t){try{return Jo(t)}catch(t){return Zo.slice()}}(t):Jo(T(t))},ti=u((function(){return!Object.getOwnPropertyNames(1)}));Y({target:"Object",stat:!0,forced:ti},{getOwnPropertyNames:$o});var ei=R.Object,ni=function(t){return ei.getOwnPropertyNames(t)};Y({target:"Object",stat:!0,forced:!l,sham:!l},{defineProperty:B.f});var ri=o((function(t){var e=R.Object,n=t.exports=function(t,n,r){return e.defineProperty(t,n,r)};e.defineProperty.sham&&(n.sham=!0)}));Y({target:"Object",stat:!0,forced:!l,sham:!l},{defineProperties:Xe});var oi=o((function(t){var e=R.Object,n=t.exports=function(t,n){return e.defineProperties(t,n)};e.defineProperties.sham&&(n.sham=!0)})),ii=[].reverse,ai=[1,2];Y({target:"Array",proto:!0,forced:String(ai)===String(ai.reverse())},{reverse:function(){return tt(this)&&(this.length=this.length),ii.call(this)}});var si=xt("Array").reverse,ci=Array.prototype,ui=function(t){var e=t.reverse;return t===ci||t instanceof Array&&e===ci.reverse?si:e},li={};function fi(t,e){switch(e.type){case Ee:var n=t.openTabIDs,r=de(n).call(n,e.tabId);if(r>=0){var o=_e(n).call(n);return Ae(o).call(o,r,1),{selectedTabID:t.selectedTabID,openTabIDs:o}}return t;case xe:var i=t.openTabIDs,a=e.tabId;if(-1===de(i).call(i,a)){var s=_e(i).call(i);return s.push(a),{selectedTabID:t.selectedTabID,openTabIDs:s}}return t;case Le:return li.getCopyState(t);case De:var c=e.tabId;return t.selectedTabID!==c?{selectedTabID:c,openTabIDs:t.openTabIDs}:t;default:throw new Error("Undefined action type '"+e.type+"'")}}li.checkArrIndex=function(t,e){return t>=0&&t<e},li.getInstance=function(t){new(Ge(Function.prototype).apply(t,arguments))},li.resolve=function(t){return Fo.resolve(t)},li.getCopyState=function(t){var e,n=$t({},t);return n.hasOwnProperty("openTabIDs")&&(n.openTabIDs=zo(e=[]).call(e,n.openTabIDs)),n},li.assingAll=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Lt(n).call(n,(function(e){var n,r=Ko(e);Lt(n=ni(e)).call(n,(function(n){de(r).call(r,n)>=0?t[n]=e[n]:ri(t,n,{value:e[n],writable:!0})}))})),t},li.setNoneEnumProps=function(t,e){var n,r={};return Lt(n=Ko(e)).call(n,(function(t){r[t]={writable:!0,value:e[t]}})),oi(t,r)},li.getArraysDiff=function(t,e){var n,r,o=zo(n=[]).call(n,t),i=zo(r=[]).call(r,e);return Lt(t).call(t,(function(t){de(e).call(e,t)>=0&&(Ae(o).call(o,de(o).call(o,t),1),Ae(i).call(i,de(i).call(i,t),1))})),[o,i]},li.arrFilterUntilFirstValue=function(t,e,n){n&&ui(t).call(t);for(var r=0,o=t.length;r<o;r++)if(e(t[r],r,t))return t[r];return null},li.throwMissingParam=function(t){throw'Missing parameter in "'+t+'" function'},li.throwInvalidParam=function(t){throw'Invalid parameter error in "'+t+'" function'},li.isObj=function(t){return"[object Object]"===Object.prototype.toString.call(t)},Y({target:"Object",stat:!0,sham:!l},{create:en});var pi=R.Object,di=function(t,e){return pi.create(t,e)},hi=Gt.includes;Y({target:"Array",proto:!0},{includes:function(t){return hi(this,t,arguments.length>1?arguments[1]:void 0)}});var vi=xt("Array").includes,yi=Tt("match"),bi=function(t){if(function(t){var e;return _(t)&&(void 0!==(e=t[yi])?!!e:"RegExp"==y(t))}(t))throw TypeError("The method doesn't accept regular expressions");return t},gi=Tt("match");Y({target:"String",proto:!0,forced:!function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[gi]=!1,"/./"[t](e)}catch(t){}}return!1}("includes")},{includes:function(t){return!!~String(m(this)).indexOf(bi(t),arguments.length>1?arguments[1]:void 0)}});var mi,Ti,_i,Oi,Si=xt("String").includes,wi=Array.prototype,Ii=String.prototype,Pi=function(t){var e=t.includes;return t===wi||t instanceof Array&&e===wi.includes?vi:"string"==typeof t||t===Ii||t instanceof String&&e===Ii.includes?Si:e},Ci=li.throwMissingParam,ji=function(t,e){void 0===e&&(e={options:{}});var n=t.call(this,e.options),r=n.optionsManager,o=n.helper,i=n.activedTabsHistory;o.setNoneEnumProps(this,{optionsManager:r,helper:o,activedTabsHistory:i}),this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions()._subscribeOnChange()},Ai={_setUserProxy:function(){var t=this,e={},n=this;for(var r in this)"_"!==r[0]&&"constructor"!==r&&function(){var o=t[r];e[r]="function"==typeof o?function(){var t=o.apply(n,arguments);return t===n?e:t}:o}();return this.userProxy=e,this},_subscribeOnChange:function(){var t=this;return this.on("onChange",(function(e){var n=e.newState,r=e.oldState,o=e.closedTabsId,i=e.openedTabsId,a=e.isSwitched;i.length&&t.trigger("onOpen",t.userProxy,i),o.length&&t.trigger("onClose",t.userProxy,o),a&&t.trigger("onSelect",t.userProxy,{currentSelectedTabId:n.selectedTabID,perviousSelectedTabId:r.selectedTabID})})),this},_subscribeCallbacksOptions:function(){var t,e=this,n=this.optionsManager.options;return Lt(t=Ko(this._publishers)).call(t,(function(t){e.on(t,(function(){n[t].apply(this.userProxy,arguments)}))})),this},_subscribeSelectedTabsHistory:function(){var t=this;return this.on("onChange",(function(e){var n=e.isSwitched,r=e.oldState;n&&t.activedTabsHistory.add(r.selectedTabID)})),this},getOption:function(t){return this.optionsManager.getOption(t)},setOption:function(t,e){return this.optionsManager.setOption(t,e)},getCopyPerviousData:function(){return this.helper.getCopyState(this._perviousState)},getCopyData:function(){return this.helper.getCopyState(this._state)},isSelected:function(t){return void 0===t&&(t=Ci("isSelected")),this._state.selectedTabID==t},isOpen:function(t){var e;return void 0===t&&(t=Ci("isOpen")),de(e=this._state.openTabIDs).call(e,t)>=0},_getOnChangePromise:function(){var t=this;return new Fo((function(e){t.one("onChange",(function(){e.call(t.userProxy)}))}))},select:function(t){void 0===t&&(t=Ci("select"));var e=this._getOnChangePromise();return this._select(t),e},_findTabIdForSwitching:(mi=function(t,e){var n=this;return this.helper.arrFilterUntilFirstValue(t,(function(t){return n.isOpen(t)&&!n.getTab(t).disable&&!n.isSelected(t)}),e)||""},Ti=function(){var t;return mi.call(this,zo(t=[]).call(t,this.activedTabsHistory.tabsId),!0)},_i=function(){var t=this._state,e=t.openTabIDs;return mi.call(this,_e(e).call(e,0,de(e).call(e,t.selectedTabID)),!0)},Oi=function(){var t=this._state,e=t.openTabIDs;return mi.call(this,_e(e).call(e,de(e).call(e,t.selectedTabID)+1))},function(){return Ti.call(this)||_i.call(this)||Oi.call(this)}),open:function(t){void 0===t&&(t=Ci("open"));var e=this._getOnChangePromise();return this._open(t.id),this._addTab(t,{defaultPanelComponent:this.getOption("defaultPanelComponent")}),e},__close:function(t){var e=this._getOnChangePromise();return this._close(t),this._removeTab(t),e},close:function(t){if(void 0===t&&(t=Ci("close")),this.isSelected(t)){var e,n=zo(e=[]).call(e,this._state.openTabIDs);return Ae(n).call(n,de(n).call(n,t),1),this.select(this._findTabIdForSwitching()),this.__close(t)}return this.__close(t)},refresh:function(){var t=this._getOnChangePromise();return this._refresh(),t}};li.setNoneEnumProps(Ai,{getInitialState:function(){var t=this;if(!this._initialState){var e=this.optionsManager.options,n=e.selectedTabID,r=e.tabs,o=e.defaultPanelComponent,i=[];Lt(r).call(r,(function(e){t._addTab(e,{defaultPanelComponent:o}),i.push(e.id)})),this._initialState={selectedTabID:n,openTabIDs:i}}return this._initialState},eventHandlerFactory:function(t){var e,n,r,o,i=t.e,a=t.id,s=i.target,c=s.parentElement,u=this.optionsManager.setting,l=u.closeClass,f=u.tabClass;Pi(e=s.className).call(e,l)&&c&&c.lastChild&&c.lastChild==s&&Pi(n=c.className).call(n,f)?Pi(r=this.trigger("beforeClose",this.userProxy,i,a)).call(r,!1)||this.close(a):Pi(o=this.trigger("beforeSelect",this.userProxy,i,a)).call(o,!1)||this.select(a).then((function(t){})).catch((function(t){}))}});var xi=Ai,Ei=Qt,Di=li.throwMissingParam;function Li(t,e){var n=e.options,r=t().globalDefaultOptions;this._defaultOptions=r,this._validateOptions(n),this.options=Ei({},this._defaultOptions,n),this._setSetting()}Li.prototype.getOption=function(t){return this.options[t]},Li.prototype.setOption=function(t,e){return void 0===t&&(t=Di("setOption")),void 0===e&&(e=Di("setOption")),"SELECTEDTABID"===t.toUpperCase()||this._defaultOptions.hasOwnProperty(t)&&(this.options[t]=e),this},Li.prototype._validateOptions=function(t){if("[object Object]"!==Object.prototype.toString.call(t))throw'Invalid argument in "useDynamicTabs" function. Argument must be type of an object';return this},Li.prototype._setSetting=function(){return this.setting={tabClass:"rc-dyn-tabs-tab",titleClass:"rc-dyn-tabs-title",iconClass:"rc-dyn-tabs-icon",selectedClass:"rc-dyn-tabs-selected",hoverClass:"rc-dyn-tabs-hover",tablistClass:"rc-dyn-tabs-tablist",closeClass:"rc-dyn-tabs-close",panelClass:"rc-dyn-tabs-panel",panellistClass:"rc-dyn-tabs-panellist",disableClass:"rc-dyn-tabs-disable",ltrClass:"rc-dyn-tabs-ltr",rtlClass:"rc-dyn-tabs-rtl",panelIdTemplate:function(t){return"rc-dyn-tabs-p-"+t},ariaLabelledbyIdTemplate:function(t){return"rc-dyn-tabs-l-"+t}},this};var Mi=function(t){return n.default.createElement("button",t.tabProps,t.children,t.hasOwnProperty("iconProps")&&n.default.createElement("span",t.iconProps))},Ni=function(t){void 0===t&&(t=null),this.defaultDirection="ltr",this._DefaulTabInnerComponent=t,this.directionsRange=["ltr","rtl"]};Ni.prototype.getOptions=function(){return this._getOptions()},Ni.prototype._getOptions=function(){var t={tabs:[],selectedTabID:"",beforeSelect:function(t,e){return!0},beforeClose:function(t,e){return!0},onOpen:function(t){},onClose:function(t){},onSelect:function(t){t.currentSelectedTabId,t.perviousSelectedTabId},onChange:function(t){t.currentData,t.perviousData},onLoad:function(t){},onDestroy:function(){},onInit:function(){},accessibility:!0,defaultPanelComponent:null},e=this.defaultDirection,n=this._DefaulTabInnerComponent,r=this;return oi(t,{direction:{get:function(){return e},set:function(t){var n;if(-1===de(n=r.directionsRange).call(n,t))throw'Invalid direction value! it can be eather of "ltr" or "rtl" ';e=t},enumerable:!0},tabComponent:{get:function(){return n},set:function(t){if(t&&"function"!=typeof t)throw"tabComponent property must be type of a function.";n=t||r._DefaulTabInnerComponent},enumerable:!0}}),t};var ki=Ge(Li).call(Li,null,(function(){return{globalDefaultOptions:new Ni(Mi).getOptions()}})),Fi=function(){this.tabsId=[]};Fi.prototype.getTab=function(){return this.tabsId.pop()},Fi.prototype.reset=function(){this.tabsId=[]},Fi.prototype.add=function(t){var e=this.tabsId;e[e.length-1]===t||e.push(t)};var Ri=function(){this._publishers={onChange:[],onLoad:[],onDestroy:[],onOpen:[],onClose:[],onSelect:[],beforeSelect:[],beforeClose:[],onInit:[],onFirstSelect:[]}};Ri.prototype.off=function(t,e){if("function"==typeof e&&this._publishers.hasOwnProperty(t)){var n,r,o=de(n=this._publishers[t]).call(n,e);o>=0&&Ae(r=this._publishers[t]).call(r,o,1)}return this},Ri.prototype.on=function(t,e){return"function"==typeof e&&this._publishers.hasOwnProperty(t)&&this._publishers[t].push(e),this},Ri.prototype.one=function(t,e){var n=this;if("function"==typeof e&&this._publishers.hasOwnProperty(t)){return this.on(t,(function r(o){e(o),n.off(t,r)}))}return this},li.setNoneEnumProps(Ri.prototype,{trigger:function(t,e){for(var n,r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];e=e||null;var a=[],s=zo(n=[]).call(n,this._publishers[t]);return Lt(s).call(s,(function(t){a.push(t.apply(e,o))})),a}});var Hi=It.findIndex,Ui="findIndex",Gi=!0;Ui in[]&&Array(1).findIndex((function(){Gi=!1})),Y({target:"Array",proto:!0,forced:Gi},{findIndex:function(t){return Hi(this,t,arguments.length>1?arguments[1]:void 0)}});var Vi=xt("Array").findIndex,Bi=Array.prototype,Wi=function(t){var e=t.findIndex;return t===Bi||t instanceof Array&&e===Bi.findIndex?Vi:e},qi=It.find,zi="find",Yi=!0;zi in[]&&Array(1).find((function(){Yi=!1})),Y({target:"Array",proto:!0,forced:Yi},{find:function(t){return qi(this,t,arguments.length>1?arguments[1]:void 0)}});var Ki=xt("Array").find,Xi=Array.prototype,Ji=function(t){var e=t.find;return t===Xi||t instanceof Array&&e===Xi.find?Ki:e},Qi=t.memo((function(t){return t.childComponent}),(function(){return!0}));function Zi(){this._data=[]}function $i(t){this._helper=t,this._state={},this._initialState=null,this._perviousState={},this._dispatch=function(){},t.setNoneEnumProps(this,{forceUpdateState:{},stateRef:{}})}Zi.prototype._getDefaultTabData=function(t){return{title:"unnamed tab",tooltip:"",panelComponent:t,closable:!0,iconClass:"",disable:!1,id:"tab_"+(new Date).getTime()}},Zi.prototype._addTab=function(t,e){var n=e.defaultPanelComponent;return t=Ei(this._getDefaultTabData(n),t),this._data.push(t),this},Zi.prototype._removeTab=function(t){var e,n,r=Wi(e=this._data).call(e,(function(e){return e.id===t}));return r>=0&&Ae(n=this._data).call(n,r,1),this},Zi.prototype.getTab=function(t){var e;return Ji(e=this._data).call(e,(function(e){return e.id===t}))},Zi.prototype.setTab=function(t,e,r){var o;void 0===e&&(e={}),void 0===r&&(r=!0);var i=Wi(o=this._data).call(o,(function(e){return e.id===t}));if(i>=0){var a=this._data[i];e.id=a.id,r&&e.panelComponent!==a.panelComponent&&n.default.isValidElement(e.panelComponent)&&(e.panelComponent=n.default.createElement(Qi,null,"newData.panelComponent")),Ei(this._data[i],e)}return e},$i.prototype._select=function(t){this._dispatch({type:De,tabId:t})},$i.prototype._close=function(t){this._dispatch({type:Ee,tabId:t})},$i.prototype._open=function(t){this._dispatch({type:xe,tabId:t})},$i.prototype._refresh=function(){this.forceUpdateState={},this._dispatch({type:Le})},li.setNoneEnumProps($i.prototype,{updateReducer:function(t,e){this.stateRef=t,this._perviousState=this._helper.getCopyState(this._state),this._state=this._helper.getCopyState(t),this._perviousState=this._perviousState.hasOwnProperty("openTabIDs")?this._perviousState:this._helper.getCopyState(this._state),this._dispatch=e}});ji.prototype=di($i.prototype),li.assingAll(ji.prototype,Zi.prototype,Ri.prototype,xi).constructor=ji;var ta=Ge(ji).call(ji,null,(function(t){void 0===t&&(t={});var e=new Fi,n=new ki({options:t});return $i.call(this,li),Zi.call(this),Ri.call(this),{activedTabsHistory:e,helper:li,optionsManager:n}}));return function(e){var r=t.useRef(null);null===r.current&&(r.current={api:new ta({options:e}),TabListComponent:null,PanelListComponent:null});var o=r.current.api,i=r.current,a=t.useReducer(fi,o.getInitialState()),s=a[0],c=a[1];return o.updateReducer(s,c),t.useLayoutEffect((function(){return o.trigger("onLoad",o.userProxy),function(){o.trigger("onDestroy",o.userProxy)}}),[]),t.useLayoutEffect((function(){o.trigger("onInit",o.userProxy)})),t.useLayoutEffect((function(){var t=o.getCopyPerviousData(),e=o.helper.getArraysDiff(s.openTabIDs,t.openTabIDs),n=e[0],r=e[1],i=t.selectedTabID!==s.selectedTabID;o.trigger("onChange",o.userProxy,{newState:s,oldState:t,closedTabsId:r,openedTabsId:n,isSwitched:i})}),[s]),i.TabListComponent||(i.TabListComponent=function(t){return void 0===t&&(t={}),n.default.createElement(Mt.Provider,{value:o},n.default.createElement(Nt.Provider,{value:o.stateRef},n.default.createElement(kt.Provider,{value:o.forceUpdateState},n.default.createElement(ne,t,"props.children"))))}),i.PanelListCompoent||(i.PanelListCompoent=function(t){return n.default.createElement(Mt.Provider,{value:o},n.default.createElement(Nt.Provider,{value:o.stateRef},n.default.createElement(kt.Provider,{value:s},n.default.createElement(ae,t,"props.children"))))}),[i.TabListComponent,i.PanelListCompoent,o.userProxy]}})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).useDynTabs=e(t.React)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(t){var e={exports:{}};return t(e,e.exports),e.exports}var i,a,s=function(t){return t&&t.Math==Math&&t},c=s("object"==typeof globalThis&&globalThis)||s("object"==typeof window&&window)||s("object"==typeof self&&self)||s("object"==typeof r&&r)||function(){return this}()||Function("return this")(),u=function(t){try{return!!t()}catch(t){return!0}},l=!u((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),f={}.propertyIsEnumerable,p=Object.getOwnPropertyDescriptor,d={f:p&&!f.call({1:2},1)?function(t){var e=p(this,t);return!!e&&e.enumerable}:f},h=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},v={}.toString,y=function(t){return v.call(t).slice(8,-1)},b="".split,g=u((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==y(t)?b.call(t,""):Object(t)}:Object,m=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},T=function(t){return g(m(t))},_=function(t){return"object"==typeof t?null!==t:"function"==typeof t},O=function(t,e){if(!_(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!_(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!_(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!_(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},S={}.hasOwnProperty,w=function(t,e){return S.call(t,e)},I=c.document,P=_(I)&&_(I.createElement),C=function(t){return P?I.createElement(t):{}},j=!l&&!u((function(){return 7!=Object.defineProperty(C("div"),"a",{get:function(){return 7}}).a})),A=Object.getOwnPropertyDescriptor,x={f:l?A:function(t,e){if(t=T(t),e=O(e,!0),j)try{return A(t,e)}catch(t){}if(w(t,e))return h(!d.f.call(t,e),t[e])}},D=/#|\.prototype\./,E=function(t,e){var n=M[L(t)];return n==k||n!=N&&("function"==typeof e?u(e):!!e)},L=E.normalize=function(t){return String(t).replace(D,".").toLowerCase()},M=E.data={},N=E.NATIVE="N",k=E.POLYFILL="P",F=E,R={},H=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t},U=function(t,e,n){if(H(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}},G=function(t){if(!_(t))throw TypeError(String(t)+" is not an object");return t},V=Object.defineProperty,B={f:l?V:function(t,e,n){if(G(t),e=O(e,!0),G(n),j)try{return V(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},W=l?function(t,e,n){return B.f(t,e,h(1,n))}:function(t,e,n){return t[e]=n,t},q=x.f,z=function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e.prototype=t.prototype,e},Y=function(t,e){var n,r,o,i,a,s,u,l,f=t.target,p=t.global,d=t.stat,h=t.proto,v=p?c:d?c[f]:(c[f]||{}).prototype,y=p?R:R[f]||(R[f]={}),b=y.prototype;for(o in e)n=!F(p?o:f+(d?".":"#")+o,t.forced)&&v&&w(v,o),a=y[o],n&&(s=t.noTargetGet?(l=q(v,o))&&l.value:v[o]),i=n&&s?s:e[o],n&&typeof a==typeof i||(u=t.bind&&n?U(i,c):t.wrap&&n?z(i):h&&"function"==typeof i?U(Function.call,i):i,(t.sham||i&&i.sham||a&&a.sham)&&W(u,"sham",!0),y[o]=u,h&&(w(R,r=f+"Prototype")||W(R,r,{}),R[r][o]=i,t.real&&b&&!b[o]&&W(b,o,i)))},K=function(t){return Object(m(t))},X=Math.ceil,J=Math.floor,Q=function(t){return isNaN(t=+t)?0:(t>0?J:X)(t)},Z=Math.min,$=function(t){return t>0?Z(Q(t),9007199254740991):0},tt=Array.isArray||function(t){return"Array"==y(t)},et="__core-js_shared__",nt=c[et]||function(t,e){try{W(c,t,e)}catch(n){c[t]=e}return e}(et,{}),rt=o((function(t){(t.exports=function(t,e){return nt[t]||(nt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.10.0",mode:"pure",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),ot=0,it=Math.random(),at=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++ot+it).toString(36)},st="process"==y(c.process),ct=function(t){return"function"==typeof t?t:void 0},ut=function(t,e){return arguments.length<2?ct(R[t])||ct(c[t]):R[t]&&R[t][e]||c[t]&&c[t][e]},lt=ut("navigator","userAgent")||"",ft=c.process,pt=ft&&ft.versions,dt=pt&&pt.v8;dt?a=(i=dt.split("."))[0]+i[1]:lt&&(!(i=lt.match(/Edge\/(\d+)/))||i[1]>=74)&&(i=lt.match(/Chrome\/(\d+)/))&&(a=i[1]);var ht=a&&+a,vt=!!Object.getOwnPropertySymbols&&!u((function(){return!Symbol.sham&&(st?38===ht:ht>37&&ht<41)})),yt=vt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,bt=rt("wks"),gt=c.Symbol,mt=yt?gt:gt&>.withoutSetter||at,Tt=function(t){return w(bt,t)&&(vt||"string"==typeof bt[t])||(vt&&w(gt,t)?bt[t]=gt[t]:bt[t]=mt("Symbol."+t)),bt[t]},_t=Tt("species"),Ot=function(t,e){var n;return tt(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!tt(n.prototype)?_(n)&&null===(n=n[_t])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)},St=[].push,wt=function(t){var e=1==t,n=2==t,r=3==t,o=4==t,i=6==t,a=7==t,s=5==t||i;return function(c,u,l,f){for(var p,d,h=K(c),v=g(h),y=U(u,l,3),b=$(v.length),m=0,T=f||Ot,_=e?T(c,b):n||a?T(c,0):void 0;b>m;m++)if((s||m in v)&&(d=y(p=v[m],m,h),t))if(e)_[m]=d;else if(d)switch(t){case 3:return!0;case 5:return p;case 6:return m;case 2:St.call(_,p)}else switch(t){case 4:return!1;case 7:St.call(_,p)}return i?-1:r||o?o:_}},It={forEach:wt(0),map:wt(1),filter:wt(2),some:wt(3),every:wt(4),find:wt(5),findIndex:wt(6),filterOut:wt(7)},Pt=Tt("species"),Ct=function(t){return ht>=51||!u((function(){var e=[];return(e.constructor={})[Pt]=function(){return{foo:1}},1!==e[t](Boolean).foo}))},jt=It.map,At=Ct("map");Y({target:"Array",proto:!0,forced:!At},{map:function(t){return jt(this,t,arguments.length>1?arguments[1]:void 0)}});var xt=function(t){return R[t+"Prototype"]},Dt=xt("Array").map,Et=Array.prototype,Lt=function(t){var e=t.map;return t===Et||t instanceof Array&&e===Et.map?Dt:e},Mt=t.createContext({}),Nt=t.createContext({}),kt=t.createContext({}),Ft=Math.max,Rt=Math.min,Ht=function(t,e){var n=Q(t);return n<0?Ft(n+e,0):Rt(n,e)},Ut=function(t){return function(e,n,r){var o,i=T(e),a=$(i.length),s=Ht(r,a);if(t&&n!=n){for(;a>s;)if((o=i[s++])!=o)return!0}else for(;a>s;s++)if((t||s in i)&&i[s]===n)return t||s||0;return!t&&-1}},Gt={includes:Ut(!0),indexOf:Ut(!1)},Vt={},Bt=Gt.indexOf,Wt=function(t,e){var n,r=T(t),o=0,i=[];for(n in r)!w(Vt,n)&&w(r,n)&&i.push(n);for(;e.length>o;)w(r,n=e[o++])&&(~Bt(i,n)||i.push(n));return i},qt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],zt=Object.keys||function(t){return Wt(t,qt)},Yt={f:Object.getOwnPropertySymbols},Kt=Object.assign,Xt=Object.defineProperty,Jt=!Kt||u((function(){if(l&&1!==Kt({b:1},Kt(Xt({},"a",{enumerable:!0,get:function(){Xt(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach((function(t){e[t]=t})),7!=Kt({},t)[n]||zt(Kt({},e)).join("")!=r}))?function(t,e){for(var n=K(t),r=arguments.length,o=1,i=Yt.f,a=d.f;r>o;)for(var s,c=g(arguments[o++]),u=i?zt(c).concat(i(c)):zt(c),f=u.length,p=0;f>p;)s=u[p++],l&&!a.call(c,s)||(n[s]=c[s]);return n}:Kt;Y({target:"Object",stat:!0,forced:Object.assign!==Jt},{assign:Jt});var Qt=R.Object.assign,Zt=Qt;function $t(){return($t=Zt||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var te=function(t){var e=t.api,n=t.id,r=t.isSelected;this._api=e,this._id=n,this._isSelected=r,this._op=e.optionsManager.options,this._setting=e.optionsManager.setting,this._tabObj=e.getTab(n)};te.prototype.getTabProps=function(){var t={"tab-id":this._id,className:this._setting.tabClass,tabIndex:-1};return this._isSelected&&(t.tabIndex=0,t.className+=" "+this._setting.selectedClass),this._tabObj.disable&&(t.tabIndex=-1,t.className+=" "+this._setting.disableClass),this._op.accessibility&&(t.role="tab",t["aria-controls"]=this._setting.panelIdTemplate(this._id),t["aria-labelledby"]=this._setting.ariaLabelledbyIdTemplate(this._id),t["aria-selected"]=t["aria-expanded"]=this._isSelected),t},te.prototype.getTabInnerProps=function(){var t={id:this._id,isSelected:this._isSelected,api:this._api.userProxy,tabProps:{"tab-id":this._id,className:this._setting.titleClass,title:this._tabObj.tooltip,tabIndex:-1}};return this._tabObj.iconClass&&(t.iconProps={className:this._setting.iconClass+" "+this._tabObj.iconClass,role:"presentation"}),this._op.accessibility&&(t.tabProps.id=this._setting.ariaLabelledbyIdTemplate(this._id),t.tabProps.role="presentation"),t},te.prototype.getCloseIconProps=function(){var t={className:this._setting.closeClass};return this._op.accessibility&&(t.role="presentation"),t};var ee=t.memo((function(t){n.default.useContext(kt);var e=t.id,r=t.selectedTabID,o=n.default.useContext(Mt),i=o.getOption("tabComponent"),a=o.getTab(e),s=new te({api:o,id:e,isSelected:r===e});return n.default.createElement("li",$t({},s.getTabProps(),{onClick:function(t){!function(t){o.eventHandlerFactory({e:t,id:e})}(t)}}),n.default.createElement(i,s.getTabInnerProps(),a.title),a.closable?n.default.createElement("span",s.getCloseIconProps(),"×"):null)}),(function(t,e){var n=t.id,r=t.selectedTabID,o=e.selectedTabID;return r===o||n!==r&&n!==o}));var ne=t.memo((function(t){var e=n.default.useContext(Nt),r=e.openTabIDs,o=e.selectedTabID,i=function(t){var e=t.api,n=e.optionsManager.setting,r=e.optionsManager.options,o={className:n.tablistClass+" "+n[r.direction+"Class"]};return r.accessibility&&(o.role="tablist"),o}({api:n.default.useContext(Mt)});return n.default.createElement("ul",i,Lt(r).call(r,(function(t){return n.default.createElement(ee,{key:t,id:t,selectedTabID:o})})))}),(function(){return!0}));var re,oe,ie=t.memo((function(e){n.default.useContext(kt);var r=e.id,o=e.selectedTabID,i=t.useContext(Mt),a=function(t){var e=t.isSelected,n=t.api,r=t.id,o=n.optionsManager.options,i=n.optionsManager.setting,a={"tab-id":r,className:i.panelClass};return e&&(a.className+=" "+i.selectedClass),o.accessibility&&(a.role="tabpanel",a.id=i.panelIdTemplate(r),a["aria-hidden"]=!e,a["aria-labelledby"]=i.ariaLabelledbyIdTemplate(r)),a}({isSelected:r===o,api:i,id:r});return n.default.createElement("div",a,i.getTab(r).panelComponent)}),(function(t,e){var n=t.id,r=t.selectedTabID,o=e.selectedTabID;return r===o||n!==r&&n!==o})),ae=t.memo((function(t){var e=n.default.useContext(Nt),r=e.openTabIDs,o=e.selectedTabID,i=n.default.useContext(Mt),a=i.optionsManager.setting,s=a.panellistClass+" "+a[i.getOption("direction")+"class"];return n.default.createElement("div",{className:s},Lt(r).call(r,(function(t){return n.default.createElement(ie,{key:t,id:t,selectedTabID:o})})))}),(function(){return!0})),se=Gt.indexOf,ce=[].indexOf,ue=!!ce&&1/[1].indexOf(1,-0)<0,le=!!(oe=[]["indexOf"])&&u((function(){oe.call(null,re||function(){throw 1},1)}));Y({target:"Array",proto:!0,forced:ue||!le},{indexOf:function(t){return ue?ce.apply(this,arguments)||0:se(this,t,arguments.length>1?arguments[1]:void 0)}});var fe=xt("Array").indexOf,pe=Array.prototype,de=function(t){var e=t.indexOf;return t===pe||t instanceof Array&&e===pe.indexOf?fe:e},he=function(t,e,n){var r=O(e);r in t?B.f(t,r,h(0,n)):t[r]=n},ve=Ct("slice"),ye=Tt("species"),be=[].slice,ge=Math.max;Y({target:"Array",proto:!0,forced:!ve},{slice:function(t,e){var n,r,o,i=T(this),a=$(i.length),s=Ht(t,a),c=Ht(void 0===e?a:e,a);if(tt(i)&&("function"!=typeof(n=i.constructor)||n!==Array&&!tt(n.prototype)?_(n)&&null===(n=n[ye])&&(n=void 0):n=void 0,n===Array||void 0===n))return be.call(i,s,c);for(r=new(void 0===n?Array:n)(ge(c-s,0)),o=0;s<c;s++,o++)s in i&&he(r,o,i[s]);return r.length=o,r}});var me=xt("Array").slice,Te=Array.prototype,_e=function(t){var e=t.slice;return t===Te||t instanceof Array&&e===Te.slice?me:e},Oe=Ct("splice"),Se=Math.max,we=Math.min,Ie=9007199254740991,Pe="Maximum allowed length exceeded";Y({target:"Array",proto:!0,forced:!Oe},{splice:function(t,e){var n,r,o,i,a,s,c=K(this),u=$(c.length),l=Ht(t,u),f=arguments.length;if(0===f?n=r=0:1===f?(n=0,r=u-l):(n=f-2,r=we(Se(Q(e),0),u-l)),u+n-r>Ie)throw TypeError(Pe);for(o=Ot(c,r),i=0;i<r;i++)(a=l+i)in c&&he(o,i,c[a]);if(o.length=r,n<r){for(i=l;i<u-r;i++)s=i+n,(a=i+r)in c?c[s]=c[a]:delete c[s];for(i=u;i>u-r+n;i--)delete c[i-1]}else if(n>r)for(i=u-r;i>l;i--)s=i+n-1,(a=i+r-1)in c?c[s]=c[a]:delete c[s];for(i=0;i<n;i++)c[i+l]=arguments[i+2];return c.length=u-r+n,o}});var Ce=xt("Array").splice,je=Array.prototype,Ae=function(t){var e=t.splice;return t===je||t instanceof Array&&e===je.splice?Ce:e},xe="open",De="close",Ee="active",Le="refresh",Me=[].slice,Ne={},ke=function(t,e,n){if(!(e in Ne)){for(var r=[],o=0;o<e;o++)r[o]="a["+o+"]";Ne[e]=Function("C,a","return new C("+r.join(",")+")")}return Ne[e](t,n)},Fe=Function.bind||function(t){var e=H(this),n=Me.call(arguments,1),r=function(){var o=n.concat(Me.call(arguments));return this instanceof r?ke(e,o.length,o):e.apply(t,o)};return _(e.prototype)&&(r.prototype=e.prototype),r};Y({target:"Function",proto:!0},{bind:Fe});var Re,He=xt("Function").bind,Ue=Function.prototype,Ge=function(t){var e=t.bind;return t===Ue||t instanceof Function&&e===Ue.bind?He:e},Ve=rt("keys"),Be=function(t){return Ve[t]||(Ve[t]=at(t))},We=!u((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),qe=Be("IE_PROTO"),ze=Object.prototype,Ye=We?Object.getPrototypeOf:function(t){return t=K(t),w(t,qe)?t[qe]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?ze:null},Ke=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return G(n),function(t){if(!_(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype")}(r),e?t.call(n,r):n.__proto__=r,n}}():void 0),Xe=l?Object.defineProperties:function(t,e){G(t);for(var n,r=zt(e),o=r.length,i=0;o>i;)B.f(t,n=r[i++],e[n]);return t},Je=ut("document","documentElement"),Qe=Be("IE_PROTO"),Ze=function(){},$e=function(t){return"<script>"+t+"</"+"script>"},tn=function(){try{Re=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;tn=Re?function(t){t.write($e("")),t.close();var e=t.parentWindow.Object;return t=null,e}(Re):((e=C("iframe")).style.display="none",Je.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write($e("document.F=Object")),t.close(),t.F);for(var n=qt.length;n--;)delete tn.prototype[qt[n]];return tn()};Vt[Qe]=!0;var en=Object.create||function(t,e){var n;return null!==t?(Ze.prototype=G(t),n=new Ze,Ze.prototype=null,n[Qe]=t):n=tn(),void 0===e?n:Xe(n,e)},nn={},rn=Tt("iterator"),on=Array.prototype,an={};an[Tt("toStringTag")]="z";var sn="[object z]"===String(an),cn=Tt("toStringTag"),un="Arguments"==y(function(){return arguments}()),ln=sn?y:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),cn))?n:un?y(e):"Object"==(r=y(e))&&"function"==typeof e.callee?"Arguments":r},fn=Tt("iterator"),pn=function(t){var e=t.return;if(void 0!==e)return G(e.call(t)).value},dn=function(t,e){this.stopped=t,this.result=e},hn=function(t,e,n){var r,o,i,a,s,c,u,l,f=n&&n.that,p=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_ITERATOR),h=!(!n||!n.INTERRUPTED),v=U(e,f,1+p+h),y=function(t){return r&&pn(r),new dn(!0,t)},b=function(t){return p?(G(t),h?v(t[0],t[1],y):v(t[0],t[1])):h?v(t,y):v(t)};if(d)r=t;else{if("function"!=typeof(o=function(t){if(null!=t)return t[fn]||t["@@iterator"]||nn[ln(t)]}(t)))throw TypeError("Target is not iterable");if(void 0!==(l=o)&&(nn.Array===l||on[rn]===l)){for(i=0,a=$(t.length);a>i;i++)if((s=b(t[i]))&&s instanceof dn)return s;return new dn(!1)}r=o.call(t)}for(c=r.next;!(u=c.call(r)).done;){try{s=b(u.value)}catch(t){throw pn(r),t}if("object"==typeof s&&s&&s instanceof dn)return s}return new dn(!1)},vn=function(t,e){var n=this;if(!(n instanceof vn))return new vn(t,e);Ke&&(n=Ke(new Error(void 0),Ye(n))),void 0!==e&&W(n,"message",String(e));var r=[];return hn(t,r.push,{that:r}),W(n,"errors",r),n};vn.prototype=en(Error.prototype,{constructor:h(5,vn),message:h(5,""),name:h(5,"AggregateError")}),Y({global:!0},{AggregateError:vn});var yn=c.Promise,bn=function(t,e,n,r){r&&r.enumerable?t[e]=n:W(t,e,n)},gn=sn?{}.toString:function(){return"[object "+ln(this)+"]"},mn=B.f,Tn=Tt("toStringTag"),_n=function(t,e,n,r){if(t){var o=n?t:t.prototype;w(o,Tn)||mn(o,Tn,{configurable:!0,value:e}),r&&!sn&&W(o,"toString",gn)}},On=Tt("species"),Sn=Function.toString;"function"!=typeof nt.inspectSource&&(nt.inspectSource=function(t){return Sn.call(t)});var wn=nt.inspectSource,In=Tt("iterator"),Pn=!1;try{var Cn=0,jn={next:function(){return{done:!!Cn++}},return:function(){Pn=!0}};jn[In]=function(){return this},Array.from(jn,(function(){throw 2}))}catch(t){}var An,xn,Dn,En=Tt("species"),Ln=function(t,e){var n,r=G(t).constructor;return void 0===r||null==(n=G(r)[En])?e:H(n)},Mn=/(iphone|ipod|ipad).*applewebkit/i.test(lt),Nn=c.location,kn=c.setImmediate,Fn=c.clearImmediate,Rn=c.process,Hn=c.MessageChannel,Un=c.Dispatch,Gn=0,Vn={},Bn="onreadystatechange",Wn=function(t){if(Vn.hasOwnProperty(t)){var e=Vn[t];delete Vn[t],e()}},qn=function(t){return function(){Wn(t)}},zn=function(t){Wn(t.data)},Yn=function(t){c.postMessage(t+"",Nn.protocol+"//"+Nn.host)};kn&&Fn||(kn=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return Vn[++Gn]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},An(Gn),Gn},Fn=function(t){delete Vn[t]},st?An=function(t){Rn.nextTick(qn(t))}:Un&&Un.now?An=function(t){Un.now(qn(t))}:Hn&&!Mn?(Dn=(xn=new Hn).port2,xn.port1.onmessage=zn,An=U(Dn.postMessage,Dn,1)):c.addEventListener&&"function"==typeof postMessage&&!c.importScripts&&Nn&&"file:"!==Nn.protocol&&!u(Yn)?(An=Yn,c.addEventListener("message",zn,!1)):An=Bn in C("script")?function(t){Je.appendChild(C("script")).onreadystatechange=function(){Je.removeChild(this),Wn(t)}}:function(t){setTimeout(qn(t),0)});var Kn,Xn,Jn,Qn,Zn,$n,tr,er,nr={set:kn,clear:Fn},rr=/web0s(?!.*chrome)/i.test(lt),or=x.f,ir=nr.set,ar=c.MutationObserver||c.WebKitMutationObserver,sr=c.document,cr=c.process,ur=c.Promise,lr=or(c,"queueMicrotask"),fr=lr&&lr.value;fr||(Kn=function(){var t,e;for(st&&(t=cr.domain)&&t.exit();Xn;){e=Xn.fn,Xn=Xn.next;try{e()}catch(t){throw Xn?Qn():Jn=void 0,t}}Jn=void 0,t&&t.enter()},Mn||st||rr||!ar||!sr?ur&&ur.resolve?(tr=ur.resolve(void 0),er=tr.then,Qn=function(){er.call(tr,Kn)}):Qn=st?function(){cr.nextTick(Kn)}:function(){ir.call(c,Kn)}:(Zn=!0,$n=sr.createTextNode(""),new ar(Kn).observe($n,{characterData:!0}),Qn=function(){$n.data=Zn=!Zn}));var pr,dr,hr,vr=fr||function(t){var e={fn:t,next:void 0};Jn&&(Jn.next=e),Xn||(Xn=e,Qn()),Jn=e},yr=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=H(e),this.reject=H(n)},br={f:function(t){return new yr(t)}},gr=function(t,e){if(G(t),_(e)&&e.constructor===t)return e;var n=br.f(t);return(0,n.resolve)(e),n.promise},mr=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Tr=c.WeakMap,_r="function"==typeof Tr&&/native code/.test(wn(Tr)),Or=c.WeakMap;if(_r){var Sr=nt.state||(nt.state=new Or),wr=Sr.get,Ir=Sr.has,Pr=Sr.set;pr=function(t,e){return e.facade=t,Pr.call(Sr,t,e),e},dr=function(t){return wr.call(Sr,t)||{}},hr=function(t){return Ir.call(Sr,t)}}else{var Cr=Be("state");Vt[Cr]=!0,pr=function(t,e){return e.facade=t,W(t,Cr,e),e},dr=function(t){return w(t,Cr)?t[Cr]:{}},hr=function(t){return w(t,Cr)}}var jr={set:pr,get:dr,has:hr,enforce:function(t){return hr(t)?dr(t):pr(t,{})},getterFor:function(t){return function(e){var n;if(!_(e)||(n=dr(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},Ar=nr.set,xr=Tt("species"),Dr="Promise",Er=jr.get,Lr=jr.set,Mr=jr.getterFor(Dr),Nr=yn,kr=c.TypeError,Fr=c.document,Rr=c.process;ut("fetch");var Hr,Ur,Gr,Vr=br.f,Br=Vr,Wr=!!(Fr&&Fr.createEvent&&c.dispatchEvent),qr="function"==typeof PromiseRejectionEvent,zr="unhandledrejection",Yr=F(Dr,(function(){if(!(wn(Nr)!==String(Nr))){if(66===ht)return!0;if(!st&&!qr)return!0}if(!Nr.prototype.finally)return!0;if(ht>=51&&/native code/.test(Nr))return!1;var t=Nr.resolve(1),e=function(t){t((function(){}),(function(){}))};return(t.constructor={})[xr]=e,!(t.then((function(){}))instanceof e)})),Kr=Yr||!function(t,e){if(!e&&!Pn)return!1;var n=!1;try{var r={};r[In]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n}((function(t){Nr.all(t).catch((function(){}))})),Xr=function(t){var e;return!(!_(t)||"function"!=typeof(e=t.then))&&e},Jr=function(t,e){if(!t.notified){t.notified=!0;var n=t.reactions;vr((function(){for(var r=t.value,o=1==t.state,i=0;n.length>i;){var a,s,c,u=n[i++],l=o?u.ok:u.fail,f=u.resolve,p=u.reject,d=u.domain;try{l?(o||(2===t.rejection&&to(t),t.rejection=1),!0===l?a=r:(d&&d.enter(),a=l(r),d&&(d.exit(),c=!0)),a===u.promise?p(kr("Promise-chain cycle")):(s=Xr(a))?s.call(a,f,p):f(a)):p(r)}catch(t){d&&!c&&d.exit(),p(t)}}t.reactions=[],t.notified=!1,e&&!t.rejection&&Zr(t)}))}},Qr=function(t,e,n){var r,o;Wr?((r=Fr.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),c.dispatchEvent(r)):r={promise:e,reason:n},!qr&&(o=c["on"+t])?o(r):t===zr&&function(t,e){var n=c.console;n&&n.error&&(1===arguments.length?n.error(t):n.error(t,e))}("Unhandled promise rejection",n)},Zr=function(t){Ar.call(c,(function(){var e,n=t.facade,r=t.value;if($r(t)&&(e=mr((function(){st?Rr.emit("unhandledRejection",r,n):Qr(zr,n,r)})),t.rejection=st||$r(t)?2:1,e.error))throw e.value}))},$r=function(t){return 1!==t.rejection&&!t.parent},to=function(t){Ar.call(c,(function(){var e=t.facade;st?Rr.emit("rejectionHandled",e):Qr("rejectionhandled",e,t.value)}))},eo=function(t,e,n){return function(r){t(e,r,n)}},no=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,Jr(t,!0))},ro=function(t,e,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===e)throw kr("Promise can't be resolved itself");var r=Xr(e);r?vr((function(){var n={done:!1};try{r.call(e,eo(ro,n,t),eo(no,n,t))}catch(e){no(n,e,t)}})):(t.value=e,t.state=1,Jr(t,!1))}catch(e){no({done:!1},e,t)}}};Yr&&(Nr=function(t){!function(t,e,n){if(!(t instanceof e))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation")}(this,Nr,Dr),H(t),Hr.call(this);var e=Er(this);try{t(eo(ro,e),eo(no,e))}catch(t){no(e,t)}},(Hr=function(t){Lr(this,{type:Dr,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=function(t,e,n){for(var r in e)n&&n.unsafe&&t[r]?t[r]=e[r]:bn(t,r,e[r],n);return t}(Nr.prototype,{then:function(t,e){var n=Mr(this),r=Vr(Ln(this,Nr));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=st?Rr.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&Jr(n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),Ur=function(){var t=new Hr,e=Er(t);this.promise=t,this.resolve=eo(ro,e),this.reject=eo(no,e)},br.f=Vr=function(t){return t===Nr||t===Gr?new Ur(t):Br(t)}),Y({global:!0,wrap:!0,forced:Yr},{Promise:Nr}),_n(Nr,Dr,!1,!0),function(t){var e=ut(t),n=B.f;l&&e&&!e[On]&&n(e,On,{configurable:!0,get:function(){return this}})}(Dr),Gr=ut(Dr),Y({target:Dr,stat:!0,forced:Yr},{reject:function(t){var e=Vr(this);return e.reject.call(void 0,t),e.promise}}),Y({target:Dr,stat:!0,forced:!0},{resolve:function(t){return gr(this===Gr?Nr:this,t)}}),Y({target:Dr,stat:!0,forced:Kr},{all:function(t){var e=this,n=Vr(e),r=n.resolve,o=n.reject,i=mr((function(){var n=H(e.resolve),i=[],a=0,s=1;hn(t,(function(t){var c=a++,u=!1;i.push(void 0),s++,n.call(e,t).then((function(t){u||(u=!0,i[c]=t,--s||r(i))}),o)})),--s||r(i)}));return i.error&&o(i.value),n.promise},race:function(t){var e=this,n=Vr(e),r=n.reject,o=mr((function(){var o=H(e.resolve);hn(t,(function(t){o.call(e,t).then(n.resolve,r)}))}));return o.error&&r(o.value),n.promise}}),Y({target:"Promise",stat:!0},{allSettled:function(t){var e=this,n=br.f(e),r=n.resolve,o=n.reject,i=mr((function(){var n=H(e.resolve),o=[],i=0,a=1;hn(t,(function(t){var s=i++,c=!1;o.push(void 0),a++,n.call(e,t).then((function(t){c||(c=!0,o[s]={status:"fulfilled",value:t},--a||r(o))}),(function(t){c||(c=!0,o[s]={status:"rejected",reason:t},--a||r(o))}))})),--a||r(o)}));return i.error&&o(i.value),n.promise}});var oo="No one promise resolved";Y({target:"Promise",stat:!0},{any:function(t){var e=this,n=br.f(e),r=n.resolve,o=n.reject,i=mr((function(){var n=H(e.resolve),i=[],a=0,s=1,c=!1;hn(t,(function(t){var u=a++,l=!1;i.push(void 0),s++,n.call(e,t).then((function(t){l||c||(c=!0,r(t))}),(function(t){l||c||(l=!0,i[u]=t,--s||o(new(ut("AggregateError"))(i,oo)))}))})),--s||o(new(ut("AggregateError"))(i,oo))}));return i.error&&o(i.value),n.promise}});var io=!!yn&&u((function(){yn.prototype.finally.call({then:function(){}},(function(){}))}));Y({target:"Promise",proto:!0,real:!0,forced:io},{finally:function(t){var e=Ln(this,ut("Promise")),n="function"==typeof t;return this.then(n?function(n){return gr(e,t()).then((function(){return n}))}:t,n?function(n){return gr(e,t()).then((function(){throw n}))}:t)}});var ao,so,co,uo=function(t){return function(e,n){var r,o,i=String(m(e)),a=Q(n),s=i.length;return a<0||a>=s?t?"":void 0:(r=i.charCodeAt(a))<55296||r>56319||a+1===s||(o=i.charCodeAt(a+1))<56320||o>57343?t?i.charAt(a):r:t?i.slice(a,a+2):o-56320+(r-55296<<10)+65536}},lo={codeAt:uo(!1),charAt:uo(!0)},fo=Tt("iterator"),po=!1;[].keys&&("next"in(co=[].keys())?(so=Ye(Ye(co)))!==Object.prototype&&(ao=so):po=!0);var ho=null==ao||u((function(){var t={};return ao[fo].call(t)!==t}));ho&&(ao={}),ho&&!w(ao,fo)&&W(ao,fo,(function(){return this}));var vo={IteratorPrototype:ao,BUGGY_SAFARI_ITERATORS:po},yo=vo.IteratorPrototype,bo=function(){return this},go=vo.IteratorPrototype,mo=vo.BUGGY_SAFARI_ITERATORS,To=Tt("iterator"),_o="keys",Oo="values",So="entries",wo=function(){return this},Io=function(t,e,n,r,o,i,a){!function(t,e,n){var r=e+" Iterator";t.prototype=en(yo,{next:h(1,n)}),_n(t,r,!1,!0),nn[r]=bo}(n,e,r);var s,c,u,l=function(t){if(t===o&&y)return y;if(!mo&&t in d)return d[t];switch(t){case _o:case Oo:case So:return function(){return new n(this,t)}}return function(){return new n(this)}},f=e+" Iterator",p=!1,d=t.prototype,v=d[To]||d["@@iterator"]||o&&d[o],y=!mo&&v||l(o),b="Array"==e&&d.entries||v;if(b&&(s=Ye(b.call(new t)),go!==Object.prototype&&s.next&&(_n(s,f,!0,!0),nn[f]=wo)),o==Oo&&v&&v.name!==Oo&&(p=!0,y=function(){return v.call(this)}),a&&d[To]!==y&&W(d,To,y),nn[e]=y,o)if(c={values:l(Oo),keys:i?y:l(_o),entries:l(So)},a)for(u in c)(mo||p||!(u in d))&&bn(d,u,c[u]);else Y({target:e,proto:!0,forced:mo||p},c);return c},Po=lo.charAt,Co="String Iterator",jo=jr.set,Ao=jr.getterFor(Co);Io(String,"String",(function(t){jo(this,{type:Co,string:String(t),index:0})}),(function(){var t,e=Ao(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=Po(n,r),e.index+=t.length,{value:t,done:!1})}));var xo="Array Iterator",Do=jr.set,Eo=jr.getterFor(xo);Io(Array,"Array",(function(t,e){Do(this,{type:xo,target:T(t),index:0,kind:e})}),(function(){var t=Eo(this),e=t.target,n=t.kind,r=t.index++;return!e||r>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:e[r],done:!1}:{value:[r,e[r]],done:!1}}),"values"),nn.Arguments=nn.Array;var Lo=Tt("toStringTag");for(var Mo in{CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}){var No=c[Mo],ko=No&&No.prototype;ko&&ln(ko)!==Lo&&W(ko,Lo,Mo),nn[Mo]=nn.Array}var Fo=R.Promise,Ro=Tt("isConcatSpreadable"),Ho=9007199254740991,Uo="Maximum allowed index exceeded",Go=ht>=51||!u((function(){var t=[];return t[Ro]=!1,t.concat()[0]!==t})),Vo=Ct("concat"),Bo=function(t){if(!_(t))return!1;var e=t[Ro];return void 0!==e?!!e:tt(t)};Y({target:"Array",proto:!0,forced:!Go||!Vo},{concat:function(t){var e,n,r,o,i,a=K(this),s=Ot(a,0),c=0;for(e=-1,r=arguments.length;e<r;e++)if(Bo(i=-1===e?a:arguments[e])){if(c+(o=$(i.length))>Ho)throw TypeError(Uo);for(n=0;n<o;n++,c++)n in i&&he(s,c,i[n])}else{if(c>=Ho)throw TypeError(Uo);he(s,c++,i)}return s.length=c,s}});var Wo=xt("Array").concat,qo=Array.prototype,zo=function(t){var e=t.concat;return t===qo||t instanceof Array&&e===qo.concat?Wo:e},Yo=u((function(){zt(1)}));Y({target:"Object",stat:!0,forced:Yo},{keys:function(t){return zt(K(t))}});var Ko=R.Object.keys,Xo=qt.concat("length","prototype"),Jo={f:Object.getOwnPropertyNames||function(t){return Wt(t,Xo)}}.f,Qo={}.toString,Zo="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],$o=function(t){return Zo&&"[object Window]"==Qo.call(t)?function(t){try{return Jo(t)}catch(t){return Zo.slice()}}(t):Jo(T(t))},ti=u((function(){return!Object.getOwnPropertyNames(1)}));Y({target:"Object",stat:!0,forced:ti},{getOwnPropertyNames:$o});var ei=R.Object,ni=function(t){return ei.getOwnPropertyNames(t)};Y({target:"Object",stat:!0,forced:!l,sham:!l},{defineProperty:B.f});var ri=o((function(t){var e=R.Object,n=t.exports=function(t,n,r){return e.defineProperty(t,n,r)};e.defineProperty.sham&&(n.sham=!0)}));Y({target:"Object",stat:!0,forced:!l,sham:!l},{defineProperties:Xe});var oi=o((function(t){var e=R.Object,n=t.exports=function(t,n){return e.defineProperties(t,n)};e.defineProperties.sham&&(n.sham=!0)})),ii=[].reverse,ai=[1,2];Y({target:"Array",proto:!0,forced:String(ai)===String(ai.reverse())},{reverse:function(){return tt(this)&&(this.length=this.length),ii.call(this)}});var si=xt("Array").reverse,ci=Array.prototype,ui=function(t){var e=t.reverse;return t===ci||t instanceof Array&&e===ci.reverse?si:e},li={};function fi(t,e){switch(e.type){case De:var n=t.openTabIDs,r=de(n).call(n,e.tabId);if(r>=0){var o=_e(n).call(n);return Ae(o).call(o,r,1),{selectedTabID:t.selectedTabID,openTabIDs:o}}return t;case xe:var i=t.openTabIDs,a=e.tabId;if(-1===de(i).call(i,a)){var s=_e(i).call(i);return s.push(a),{selectedTabID:t.selectedTabID,openTabIDs:s}}return t;case Le:return li.getCopyState(t);case Ee:var c=e.tabId;return t.selectedTabID!==c?{selectedTabID:c,openTabIDs:t.openTabIDs}:t;default:throw new Error("Undefined action type '"+e.type+"'")}}li.checkArrIndex=function(t,e){return t>=0&&t<e},li.getInstance=function(t){new(Ge(Function.prototype).apply(t,arguments))},li.resolve=function(t){return Fo.resolve(t)},li.getCopyState=function(t){var e,n=$t({},t);return n.hasOwnProperty("openTabIDs")&&(n.openTabIDs=zo(e=[]).call(e,n.openTabIDs)),n},li.assingAll=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Lt(n).call(n,(function(e){var n,r=Ko(e);Lt(n=ni(e)).call(n,(function(n){de(r).call(r,n)>=0?t[n]=e[n]:ri(t,n,{value:e[n],writable:!0})}))})),t},li.setNoneEnumProps=function(t,e){var n,r={};return Lt(n=Ko(e)).call(n,(function(t){r[t]={writable:!0,value:e[t]}})),oi(t,r)},li.getArraysDiff=function(t,e){var n,r,o=zo(n=[]).call(n,t),i=zo(r=[]).call(r,e);return Lt(t).call(t,(function(t){de(e).call(e,t)>=0&&(Ae(o).call(o,de(o).call(o,t),1),Ae(i).call(i,de(i).call(i,t),1))})),[o,i]},li.arrFilterUntilFirstValue=function(t,e,n){n&&ui(t).call(t);for(var r=0,o=t.length;r<o;r++)if(e(t[r],r,t))return t[r];return null},li.throwMissingParam=function(t){throw'Missing parameter in "'+t+'" function'},li.throwInvalidParam=function(t){throw'Invalid parameter error in "'+t+'" function'},li.isObj=function(t){return"[object Object]"===Object.prototype.toString.call(t)},Y({target:"Object",stat:!0,sham:!l},{create:en});var pi=R.Object,di=function(t,e){return pi.create(t,e)},hi=Gt.includes;Y({target:"Array",proto:!0},{includes:function(t){return hi(this,t,arguments.length>1?arguments[1]:void 0)}});var vi=xt("Array").includes,yi=Tt("match"),bi=function(t){if(function(t){var e;return _(t)&&(void 0!==(e=t[yi])?!!e:"RegExp"==y(t))}(t))throw TypeError("The method doesn't accept regular expressions");return t},gi=Tt("match");Y({target:"String",proto:!0,forced:!function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[gi]=!1,"/./"[t](e)}catch(t){}}return!1}("includes")},{includes:function(t){return!!~String(m(this)).indexOf(bi(t),arguments.length>1?arguments[1]:void 0)}});var mi,Ti,_i,Oi,Si=xt("String").includes,wi=Array.prototype,Ii=String.prototype,Pi=function(t){var e=t.includes;return t===wi||t instanceof Array&&e===wi.includes?vi:"string"==typeof t||t===Ii||t instanceof String&&e===Ii.includes?Si:e},Ci=li.throwMissingParam,ji=function(t,e){void 0===e&&(e={options:{}});var n=t.call(this,e.options),r=n.optionsManager,o=n.helper,i=n.activedTabsHistory;o.setNoneEnumProps(this,{optionsManager:r,helper:o,activedTabsHistory:i}),this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions()},Ai={_setUserProxy:function(){var t=this,e={},n=this;for(var r in this)"_"!==r[0]&&"constructor"!==r&&function(){var o=t[r];e[r]="function"==typeof o?function(){var t=o.apply(n,arguments);return t===n?e:t}:o}();return this.userProxy=e,this},_subscribeCallbacksOptions:function(){var t,e=this,n=this.optionsManager.options;return Lt(t=Ko(this._publishers)).call(t,(function(t){e.on(t,(function(){n[t].apply(this,arguments)}))})),this},_subscribeSelectedTabsHistory:function(){var t=this;return this.on("onChange",(function(e){var n=e.isSwitched,r=e.oldState;n&&t.activedTabsHistory.add(r.selectedTabID)})),this},getOption:function(t){return this.optionsManager.getOption(t)},setOption:function(t,e){return this.optionsManager.setOption(t,e)},getCopyPerviousData:function(){return this.helper.getCopyState(this._perviousState)},getCopyData:function(){return this.helper.getCopyState(this._state)},isSelected:function(t){return void 0===t&&(t=Ci("isSelected")),this._state.selectedTabID==t},isOpen:function(t){var e;return void 0===t&&(t=Ci("isOpen")),de(e=this._state.openTabIDs).call(e,t)>=0},_getOnChangePromise:function(){var t=this;return new Fo((function(e){t.one("onChange",(function(){e.call(t.userProxy)}))}))},select:function(t){void 0===t&&(t=Ci("select"));var e=this._getOnChangePromise();return this._select(t),e},_findTabIdForSwitching:(mi=function(t,e){var n=this;return this.helper.arrFilterUntilFirstValue(t,(function(t){return n.isOpen(t)&&!n.getTab(t).disable&&!n.isSelected(t)}),e)||""},Ti=function(){var t;return mi.call(this,zo(t=[]).call(t,this.activedTabsHistory.tabsId),!0)},_i=function(){var t=this._state,e=t.openTabIDs;return mi.call(this,_e(e).call(e,0,de(e).call(e,t.selectedTabID)),!0)},Oi=function(){var t=this._state,e=t.openTabIDs;return mi.call(this,_e(e).call(e,de(e).call(e,t.selectedTabID)+1))},function(){return Ti.call(this)||_i.call(this)||Oi.call(this)}),open:function(t){void 0===t&&(t=Ci("open"));var e=this._getOnChangePromise();return this._open(t.id),this._addTab(t,{defaultPanelComponent:this.getOption("defaultPanelComponent")}),e},__close:function(t){var e=this._getOnChangePromise();return this._close(t),this._removeTab(t),e},close:function(t){if(void 0===t&&(t=Ci("close")),this.isSelected(t)){var e,n=zo(e=[]).call(e,this._state.openTabIDs);return Ae(n).call(n,de(n).call(n,t),1),this.select(this._findTabIdForSwitching()),this.__close(t)}return this.__close(t)},refresh:function(){var t=this._getOnChangePromise();return this._refresh(),t}};li.setNoneEnumProps(Ai,{getInitialState:function(){var t=this;if(!this._initialState){var e=this.optionsManager.options,n=e.selectedTabID,r=e.tabs,o=e.defaultPanelComponent,i=[];Lt(r).call(r,(function(e){t._addTab(e,{defaultPanelComponent:o}),i.push(e.id)})),this._initialState={selectedTabID:n,openTabIDs:i}}return this._initialState},onChange:function(t){var e=t.newState,n=t.oldState,r=t.closedTabsId,o=t.openedTabsId,i=t.isSwitched;return(i||o.length||r.length)&&(this.trigger("onChange",this.userProxy,{currentData:$t({},e),perviousData:$t({},n)}),o.length&&this.trigger("onOpen",this.userProxy,o),r.length&&this.trigger("onClose",this.userProxy,r),i&&this.trigger("onSelect",this.userProxy,{currentSelectedTabId:e.selectedTabID,perviousSelectedTabId:n.selectedTabID})),this},eventHandlerFactory:function(t){var e,n,r=t.e,o=t.id,i=r.target,a=i.parentElement,s=this.optionsManager.setting,c=s.closeClass,u=s.tabClass;Pi(e=i.className).call(e,c)&&a&&a.lastChild&&a.lastChild==i&&Pi(n=a.className).call(n,u)?!1!==this.getOption("beforeClose").call(this.userProxy,r,o)&&this.close(o):!1!==this.getOption("beforeSelect").call(this.userProxy,r,o)&&this.select(o)}});var xi=Ai,Di=Qt,Ei=li.throwMissingParam;function Li(t,e){var n=e.options,r=t().globalDefaultOptions;this._defaultOptions=r,this._validateOptions(n),this.options=Di({},this._defaultOptions,n),this._setSetting()}Li.prototype.getOption=function(t){return this.options[t]},Li.prototype.setOption=function(t,e){return void 0===t&&(t=Ei("setOption")),void 0===e&&(e=Ei("setOption")),"SELECTEDTABID"===t.toUpperCase()||this._defaultOptions.hasOwnProperty(t)&&(this.options[t]=e),this},Li.prototype._validateOptions=function(t){if("[object Object]"!==Object.prototype.toString.call(t))throw'Invalid argument in "useDynamicTabs" function. Argument must be type of an object';return this},Li.prototype._setSetting=function(){return this.setting={tabClass:"rc-dyn-tabs-tab",titleClass:"rc-dyn-tabs-title",iconClass:"rc-dyn-tabs-icon",selectedClass:"rc-dyn-tabs-selected",hoverClass:"rc-dyn-tabs-hover",tablistClass:"rc-dyn-tabs-tablist",closeClass:"rc-dyn-tabs-close",panelClass:"rc-dyn-tabs-panel",panellistClass:"rc-dyn-tabs-panellist",disableClass:"rc-dyn-tabs-disable",ltrClass:"rc-dyn-tabs-ltr",rtlClass:"rc-dyn-tabs-rtl",panelIdTemplate:function(t){return"rc-dyn-tabs-p-"+t},ariaLabelledbyIdTemplate:function(t){return"rc-dyn-tabs-l-"+t}},this};var Mi=function(t){return n.default.createElement("button",t.tabProps,t.children,t.hasOwnProperty("iconProps")&&n.default.createElement("span",t.iconProps))},Ni=function(t){void 0===t&&(t=null),this.defaultDirection="ltr",this._DefaulTabInnerComponent=t,this.directionsRange=["ltr","rtl"]};Ni.prototype.getOptions=function(){return this._getOptions()},Ni.prototype._getOptions=function(){var t={tabs:[],selectedTabID:"",beforeSelect:function(t,e){return!0},beforeClose:function(t,e){return!0},onOpen:function(t){},onClose:function(t){},onSelect:function(t){t.currentSelectedTabId,t.perviousSelectedTabId},onChange:function(t){t.currentData,t.perviousData},onLoad:function(t){},onDestroy:function(){},onInit:function(){},accessibility:!0,defaultPanelComponent:null},e=this.defaultDirection,n=this._DefaulTabInnerComponent,r=this;return oi(t,{direction:{get:function(){return e},set:function(t){var n;if(-1===de(n=r.directionsRange).call(n,t))throw'Invalid direction value! it can be eather of "ltr" or "rtl" ';e=t},enumerable:!0},tabComponent:{get:function(){return n},set:function(t){if(t&&"function"!=typeof t)throw"tabComponent property must be type of a function.";n=t||r._DefaulTabInnerComponent},enumerable:!0}}),t};var ki=Ge(Li).call(Li,null,(function(){return{globalDefaultOptions:new Ni(Mi).getOptions()}})),Fi=function(){this.tabsId=[]};Fi.prototype.getTab=function(){return this.tabsId.pop()},Fi.prototype.reset=function(){this.tabsId=[]},Fi.prototype.add=function(t){var e=this.tabsId;e[e.length-1]===t||e.push(t)};var Ri=function(){this._publishers={onChange:[],onLoad:[],onDestroy:[],onOpen:[],onClose:[],onSelect:[],onInit:[],onFirstSelect:[]}};Ri.prototype.off=function(t,e){if("function"==typeof e&&this._publishers.hasOwnProperty(t)){var n,r,o=de(n=this._publishers[t]).call(n,e);o>=0&&Ae(r=this._publishers[t]).call(r,o,1)}return this},Ri.prototype.on=function(t,e){return"function"==typeof e&&this._publishers.hasOwnProperty(t)&&this._publishers[t].push(e),this},Ri.prototype.one=function(t,e){var n=this;if("function"==typeof e&&this._publishers.hasOwnProperty(t)){return this.on(t,(function r(o){e(o),n.off(t,r)}))}return this},li.setNoneEnumProps(Ri.prototype,{trigger:function(t,e){for(var n,r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];e=e||null;var a=[],s=zo(n=[]).call(n,this._publishers[t]);return Lt(s).call(s,(function(t){a.push(t.apply(e,o))})),a}});var Hi=It.findIndex,Ui="findIndex",Gi=!0;Ui in[]&&Array(1).findIndex((function(){Gi=!1})),Y({target:"Array",proto:!0,forced:Gi},{findIndex:function(t){return Hi(this,t,arguments.length>1?arguments[1]:void 0)}});var Vi=xt("Array").findIndex,Bi=Array.prototype,Wi=function(t){var e=t.findIndex;return t===Bi||t instanceof Array&&e===Bi.findIndex?Vi:e},qi=It.find,zi="find",Yi=!0;zi in[]&&Array(1).find((function(){Yi=!1})),Y({target:"Array",proto:!0,forced:Yi},{find:function(t){return qi(this,t,arguments.length>1?arguments[1]:void 0)}});var Ki=xt("Array").find,Xi=Array.prototype,Ji=function(t){var e=t.find;return t===Xi||t instanceof Array&&e===Xi.find?Ki:e},Qi=t.memo((function(t){return t.childComponent}),(function(){return!0}));function Zi(){this._data=[]}function $i(t){this._helper=t,this._state={},this._initialState=null,this._perviousState={},this._dispatch=function(){},t.setNoneEnumProps(this,{forceUpdateState:{},stateRef:{}})}Zi.prototype._getDefaultTabData=function(t){return{title:"",tooltip:"",panelComponent:t,closable:!0,iconClass:"",disable:!1,id:"tab_"+(new Date).getTime()}},Zi.prototype._addTab=function(t,e){var n=e.defaultPanelComponent;return t=Di(this._getDefaultTabData(n),t),this._data.push(t),this},Zi.prototype._removeTab=function(t){var e,n,r=Wi(e=this._data).call(e,(function(e){return e.id===t}));return r>=0&&Ae(n=this._data).call(n,r,1),this},Zi.prototype.getTab=function(t){var e;return Ji(e=this._data).call(e,(function(e){return e.id===t}))},Zi.prototype.setTab=function(t,e,r){var o;void 0===e&&(e={}),void 0===r&&(r=!0);var i=Wi(o=this._data).call(o,(function(e){return e.id===t}));if(i>=0){var a=this._data[i];e.id=a.id,r&&e.panelComponent!==a.panelComponent&&n.default.isValidElement(e.panelComponent)&&(e.panelComponent=n.default.createElement(Qi,null,"newData.panelComponent")),Di(this._data[i],e)}return e},$i.prototype._select=function(t){this._dispatch({type:Ee,tabId:t})},$i.prototype._close=function(t){this._dispatch({type:De,tabId:t})},$i.prototype._open=function(t){this._dispatch({type:xe,tabId:t})},$i.prototype._refresh=function(){this.forceUpdateState={},this._dispatch({type:Le})},li.setNoneEnumProps($i.prototype,{updateReducer:function(t,e){this.stateRef=t,this._perviousState=this._helper.getCopyState(this._state),this._state=this._helper.getCopyState(t),this._perviousState=this._perviousState.hasOwnProperty("openTabIDs")?this._perviousState:this._helper.getCopyState(this._state),this._dispatch=e}});ji.prototype=di($i.prototype),li.assingAll(ji.prototype,Zi.prototype,Ri.prototype,xi).constructor=ji;var ta=Ge(ji).call(ji,null,(function(t){void 0===t&&(t={});var e=new Fi,n=new ki({options:t});return $i.call(this,li),Zi.call(this),Ri.call(this),{activedTabsHistory:e,helper:li,optionsManager:n}}));return function(e){var r=t.useRef(null);null===r.current&&(r.current={api:new ta({options:e}),TabListComponent:null,PanelListComponent:null});var o=r.current.api,i=r.current,a=t.useReducer(fi,o.getInitialState()),s=a[0],c=a[1];return o.updateReducer(s,c),t.useLayoutEffect((function(){return o.trigger("onLoad",o.userProxy),function(){o.trigger("onDestroy",o.userProxy)}}),[]),t.useLayoutEffect((function(){o.trigger("onInit",o.userProxy)})),t.useLayoutEffect((function(){var t=o.getCopyPerviousData(),e=o.helper.getArraysDiff(s.openTabIDs,t.openTabIDs),n=e[0],r=e[1],i=t.selectedTabID!==s.selectedTabID;o.onChange({newState:s,oldState:t,closedTabsId:r,openedTabsId:n,isSwitched:i})}),[s]),i.TabListComponent||(i.TabListComponent=function(t){return void 0===t&&(t={}),n.default.createElement(Mt.Provider,{value:o},n.default.createElement(Nt.Provider,{value:o.stateRef},n.default.createElement(kt.Provider,{value:o.forceUpdateState},n.default.createElement(ne,t,"props.children"))))}),i.PanelListCompoent||(i.PanelListCompoent=function(t){return n.default.createElement(Mt.Provider,{value:o},n.default.createElement(Nt.Provider,{value:o.stateRef},n.default.createElement(kt.Provider,{value:s},n.default.createElement(ae,t,"props.children"))))}),[i.TabListComponent,i.PanelListCompoent,o.userProxy]}})); | ||
//# sourceMappingURL=react-dyn-tabs.including-polyfills.umd.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).useDynTabs=e(t.React)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t),i=t.createContext({}),s=t.createContext({}),a=t.createContext({}),o=function(t){var e=t.api,n=t.id,i=t.isSelected;this._api=e,this._id=n,this._isSelected=i,this._op=e.optionsManager.options,this._setting=e.optionsManager.setting,this._tabObj=e.getTab(n)};function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}o.prototype.getTabProps=function(){var t={"tab-id":this._id,className:this._setting.tabClass,tabIndex:-1};return this._isSelected&&(t.tabIndex=0,t.className+=" "+this._setting.selectedClass),this._tabObj.disable&&(t.tabIndex=-1,t.className+=" "+this._setting.disableClass),this._op.accessibility&&(t.role="tab",t["aria-controls"]=this._setting.panelIdTemplate(this._id),t["aria-labelledby"]=this._setting.ariaLabelledbyIdTemplate(this._id),t["aria-selected"]=t["aria-expanded"]=this._isSelected),t},o.prototype.getTabInnerProps=function(){var t={id:this._id,isSelected:this._isSelected,api:this._api.userProxy,tabProps:{"tab-id":this._id,className:this._setting.titleClass,tabIndex:-1}};return this._tabObj.iconClass&&(t.iconProps={className:this._setting.iconClass+" "+this._tabObj.iconClass,role:"presentation"}),this._op.accessibility&&(t.tabProps.id=this._setting.ariaLabelledbyIdTemplate(this._id),t.tabProps.role="presentation"),t},o.prototype.getCloseIconProps=function(){var t={className:this._setting.closeClass};return this._op.accessibility&&(t.role="presentation"),t};var l=t.memo((function(t){n.default.useContext(a);var e=t.id,s=t.selectedTabID,l=n.default.useContext(i),c=l.getOption("tabComponent"),u=l.getTab(e),p=new o({api:l,id:e,isSelected:s===e});return n.default.createElement("li",r({},p.getTabProps(),{onClick:function(t){!function(t){l.eventHandlerFactory({e:t,id:e})}(t)}}),n.default.createElement(c,p.getTabInnerProps(),u.title),u.closable?n.default.createElement("span",p.getCloseIconProps(),"×"):null)}),(function(t,e){var n=t.id,i=t.selectedTabID,s=e.selectedTabID;return i===s||n!==i&&n!==s}));var c=t.memo((function(t){var e=n.default.useContext(s),a=e.openTabIDs,o=e.selectedTabID,r=function(t){var e=t.api,n=e.optionsManager.setting,i=e.optionsManager.options,s={className:n.tablistClass+" "+n[i.direction+"Class"]};return i.accessibility&&(s.role="tablist"),s}({api:n.default.useContext(i)});return n.default.createElement("ul",r,a.map((function(t){return n.default.createElement(l,{key:t,id:t,selectedTabID:o})})))}),(function(){return!0}));var u=t.memo((function(e){n.default.useContext(a);var s=e.id,o=e.selectedTabID,r=t.useContext(i),l=function(t){var e=t.isSelected,n=t.api,i=t.id,s=n.optionsManager.options,a=n.optionsManager.setting,o={"tab-id":i,className:a.panelClass};return e&&(o.className+=" "+a.selectedClass),s.accessibility&&(o.role="tabpanel",o.id=a.panelIdTemplate(i),o["aria-hidden"]=!e,o["aria-labelledby"]=a.ariaLabelledbyIdTemplate(i)),o}({isSelected:s===o,api:r,id:s});return n.default.createElement("div",l,r.getTab(s).panelComponent)}),(function(t,e){var n=t.id,i=t.selectedTabID,s=e.selectedTabID;return i===s||n!==i&&n!==s})),p=t.memo((function(t){var e=n.default.useContext(s),a=e.openTabIDs,o=e.selectedTabID,r=n.default.useContext(i),l=r.optionsManager.setting,c=l.panellistClass+" "+l[r.getOption("direction")+"class"];return n.default.createElement("div",{className:c},a.map((function(t){return n.default.createElement(u,{key:t,id:t,selectedTabID:o})})))}),(function(){return!0})),d="open",f="close",h="active",b="refresh";function y(){return(y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}var g={};function v(t,e){switch(e.type){case f:var n=t.openTabIDs,i=n.indexOf(e.tabId);if(i>=0){var s=n.slice();return s.splice(i,1),{selectedTabID:t.selectedTabID,openTabIDs:s}}return t;case d:var a=t.openTabIDs,o=e.tabId;if(-1===a.indexOf(o)){var r=a.slice();return r.push(o),{selectedTabID:t.selectedTabID,openTabIDs:r}}return t;case b:return g.getCopyState(t);case h:var l=e.tabId;return t.selectedTabID!==l?{selectedTabID:l,openTabIDs:t.openTabIDs}:t;default:throw new Error("Undefined action type '"+e.type+"'")}}g.checkArrIndex=function(t,e){return t>=0&&t<e},g.getInstance=function(t){new(Function.prototype.bind.apply(t,arguments))},g.resolve=function(t){return Promise.resolve(t)},g.getCopyState=function(t){var e=y({},t);return e.hasOwnProperty("openTabIDs")&&(e.openTabIDs=[].concat(e.openTabIDs)),e},g.assingAll=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return n.map((function(e){var n=Object.keys(e);Object.getOwnPropertyNames(e).map((function(i){n.indexOf(i)>=0?t[i]=e[i]:Object.defineProperty(t,i,{value:e[i],writable:!0})}))})),t},g.setNoneEnumProps=function(t,e){var n={};return Object.keys(e).map((function(t){n[t]={writable:!0,value:e[t]}})),Object.defineProperties(t,n)},g.getArraysDiff=function(t,e){var n=[].concat(t),i=[].concat(e);return t.map((function(t){e.indexOf(t)>=0&&(n.splice(n.indexOf(t),1),i.splice(i.indexOf(t),1))})),[n,i]},g.arrFilterUntilFirstValue=function(t,e,n){n&&t.reverse();for(var i=0,s=t.length;i<s;i++)if(e(t[i],i,t))return t[i];return null},g.throwMissingParam=function(t){throw'Missing parameter in "'+t+'" function'},g.throwInvalidParam=function(t){throw'Invalid parameter error in "'+t+'" function'},g.isObj=function(t){return"[object Object]"===Object.prototype.toString.call(t)};var _,m,C,T,I=g.throwMissingParam,O=function(t,e){void 0===e&&(e={options:{}});var n=t.call(this,e.options),i=n.optionsManager,s=n.helper,a=n.activedTabsHistory;s.setNoneEnumProps(this,{optionsManager:i,helper:s,activedTabsHistory:a}),this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions()._subscribeOnChange()},P={_setUserProxy:function(){var t=this,e={},n=this;for(var i in this)"_"!==i[0]&&"constructor"!==i&&function(){var s=t[i];e[i]="function"==typeof s?function(){var t=s.apply(n,arguments);return t===n?e:t}:s}();return this.userProxy=e,this},_subscribeOnChange:function(){var t=this;return this.on("onChange",(function(e){var n=e.newState,i=e.oldState,s=e.closedTabsId,a=e.openedTabsId,o=e.isSwitched;a.length&&t.trigger("onOpen",t.userProxy,a),s.length&&t.trigger("onClose",t.userProxy,s),o&&t.trigger("onSelect",t.userProxy,{currentSelectedTabId:n.selectedTabID,perviousSelectedTabId:i.selectedTabID})})),this},_subscribeCallbacksOptions:function(){var t=this,e=this.optionsManager.options;return Object.keys(this._publishers).map((function(n){t.on(n,(function(){e[n].apply(this.userProxy,arguments)}))})),this},_subscribeSelectedTabsHistory:function(){var t=this;return this.on("onChange",(function(e){var n=e.isSwitched,i=e.oldState;n&&t.activedTabsHistory.add(i.selectedTabID)})),this},getOption:function(t){return this.optionsManager.getOption(t)},setOption:function(t,e){return this.optionsManager.setOption(t,e)},getCopyPerviousData:function(){return this.helper.getCopyState(this._perviousState)},getCopyData:function(){return this.helper.getCopyState(this._state)},isSelected:function(t){return void 0===t&&(t=I("isSelected")),this._state.selectedTabID==t},isOpen:function(t){return void 0===t&&(t=I("isOpen")),this._state.openTabIDs.indexOf(t)>=0},_getOnChangePromise:function(){var t=this;return new Promise((function(e){t.one("onChange",(function(){e.call(t.userProxy)}))}))},select:function(t){void 0===t&&(t=I("select"));var e=this._getOnChangePromise();return this._select(t),e},_findTabIdForSwitching:(_=function(t,e){var n=this;return this.helper.arrFilterUntilFirstValue(t,(function(t){return n.isOpen(t)&&!n.getTab(t).disable&&!n.isSelected(t)}),e)||""},m=function(){return _.call(this,[].concat(this.activedTabsHistory.tabsId),!0)},C=function(){var t=this._state,e=t.openTabIDs;return _.call(this,e.slice(0,e.indexOf(t.selectedTabID)),!0)},T=function(){var t=this._state,e=t.openTabIDs;return _.call(this,e.slice(e.indexOf(t.selectedTabID)+1))},function(){return m.call(this)||C.call(this)||T.call(this)}),open:function(t){void 0===t&&(t=I("open"));var e=this._getOnChangePromise();return this._open(t.id),this._addTab(t,{defaultPanelComponent:this.getOption("defaultPanelComponent")}),e},__close:function(t){var e=this._getOnChangePromise();return this._close(t),this._removeTab(t),e},close:function(t){if(void 0===t&&(t=I("close")),this.isSelected(t)){var e=[].concat(this._state.openTabIDs);return e.splice(e.indexOf(t),1),this.select(this._findTabIdForSwitching()),this.__close(t)}return this.__close(t)},refresh:function(){var t=this._getOnChangePromise();return this._refresh(),t}};g.setNoneEnumProps(P,{getInitialState:function(){var t=this;if(!this._initialState){var e=this.optionsManager.options,n=e.selectedTabID,i=e.tabs,s=e.defaultPanelComponent,a=[];i.map((function(e){t._addTab(e,{defaultPanelComponent:s}),a.push(e.id)})),this._initialState={selectedTabID:n,openTabIDs:a}}return this._initialState},eventHandlerFactory:function(t){var e=t.e,n=t.id,i=e.target,s=i.parentElement,a=this.optionsManager.setting,o=a.closeClass,r=a.tabClass;i.className.includes(o)&&s&&s.lastChild&&s.lastChild==i&&s.className.includes(r)?this.trigger("beforeClose",this.userProxy,e,n).includes(!1)||this.close(n):this.trigger("beforeSelect",this.userProxy,e,n).includes(!1)||this.select(n).then((function(t){})).catch((function(t){}))}});var D=P,S=g.throwMissingParam;function x(t,e){var n=e.options,i=t().globalDefaultOptions;this._defaultOptions=i,this._validateOptions(n),this.options=Object.assign({},this._defaultOptions,n),this._setSetting()}x.prototype.getOption=function(t){return this.options[t]},x.prototype.setOption=function(t,e){return void 0===t&&(t=S("setOption")),void 0===e&&(e=S("setOption")),"SELECTEDTABID"===t.toUpperCase()||this._defaultOptions.hasOwnProperty(t)&&(this.options[t]=e),this},x.prototype._validateOptions=function(t){if("[object Object]"!==Object.prototype.toString.call(t))throw'Invalid argument in "useDynamicTabs" function. Argument must be type of an object';return this},x.prototype._setSetting=function(){return this.setting={tabClass:"rc-dyn-tabs-tab",titleClass:"rc-dyn-tabs-title",iconClass:"rc-dyn-tabs-icon",selectedClass:"rc-dyn-tabs-selected",hoverClass:"rc-dyn-tabs-hover",tablistClass:"rc-dyn-tabs-tablist",closeClass:"rc-dyn-tabs-close",panelClass:"rc-dyn-tabs-panel",panellistClass:"rc-dyn-tabs-panellist",disableClass:"rc-dyn-tabs-disable",ltrClass:"rc-dyn-tabs-ltr",rtlClass:"rc-dyn-tabs-rtl",panelIdTemplate:function(t){return"rc-dyn-tabs-p-"+t},ariaLabelledbyIdTemplate:function(t){return"rc-dyn-tabs-l-"+t}},this};var w=function(t){return n.default.createElement("button",t.tabProps,t.children,t.hasOwnProperty("iconProps")&&n.default.createElement("span",t.iconProps))},E=function(t){void 0===t&&(t=null),this.defaultDirection="ltr",this._DefaulTabInnerComponent=t,this.directionsRange=["ltr","rtl"]};E.prototype.getOptions=function(){return this._getOptions()},E.prototype._getOptions=function(){var t={tabs:[],selectedTabID:"",beforeSelect:function(t,e){return!0},beforeClose:function(t,e){return!0},onOpen:function(t){},onClose:function(t){},onSelect:function(t){t.currentSelectedTabId,t.perviousSelectedTabId},onChange:function(t){t.currentData,t.perviousData},onLoad:function(t){},onDestroy:function(){},onInit:function(){},accessibility:!0,defaultPanelComponent:null},e=this.defaultDirection,n=this._DefaulTabInnerComponent,i=this;return Object.defineProperties(t,{direction:{get:function(){return e},set:function(t){if(-1===i.directionsRange.indexOf(t))throw'Invalid direction value! it can be eather of "ltr" or "rtl" ';e=t},enumerable:!0},tabComponent:{get:function(){return n},set:function(t){if(t&&"function"!=typeof t)throw"tabComponent property must be type of a function.";n=t||i._DefaulTabInnerComponent},enumerable:!0}}),t};var j=x.bind(null,(function(){return{globalDefaultOptions:new E(w).getOptions()}})),L=function(){this.tabsId=[]};L.prototype.getTab=function(){return this.tabsId.pop()},L.prototype.reset=function(){this.tabsId=[]},L.prototype.add=function(t){var e=this.tabsId;e[e.length-1]===t||e.push(t)};var M=function(){this._publishers={onChange:[],onLoad:[],onDestroy:[],onOpen:[],onClose:[],onSelect:[],beforeSelect:[],beforeClose:[],onInit:[],onFirstSelect:[]}};M.prototype.off=function(t,e){if("function"==typeof e&&this._publishers.hasOwnProperty(t)){var n=this._publishers[t].indexOf(e);n>=0&&this._publishers[t].splice(n,1)}return this},M.prototype.on=function(t,e){return"function"==typeof e&&this._publishers.hasOwnProperty(t)&&this._publishers[t].push(e),this},M.prototype.one=function(t,e){var n=this;if("function"==typeof e&&this._publishers.hasOwnProperty(t)){return this.on(t,(function i(s){e(s),n.off(t,i)}))}return this},g.setNoneEnumProps(M.prototype,{trigger:function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];e=e||null;var a=[],o=[].concat(this._publishers[t]);return o.map((function(t){a.push(t.apply(e,i))})),a}});var N=t.memo((function(t){return t.childComponent}),(function(){return!0}));function R(){this._data=[]}function F(t){this._helper=t,this._state={},this._initialState=null,this._perviousState={},this._dispatch=function(){},t.setNoneEnumProps(this,{forceUpdateState:{},stateRef:{}})}R.prototype._getDefaultTabData=function(t){return{title:"unnamed tab",tooltip:"",panelComponent:t,closable:!0,iconClass:"",disable:!1,id:"tab_"+(new Date).getTime()}},R.prototype._addTab=function(t,e){var n=e.defaultPanelComponent;return t=Object.assign(this._getDefaultTabData(n),t),this._data.push(t),this},R.prototype._removeTab=function(t){var e=this._data.findIndex((function(e){return e.id===t}));return e>=0&&this._data.splice(e,1),this},R.prototype.getTab=function(t){return this._data.find((function(e){return e.id===t}))},R.prototype.setTab=function(t,e,i){void 0===e&&(e={}),void 0===i&&(i=!0);var s=this._data.findIndex((function(e){return e.id===t}));if(s>=0){var a=this._data[s];e.id=a.id,i&&e.panelComponent!==a.panelComponent&&n.default.isValidElement(e.panelComponent)&&(e.panelComponent=n.default.createElement(N,null,"newData.panelComponent")),Object.assign(this._data[s],e)}return e},F.prototype._select=function(t){this._dispatch({type:h,tabId:t})},F.prototype._close=function(t){this._dispatch({type:f,tabId:t})},F.prototype._open=function(t){this._dispatch({type:d,tabId:t})},F.prototype._refresh=function(){this.forceUpdateState={},this._dispatch({type:b})},g.setNoneEnumProps(F.prototype,{updateReducer:function(t,e){this.stateRef=t,this._perviousState=this._helper.getCopyState(this._state),this._state=this._helper.getCopyState(t),this._perviousState=this._perviousState.hasOwnProperty("openTabIDs")?this._perviousState:this._helper.getCopyState(this._state),this._dispatch=e}});O.prototype=Object.create(F.prototype),g.assingAll(O.prototype,R.prototype,M.prototype,D).constructor=O;var k=O.bind(null,(function(t){void 0===t&&(t={});var e=new L,n=new j({options:t});return F.call(this,g),R.call(this),M.call(this),{activedTabsHistory:e,helper:g,optionsManager:n}}));return function(e){var o=t.useRef(null);null===o.current&&(o.current={api:new k({options:e}),TabListComponent:null,PanelListComponent:null});var r=o.current.api,l=o.current,u=t.useReducer(v,r.getInitialState()),d=u[0],f=u[1];return r.updateReducer(d,f),t.useLayoutEffect((function(){return r.trigger("onLoad",r.userProxy),function(){r.trigger("onDestroy",r.userProxy)}}),[]),t.useLayoutEffect((function(){r.trigger("onInit",r.userProxy)})),t.useLayoutEffect((function(){var t=r.getCopyPerviousData(),e=r.helper.getArraysDiff(d.openTabIDs,t.openTabIDs),n=e[0],i=e[1],s=t.selectedTabID!==d.selectedTabID;r.trigger("onChange",r.userProxy,{newState:d,oldState:t,closedTabsId:i,openedTabsId:n,isSwitched:s})}),[d]),l.TabListComponent||(l.TabListComponent=function(t){return void 0===t&&(t={}),n.default.createElement(i.Provider,{value:r},n.default.createElement(s.Provider,{value:r.stateRef},n.default.createElement(a.Provider,{value:r.forceUpdateState},n.default.createElement(c,t,"props.children"))))}),l.PanelListCompoent||(l.PanelListCompoent=function(t){return n.default.createElement(i.Provider,{value:r},n.default.createElement(s.Provider,{value:r.stateRef},n.default.createElement(a.Provider,{value:d},n.default.createElement(p,t,"props.children"))))}),[l.TabListComponent,l.PanelListCompoent,r.userProxy]}})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).useDynTabs=e(t.React)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t),i=t.createContext({}),s=t.createContext({}),a=t.createContext({}),o=function(t){var e=t.api,n=t.id,i=t.isSelected;this._api=e,this._id=n,this._isSelected=i,this._op=e.optionsManager.options,this._setting=e.optionsManager.setting,this._tabObj=e.getTab(n)};function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}o.prototype.getTabProps=function(){var t={"tab-id":this._id,className:this._setting.tabClass,tabIndex:-1};return this._isSelected&&(t.tabIndex=0,t.className+=" "+this._setting.selectedClass),this._tabObj.disable&&(t.tabIndex=-1,t.className+=" "+this._setting.disableClass),this._op.accessibility&&(t.role="tab",t["aria-controls"]=this._setting.panelIdTemplate(this._id),t["aria-labelledby"]=this._setting.ariaLabelledbyIdTemplate(this._id),t["aria-selected"]=t["aria-expanded"]=this._isSelected),t},o.prototype.getTabInnerProps=function(){var t={id:this._id,isSelected:this._isSelected,api:this._api.userProxy,tabProps:{"tab-id":this._id,className:this._setting.titleClass,title:this._tabObj.tooltip,tabIndex:-1}};return this._tabObj.iconClass&&(t.iconProps={className:this._setting.iconClass+" "+this._tabObj.iconClass,role:"presentation"}),this._op.accessibility&&(t.tabProps.id=this._setting.ariaLabelledbyIdTemplate(this._id),t.tabProps.role="presentation"),t},o.prototype.getCloseIconProps=function(){var t={className:this._setting.closeClass};return this._op.accessibility&&(t.role="presentation"),t};var l=t.memo((function(t){n.default.useContext(a);var e=t.id,s=t.selectedTabID,l=n.default.useContext(i),c=l.getOption("tabComponent"),u=l.getTab(e),p=new o({api:l,id:e,isSelected:s===e});return n.default.createElement("li",r({},p.getTabProps(),{onClick:function(t){!function(t){l.eventHandlerFactory({e:t,id:e})}(t)}}),n.default.createElement(c,p.getTabInnerProps(),u.title),u.closable?n.default.createElement("span",p.getCloseIconProps(),"×"):null)}),(function(t,e){var n=t.id,i=t.selectedTabID,s=e.selectedTabID;return i===s||n!==i&&n!==s}));var c=t.memo((function(t){var e=n.default.useContext(s),a=e.openTabIDs,o=e.selectedTabID,r=function(t){var e=t.api,n=e.optionsManager.setting,i=e.optionsManager.options,s={className:n.tablistClass+" "+n[i.direction+"Class"]};return i.accessibility&&(s.role="tablist"),s}({api:n.default.useContext(i)});return n.default.createElement("ul",r,a.map((function(t){return n.default.createElement(l,{key:t,id:t,selectedTabID:o})})))}),(function(){return!0}));var u=t.memo((function(e){n.default.useContext(a);var s=e.id,o=e.selectedTabID,r=t.useContext(i),l=function(t){var e=t.isSelected,n=t.api,i=t.id,s=n.optionsManager.options,a=n.optionsManager.setting,o={"tab-id":i,className:a.panelClass};return e&&(o.className+=" "+a.selectedClass),s.accessibility&&(o.role="tabpanel",o.id=a.panelIdTemplate(i),o["aria-hidden"]=!e,o["aria-labelledby"]=a.ariaLabelledbyIdTemplate(i)),o}({isSelected:s===o,api:r,id:s});return n.default.createElement("div",l,r.getTab(s).panelComponent)}),(function(t,e){var n=t.id,i=t.selectedTabID,s=e.selectedTabID;return i===s||n!==i&&n!==s})),p=t.memo((function(t){var e=n.default.useContext(s),a=e.openTabIDs,o=e.selectedTabID,r=n.default.useContext(i),l=r.optionsManager.setting,c=l.panellistClass+" "+l[r.getOption("direction")+"class"];return n.default.createElement("div",{className:c},a.map((function(t){return n.default.createElement(u,{key:t,id:t,selectedTabID:o})})))}),(function(){return!0})),d="open",f="close",h="active",b="refresh";function y(){return(y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}var g={};function v(t,e){switch(e.type){case f:var n=t.openTabIDs,i=n.indexOf(e.tabId);if(i>=0){var s=n.slice();return s.splice(i,1),{selectedTabID:t.selectedTabID,openTabIDs:s}}return t;case d:var a=t.openTabIDs,o=e.tabId;if(-1===a.indexOf(o)){var r=a.slice();return r.push(o),{selectedTabID:t.selectedTabID,openTabIDs:r}}return t;case b:return g.getCopyState(t);case h:var l=e.tabId;return t.selectedTabID!==l?{selectedTabID:l,openTabIDs:t.openTabIDs}:t;default:throw new Error("Undefined action type '"+e.type+"'")}}function _(){return(_=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}g.checkArrIndex=function(t,e){return t>=0&&t<e},g.getInstance=function(t){new(Function.prototype.bind.apply(t,arguments))},g.resolve=function(t){return Promise.resolve(t)},g.getCopyState=function(t){var e=y({},t);return e.hasOwnProperty("openTabIDs")&&(e.openTabIDs=[].concat(e.openTabIDs)),e},g.assingAll=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return n.map((function(e){var n=Object.keys(e);Object.getOwnPropertyNames(e).map((function(i){n.indexOf(i)>=0?t[i]=e[i]:Object.defineProperty(t,i,{value:e[i],writable:!0})}))})),t},g.setNoneEnumProps=function(t,e){var n={};return Object.keys(e).map((function(t){n[t]={writable:!0,value:e[t]}})),Object.defineProperties(t,n)},g.getArraysDiff=function(t,e){var n=[].concat(t),i=[].concat(e);return t.map((function(t){e.indexOf(t)>=0&&(n.splice(n.indexOf(t),1),i.splice(i.indexOf(t),1))})),[n,i]},g.arrFilterUntilFirstValue=function(t,e,n){n&&t.reverse();for(var i=0,s=t.length;i<s;i++)if(e(t[i],i,t))return t[i];return null},g.throwMissingParam=function(t){throw'Missing parameter in "'+t+'" function'},g.throwInvalidParam=function(t){throw'Invalid parameter error in "'+t+'" function'},g.isObj=function(t){return"[object Object]"===Object.prototype.toString.call(t)};var m,C,T,I,O=g.throwMissingParam,P=function(t,e){void 0===e&&(e={options:{}});var n=t.call(this,e.options),i=n.optionsManager,s=n.helper,a=n.activedTabsHistory;s.setNoneEnumProps(this,{optionsManager:i,helper:s,activedTabsHistory:a}),this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions()},D={_setUserProxy:function(){var t=this,e={},n=this;for(var i in this)"_"!==i[0]&&"constructor"!==i&&function(){var s=t[i];e[i]="function"==typeof s?function(){var t=s.apply(n,arguments);return t===n?e:t}:s}();return this.userProxy=e,this},_subscribeCallbacksOptions:function(){var t=this,e=this.optionsManager.options;return Object.keys(this._publishers).map((function(n){t.on(n,(function(){e[n].apply(this,arguments)}))})),this},_subscribeSelectedTabsHistory:function(){var t=this;return this.on("onChange",(function(e){var n=e.isSwitched,i=e.oldState;n&&t.activedTabsHistory.add(i.selectedTabID)})),this},getOption:function(t){return this.optionsManager.getOption(t)},setOption:function(t,e){return this.optionsManager.setOption(t,e)},getCopyPerviousData:function(){return this.helper.getCopyState(this._perviousState)},getCopyData:function(){return this.helper.getCopyState(this._state)},isSelected:function(t){return void 0===t&&(t=O("isSelected")),this._state.selectedTabID==t},isOpen:function(t){return void 0===t&&(t=O("isOpen")),this._state.openTabIDs.indexOf(t)>=0},_getOnChangePromise:function(){var t=this;return new Promise((function(e){t.one("onChange",(function(){e.call(t.userProxy)}))}))},select:function(t){void 0===t&&(t=O("select"));var e=this._getOnChangePromise();return this._select(t),e},_findTabIdForSwitching:(m=function(t,e){var n=this;return this.helper.arrFilterUntilFirstValue(t,(function(t){return n.isOpen(t)&&!n.getTab(t).disable&&!n.isSelected(t)}),e)||""},C=function(){return m.call(this,[].concat(this.activedTabsHistory.tabsId),!0)},T=function(){var t=this._state,e=t.openTabIDs;return m.call(this,e.slice(0,e.indexOf(t.selectedTabID)),!0)},I=function(){var t=this._state,e=t.openTabIDs;return m.call(this,e.slice(e.indexOf(t.selectedTabID)+1))},function(){return C.call(this)||T.call(this)||I.call(this)}),open:function(t){void 0===t&&(t=O("open"));var e=this._getOnChangePromise();return this._open(t.id),this._addTab(t,{defaultPanelComponent:this.getOption("defaultPanelComponent")}),e},__close:function(t){var e=this._getOnChangePromise();return this._close(t),this._removeTab(t),e},close:function(t){if(void 0===t&&(t=O("close")),this.isSelected(t)){var e=[].concat(this._state.openTabIDs);return e.splice(e.indexOf(t),1),this.select(this._findTabIdForSwitching()),this.__close(t)}return this.__close(t)},refresh:function(){var t=this._getOnChangePromise();return this._refresh(),t}};g.setNoneEnumProps(D,{getInitialState:function(){var t=this;if(!this._initialState){var e=this.optionsManager.options,n=e.selectedTabID,i=e.tabs,s=e.defaultPanelComponent,a=[];i.map((function(e){t._addTab(e,{defaultPanelComponent:s}),a.push(e.id)})),this._initialState={selectedTabID:n,openTabIDs:a}}return this._initialState},onChange:function(t){var e=t.newState,n=t.oldState,i=t.closedTabsId,s=t.openedTabsId,a=t.isSwitched;return(a||s.length||i.length)&&(this.trigger("onChange",this.userProxy,{currentData:_({},e),perviousData:_({},n)}),s.length&&this.trigger("onOpen",this.userProxy,s),i.length&&this.trigger("onClose",this.userProxy,i),a&&this.trigger("onSelect",this.userProxy,{currentSelectedTabId:e.selectedTabID,perviousSelectedTabId:n.selectedTabID})),this},eventHandlerFactory:function(t){var e=t.e,n=t.id,i=e.target,s=i.parentElement,a=this.optionsManager.setting,o=a.closeClass,r=a.tabClass;i.className.includes(o)&&s&&s.lastChild&&s.lastChild==i&&s.className.includes(r)?!1!==this.getOption("beforeClose").call(this.userProxy,e,n)&&this.close(n):!1!==this.getOption("beforeSelect").call(this.userProxy,e,n)&&this.select(n)}});var S=D,x=g.throwMissingParam;function w(t,e){var n=e.options,i=t().globalDefaultOptions;this._defaultOptions=i,this._validateOptions(n),this.options=Object.assign({},this._defaultOptions,n),this._setSetting()}w.prototype.getOption=function(t){return this.options[t]},w.prototype.setOption=function(t,e){return void 0===t&&(t=x("setOption")),void 0===e&&(e=x("setOption")),"SELECTEDTABID"===t.toUpperCase()||this._defaultOptions.hasOwnProperty(t)&&(this.options[t]=e),this},w.prototype._validateOptions=function(t){if("[object Object]"!==Object.prototype.toString.call(t))throw'Invalid argument in "useDynamicTabs" function. Argument must be type of an object';return this},w.prototype._setSetting=function(){return this.setting={tabClass:"rc-dyn-tabs-tab",titleClass:"rc-dyn-tabs-title",iconClass:"rc-dyn-tabs-icon",selectedClass:"rc-dyn-tabs-selected",hoverClass:"rc-dyn-tabs-hover",tablistClass:"rc-dyn-tabs-tablist",closeClass:"rc-dyn-tabs-close",panelClass:"rc-dyn-tabs-panel",panellistClass:"rc-dyn-tabs-panellist",disableClass:"rc-dyn-tabs-disable",ltrClass:"rc-dyn-tabs-ltr",rtlClass:"rc-dyn-tabs-rtl",panelIdTemplate:function(t){return"rc-dyn-tabs-p-"+t},ariaLabelledbyIdTemplate:function(t){return"rc-dyn-tabs-l-"+t}},this};var E=function(t){return n.default.createElement("button",t.tabProps,t.children,t.hasOwnProperty("iconProps")&&n.default.createElement("span",t.iconProps))},j=function(t){void 0===t&&(t=null),this.defaultDirection="ltr",this._DefaulTabInnerComponent=t,this.directionsRange=["ltr","rtl"]};j.prototype.getOptions=function(){return this._getOptions()},j.prototype._getOptions=function(){var t={tabs:[],selectedTabID:"",beforeSelect:function(t,e){return!0},beforeClose:function(t,e){return!0},onOpen:function(t){},onClose:function(t){},onSelect:function(t){t.currentSelectedTabId,t.perviousSelectedTabId},onChange:function(t){t.currentData,t.perviousData},onLoad:function(t){},onDestroy:function(){},onInit:function(){},accessibility:!0,defaultPanelComponent:null},e=this.defaultDirection,n=this._DefaulTabInnerComponent,i=this;return Object.defineProperties(t,{direction:{get:function(){return e},set:function(t){if(-1===i.directionsRange.indexOf(t))throw'Invalid direction value! it can be eather of "ltr" or "rtl" ';e=t},enumerable:!0},tabComponent:{get:function(){return n},set:function(t){if(t&&"function"!=typeof t)throw"tabComponent property must be type of a function.";n=t||i._DefaulTabInnerComponent},enumerable:!0}}),t};var L=w.bind(null,(function(){return{globalDefaultOptions:new j(E).getOptions()}})),M=function(){this.tabsId=[]};M.prototype.getTab=function(){return this.tabsId.pop()},M.prototype.reset=function(){this.tabsId=[]},M.prototype.add=function(t){var e=this.tabsId;e[e.length-1]===t||e.push(t)};var N=function(){this._publishers={onChange:[],onLoad:[],onDestroy:[],onOpen:[],onClose:[],onSelect:[],onInit:[],onFirstSelect:[]}};N.prototype.off=function(t,e){if("function"==typeof e&&this._publishers.hasOwnProperty(t)){var n=this._publishers[t].indexOf(e);n>=0&&this._publishers[t].splice(n,1)}return this},N.prototype.on=function(t,e){return"function"==typeof e&&this._publishers.hasOwnProperty(t)&&this._publishers[t].push(e),this},N.prototype.one=function(t,e){var n=this;if("function"==typeof e&&this._publishers.hasOwnProperty(t)){return this.on(t,(function i(s){e(s),n.off(t,i)}))}return this},g.setNoneEnumProps(N.prototype,{trigger:function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];e=e||null;var a=[],o=[].concat(this._publishers[t]);return o.map((function(t){a.push(t.apply(e,i))})),a}});var R=t.memo((function(t){return t.childComponent}),(function(){return!0}));function F(){this._data=[]}function k(t){this._helper=t,this._state={},this._initialState=null,this._perviousState={},this._dispatch=function(){},t.setNoneEnumProps(this,{forceUpdateState:{},stateRef:{}})}F.prototype._getDefaultTabData=function(t){return{title:"",tooltip:"",panelComponent:t,closable:!0,iconClass:"",disable:!1,id:"tab_"+(new Date).getTime()}},F.prototype._addTab=function(t,e){var n=e.defaultPanelComponent;return t=Object.assign(this._getDefaultTabData(n),t),this._data.push(t),this},F.prototype._removeTab=function(t){var e=this._data.findIndex((function(e){return e.id===t}));return e>=0&&this._data.splice(e,1),this},F.prototype.getTab=function(t){return this._data.find((function(e){return e.id===t}))},F.prototype.setTab=function(t,e,i){void 0===e&&(e={}),void 0===i&&(i=!0);var s=this._data.findIndex((function(e){return e.id===t}));if(s>=0){var a=this._data[s];e.id=a.id,i&&e.panelComponent!==a.panelComponent&&n.default.isValidElement(e.panelComponent)&&(e.panelComponent=n.default.createElement(R,null,"newData.panelComponent")),Object.assign(this._data[s],e)}return e},k.prototype._select=function(t){this._dispatch({type:h,tabId:t})},k.prototype._close=function(t){this._dispatch({type:f,tabId:t})},k.prototype._open=function(t){this._dispatch({type:d,tabId:t})},k.prototype._refresh=function(){this.forceUpdateState={},this._dispatch({type:b})},g.setNoneEnumProps(k.prototype,{updateReducer:function(t,e){this.stateRef=t,this._perviousState=this._helper.getCopyState(this._state),this._state=this._helper.getCopyState(t),this._perviousState=this._perviousState.hasOwnProperty("openTabIDs")?this._perviousState:this._helper.getCopyState(this._state),this._dispatch=e}});P.prototype=Object.create(k.prototype),g.assingAll(P.prototype,F.prototype,N.prototype,S).constructor=P;var A=P.bind(null,(function(t){void 0===t&&(t={});var e=new M,n=new L({options:t});return k.call(this,g),F.call(this),N.call(this),{activedTabsHistory:e,helper:g,optionsManager:n}}));return function(e){var o=t.useRef(null);null===o.current&&(o.current={api:new A({options:e}),TabListComponent:null,PanelListComponent:null});var r=o.current.api,l=o.current,u=t.useReducer(v,r.getInitialState()),d=u[0],f=u[1];return r.updateReducer(d,f),t.useLayoutEffect((function(){return r.trigger("onLoad",r.userProxy),function(){r.trigger("onDestroy",r.userProxy)}}),[]),t.useLayoutEffect((function(){r.trigger("onInit",r.userProxy)})),t.useLayoutEffect((function(){var t=r.getCopyPerviousData(),e=r.helper.getArraysDiff(d.openTabIDs,t.openTabIDs),n=e[0],i=e[1],s=t.selectedTabID!==d.selectedTabID;r.onChange({newState:d,oldState:t,closedTabsId:i,openedTabsId:n,isSwitched:s})}),[d]),l.TabListComponent||(l.TabListComponent=function(t){return void 0===t&&(t={}),n.default.createElement(i.Provider,{value:r},n.default.createElement(s.Provider,{value:r.stateRef},n.default.createElement(a.Provider,{value:r.forceUpdateState},n.default.createElement(c,t,"props.children"))))}),l.PanelListCompoent||(l.PanelListCompoent=function(t){return n.default.createElement(i.Provider,{value:r},n.default.createElement(s.Provider,{value:r.stateRef},n.default.createElement(a.Provider,{value:d},n.default.createElement(p,t,"props.children"))))}),[l.TabListComponent,l.PanelListCompoent,r.userProxy]}})); | ||
//# sourceMappingURL=react-dyn-tabs.umd.min.js.map |
@@ -55,2 +55,3 @@ "use strict"; | ||
className: this._setting.titleClass, | ||
title: this._tabObj.tooltip, | ||
tabIndex: -1 | ||
@@ -57,0 +58,0 @@ } |
@@ -57,3 +57,3 @@ "use strict"; | ||
api.trigger('onChange', api.userProxy, { | ||
api.onChange({ | ||
newState: state, | ||
@@ -60,0 +60,0 @@ oldState: oldState, |
@@ -10,2 +10,4 @@ "use strict"; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
var missingParamEr = _helper["default"].throwMissingParam, | ||
@@ -32,3 +34,4 @@ invalidParamEr = _helper["default"].throwInvalidParam; | ||
this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions()._subscribeOnChange(); | ||
this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions(); //._subscribeOnChange(); | ||
}; | ||
@@ -64,27 +67,9 @@ | ||
}, | ||
_subscribeOnChange: function _subscribeOnChange() { | ||
_subscribeCallbacksOptions: function _subscribeCallbacksOptions() { | ||
var _this2 = this; | ||
this.on('onChange', function (_ref) { | ||
var newState = _ref.newState, | ||
oldState = _ref.oldState, | ||
closedTabsId = _ref.closedTabsId, | ||
openedTabsId = _ref.openedTabsId, | ||
isSwitched = _ref.isSwitched; | ||
openedTabsId.length && _this2.trigger('onOpen', _this2.userProxy, openedTabsId); | ||
closedTabsId.length && _this2.trigger('onClose', _this2.userProxy, closedTabsId); | ||
isSwitched && _this2.trigger('onSelect', _this2.userProxy, { | ||
currentSelectedTabId: newState.selectedTabID, | ||
perviousSelectedTabId: oldState.selectedTabID | ||
}); | ||
}); | ||
return this; | ||
}, | ||
_subscribeCallbacksOptions: function _subscribeCallbacksOptions() { | ||
var _this3 = this; | ||
var op = this.optionsManager.options; | ||
Object.keys(this._publishers).map(function (eventName) { | ||
_this3.on(eventName, function () { | ||
op[eventName].apply(this.userProxy, arguments); | ||
_this2.on(eventName, function () { | ||
op[eventName].apply(this, arguments); | ||
}); | ||
@@ -95,8 +80,8 @@ }); | ||
_subscribeSelectedTabsHistory: function _subscribeSelectedTabsHistory() { | ||
var _this4 = this; | ||
var _this3 = this; | ||
this.on('onChange', function (_ref2) { | ||
var isSwitched = _ref2.isSwitched, | ||
oldState = _ref2.oldState; | ||
isSwitched && _this4.activedTabsHistory.add(oldState.selectedTabID); | ||
this.on('onChange', function (_ref) { | ||
var isSwitched = _ref.isSwitched, | ||
oldState = _ref.oldState; | ||
isSwitched && _this3.activedTabsHistory.add(oldState.selectedTabID); | ||
}); | ||
@@ -132,7 +117,7 @@ return this; | ||
_getOnChangePromise: function _getOnChangePromise() { | ||
var _this5 = this; | ||
var _this4 = this; | ||
return new Promise(function (resolve) { | ||
_this5.one('onChange', function () { | ||
resolve.call(_this5.userProxy); | ||
_this4.one('onChange', function () { | ||
resolve.call(_this4.userProxy); | ||
}); | ||
@@ -154,6 +139,6 @@ }); | ||
var _findOpenedAndNoneDisableTabId = function _findOpenedAndNoneDisableTabId(tabsIdArr, isRightToLeft) { | ||
var _this6 = this; | ||
var _this5 = this; | ||
return this.helper.arrFilterUntilFirstValue(tabsIdArr, function (id) { | ||
return _this6.isOpen(id) && !_this6.getTab(id).disable && !_this6.isSelected(id); | ||
return _this5.isOpen(id) && !_this5.getTab(id).disable && !_this5.isSelected(id); | ||
}, isRightToLeft) || ''; | ||
@@ -232,3 +217,3 @@ }, | ||
getInitialState: function getInitialState() { | ||
var _this7 = this; | ||
var _this6 = this; | ||
@@ -242,3 +227,3 @@ if (!this._initialState) { | ||
tabs.map(function (tab) { | ||
_this7._addTab(tab, { | ||
_this6._addTab(tab, { | ||
defaultPanelComponent: defaultPanelComponent | ||
@@ -257,2 +242,24 @@ }); | ||
}, | ||
onChange: function onChange(_ref2) { | ||
var newState = _ref2.newState, | ||
oldState = _ref2.oldState, | ||
closedTabsId = _ref2.closedTabsId, | ||
openedTabsId = _ref2.openedTabsId, | ||
isSwitched = _ref2.isSwitched; | ||
if (isSwitched || openedTabsId.length || closedTabsId.length) { | ||
this.trigger('onChange', this.userProxy, { | ||
currentData: _extends({}, newState), | ||
perviousData: _extends({}, oldState) | ||
}); | ||
openedTabsId.length && this.trigger('onOpen', this.userProxy, openedTabsId); | ||
closedTabsId.length && this.trigger('onClose', this.userProxy, closedTabsId); | ||
isSwitched && this.trigger('onSelect', this.userProxy, { | ||
currentSelectedTabId: newState.selectedTabID, | ||
perviousSelectedTabId: oldState.selectedTabID | ||
}); | ||
} | ||
return this; | ||
}, | ||
eventHandlerFactory: function eventHandlerFactory(_ref3) { | ||
@@ -268,9 +275,5 @@ var e = _ref3.e, | ||
if (el.className.includes(closeClass) && parentEl && parentEl.lastChild && parentEl.lastChild == el && parentEl.className.includes(tabClass)) { | ||
// if just on of the beforeClose subscribers return false then it will prevent tab from close | ||
this.trigger('beforeClose', this.userProxy, e, id).includes(false) || this.close(id); | ||
this.getOption('beforeClose').call(this.userProxy, e, id) !== false && this.close(id); | ||
} else { | ||
// if just on of the beforeSelect subscribers return false then it will prevent tab from select | ||
if (!this.trigger('beforeSelect', this.userProxy, e, id).includes(false)) { | ||
this.select(id).then(function (result) {})["catch"](function (er) {}); | ||
} | ||
this.getOption('beforeSelect').call(this.userProxy, e, id) !== false && this.select(id); | ||
} | ||
@@ -277,0 +280,0 @@ } |
@@ -18,4 +18,2 @@ "use strict"; | ||
onSelect: [], | ||
beforeSelect: [], | ||
beforeClose: [], | ||
onInit: [], | ||
@@ -22,0 +20,0 @@ onFirstSelect: [] |
@@ -18,3 +18,3 @@ "use strict"; | ||
return { | ||
title: "unnamed tab", | ||
title: "", | ||
tooltip: "", | ||
@@ -21,0 +21,0 @@ panelComponent: defaultPanelComponent, |
@@ -50,2 +50,3 @@ var TabPropsManager = function TabPropsManager(_ref) { | ||
className: this._setting.titleClass, | ||
title: this._tabObj.tooltip, | ||
tabIndex: -1 | ||
@@ -52,0 +53,0 @@ } |
@@ -41,3 +41,3 @@ import React, { useReducer, useLayoutEffect, useRef } from "react"; | ||
api.trigger('onChange', api.userProxy, { | ||
api.onChange({ | ||
newState: state, | ||
@@ -44,0 +44,0 @@ oldState: oldState, |
@@ -0,1 +1,2 @@ | ||
import _extends from "@babel/runtime-corejs3/helpers/extends"; | ||
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map"; | ||
@@ -30,3 +31,4 @@ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys"; | ||
this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions()._subscribeOnChange(); | ||
this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions(); //._subscribeOnChange(); | ||
}; | ||
@@ -60,23 +62,5 @@ var _apiProps = { | ||
}, | ||
_subscribeOnChange: function _subscribeOnChange() { | ||
var _this2 = this; | ||
this.on('onChange', function (_ref) { | ||
var newState = _ref.newState, | ||
oldState = _ref.oldState, | ||
closedTabsId = _ref.closedTabsId, | ||
openedTabsId = _ref.openedTabsId, | ||
isSwitched = _ref.isSwitched; | ||
openedTabsId.length && _this2.trigger('onOpen', _this2.userProxy, openedTabsId); | ||
closedTabsId.length && _this2.trigger('onClose', _this2.userProxy, closedTabsId); | ||
isSwitched && _this2.trigger('onSelect', _this2.userProxy, { | ||
currentSelectedTabId: newState.selectedTabID, | ||
perviousSelectedTabId: oldState.selectedTabID | ||
}); | ||
}); | ||
return this; | ||
}, | ||
_subscribeCallbacksOptions: function _subscribeCallbacksOptions() { | ||
var _context, | ||
_this3 = this; | ||
_this2 = this; | ||
@@ -86,4 +70,4 @@ var op = this.optionsManager.options; | ||
_mapInstanceProperty(_context = _Object$keys(this._publishers)).call(_context, function (eventName) { | ||
_this3.on(eventName, function () { | ||
op[eventName].apply(this.userProxy, arguments); | ||
_this2.on(eventName, function () { | ||
op[eventName].apply(this, arguments); | ||
}); | ||
@@ -95,8 +79,8 @@ }); | ||
_subscribeSelectedTabsHistory: function _subscribeSelectedTabsHistory() { | ||
var _this4 = this; | ||
var _this3 = this; | ||
this.on('onChange', function (_ref2) { | ||
var isSwitched = _ref2.isSwitched, | ||
oldState = _ref2.oldState; | ||
isSwitched && _this4.activedTabsHistory.add(oldState.selectedTabID); | ||
this.on('onChange', function (_ref) { | ||
var isSwitched = _ref.isSwitched, | ||
oldState = _ref.oldState; | ||
isSwitched && _this3.activedTabsHistory.add(oldState.selectedTabID); | ||
}); | ||
@@ -134,7 +118,7 @@ return this; | ||
_getOnChangePromise: function _getOnChangePromise() { | ||
var _this5 = this; | ||
var _this4 = this; | ||
return new _Promise(function (resolve) { | ||
_this5.one('onChange', function () { | ||
resolve.call(_this5.userProxy); | ||
_this4.one('onChange', function () { | ||
resolve.call(_this4.userProxy); | ||
}); | ||
@@ -156,6 +140,6 @@ }); | ||
var _findOpenedAndNoneDisableTabId = function _findOpenedAndNoneDisableTabId(tabsIdArr, isRightToLeft) { | ||
var _this6 = this; | ||
var _this5 = this; | ||
return this.helper.arrFilterUntilFirstValue(tabsIdArr, function (id) { | ||
return _this6.isOpen(id) && !_this6.getTab(id).disable && !_this6.isSelected(id); | ||
return _this5.isOpen(id) && !_this5.getTab(id).disable && !_this5.isSelected(id); | ||
}, isRightToLeft) || ''; | ||
@@ -237,3 +221,3 @@ }, | ||
getInitialState: function getInitialState() { | ||
var _this7 = this; | ||
var _this6 = this; | ||
@@ -248,3 +232,3 @@ if (!this._initialState) { | ||
_mapInstanceProperty(tabs).call(tabs, function (tab) { | ||
_this7._addTab(tab, { | ||
_this6._addTab(tab, { | ||
defaultPanelComponent: defaultPanelComponent | ||
@@ -264,2 +248,24 @@ }); | ||
}, | ||
onChange: function onChange(_ref2) { | ||
var newState = _ref2.newState, | ||
oldState = _ref2.oldState, | ||
closedTabsId = _ref2.closedTabsId, | ||
openedTabsId = _ref2.openedTabsId, | ||
isSwitched = _ref2.isSwitched; | ||
if (isSwitched || openedTabsId.length || closedTabsId.length) { | ||
this.trigger('onChange', this.userProxy, { | ||
currentData: _extends({}, newState), | ||
perviousData: _extends({}, oldState) | ||
}); | ||
openedTabsId.length && this.trigger('onOpen', this.userProxy, openedTabsId); | ||
closedTabsId.length && this.trigger('onClose', this.userProxy, closedTabsId); | ||
isSwitched && this.trigger('onSelect', this.userProxy, { | ||
currentSelectedTabId: newState.selectedTabID, | ||
perviousSelectedTabId: oldState.selectedTabID | ||
}); | ||
} | ||
return this; | ||
}, | ||
eventHandlerFactory: function eventHandlerFactory(_ref3) { | ||
@@ -277,13 +283,5 @@ var _context5, _context6; | ||
if (_includesInstanceProperty(_context5 = el.className).call(_context5, closeClass) && parentEl && parentEl.lastChild && parentEl.lastChild == el && _includesInstanceProperty(_context6 = parentEl.className).call(_context6, tabClass)) { | ||
var _context7; | ||
// if just on of the beforeClose subscribers return false then it will prevent tab from close | ||
_includesInstanceProperty(_context7 = this.trigger('beforeClose', this.userProxy, e, id)).call(_context7, false) || this.close(id); | ||
this.getOption('beforeClose').call(this.userProxy, e, id) !== false && this.close(id); | ||
} else { | ||
var _context8; | ||
// if just on of the beforeSelect subscribers return false then it will prevent tab from select | ||
if (!_includesInstanceProperty(_context8 = this.trigger('beforeSelect', this.userProxy, e, id)).call(_context8, false)) { | ||
this.select(id).then(function (result) {})["catch"](function (er) {}); | ||
} | ||
this.getOption('beforeSelect').call(this.userProxy, e, id) !== false && this.select(id); | ||
} | ||
@@ -290,0 +288,0 @@ } |
@@ -15,4 +15,2 @@ import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of"; | ||
onSelect: [], | ||
beforeSelect: [], | ||
beforeClose: [], | ||
onInit: [], | ||
@@ -19,0 +17,0 @@ onFirstSelect: [] |
@@ -14,3 +14,3 @@ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign"; | ||
return { | ||
title: "unnamed tab", | ||
title: "", | ||
tooltip: "", | ||
@@ -17,0 +17,0 @@ panelComponent: defaultPanelComponent, |
@@ -50,2 +50,3 @@ var TabPropsManager = function TabPropsManager(_ref) { | ||
className: this._setting.titleClass, | ||
title: this._tabObj.tooltip, | ||
tabIndex: -1 | ||
@@ -52,0 +53,0 @@ } |
@@ -41,3 +41,3 @@ import React, { useReducer, useLayoutEffect, useRef } from "react"; | ||
api.trigger('onChange', api.userProxy, { | ||
api.onChange({ | ||
newState: state, | ||
@@ -44,0 +44,0 @@ oldState: oldState, |
@@ -0,1 +1,3 @@ | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
import Helper from '../helper.js'; | ||
@@ -22,3 +24,4 @@ var missingParamEr = Helper.throwMissingParam, | ||
this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions()._subscribeOnChange(); | ||
this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions(); //._subscribeOnChange(); | ||
}; | ||
@@ -52,27 +55,9 @@ var _apiProps = { | ||
}, | ||
_subscribeOnChange: function _subscribeOnChange() { | ||
_subscribeCallbacksOptions: function _subscribeCallbacksOptions() { | ||
var _this2 = this; | ||
this.on('onChange', function (_ref) { | ||
var newState = _ref.newState, | ||
oldState = _ref.oldState, | ||
closedTabsId = _ref.closedTabsId, | ||
openedTabsId = _ref.openedTabsId, | ||
isSwitched = _ref.isSwitched; | ||
openedTabsId.length && _this2.trigger('onOpen', _this2.userProxy, openedTabsId); | ||
closedTabsId.length && _this2.trigger('onClose', _this2.userProxy, closedTabsId); | ||
isSwitched && _this2.trigger('onSelect', _this2.userProxy, { | ||
currentSelectedTabId: newState.selectedTabID, | ||
perviousSelectedTabId: oldState.selectedTabID | ||
}); | ||
}); | ||
return this; | ||
}, | ||
_subscribeCallbacksOptions: function _subscribeCallbacksOptions() { | ||
var _this3 = this; | ||
var op = this.optionsManager.options; | ||
Object.keys(this._publishers).map(function (eventName) { | ||
_this3.on(eventName, function () { | ||
op[eventName].apply(this.userProxy, arguments); | ||
_this2.on(eventName, function () { | ||
op[eventName].apply(this, arguments); | ||
}); | ||
@@ -83,8 +68,8 @@ }); | ||
_subscribeSelectedTabsHistory: function _subscribeSelectedTabsHistory() { | ||
var _this4 = this; | ||
var _this3 = this; | ||
this.on('onChange', function (_ref2) { | ||
var isSwitched = _ref2.isSwitched, | ||
oldState = _ref2.oldState; | ||
isSwitched && _this4.activedTabsHistory.add(oldState.selectedTabID); | ||
this.on('onChange', function (_ref) { | ||
var isSwitched = _ref.isSwitched, | ||
oldState = _ref.oldState; | ||
isSwitched && _this3.activedTabsHistory.add(oldState.selectedTabID); | ||
}); | ||
@@ -120,7 +105,7 @@ return this; | ||
_getOnChangePromise: function _getOnChangePromise() { | ||
var _this5 = this; | ||
var _this4 = this; | ||
return new Promise(function (resolve) { | ||
_this5.one('onChange', function () { | ||
resolve.call(_this5.userProxy); | ||
_this4.one('onChange', function () { | ||
resolve.call(_this4.userProxy); | ||
}); | ||
@@ -142,6 +127,6 @@ }); | ||
var _findOpenedAndNoneDisableTabId = function _findOpenedAndNoneDisableTabId(tabsIdArr, isRightToLeft) { | ||
var _this6 = this; | ||
var _this5 = this; | ||
return this.helper.arrFilterUntilFirstValue(tabsIdArr, function (id) { | ||
return _this6.isOpen(id) && !_this6.getTab(id).disable && !_this6.isSelected(id); | ||
return _this5.isOpen(id) && !_this5.getTab(id).disable && !_this5.isSelected(id); | ||
}, isRightToLeft) || ''; | ||
@@ -219,3 +204,3 @@ }, | ||
getInitialState: function getInitialState() { | ||
var _this7 = this; | ||
var _this6 = this; | ||
@@ -229,3 +214,3 @@ if (!this._initialState) { | ||
tabs.map(function (tab) { | ||
_this7._addTab(tab, { | ||
_this6._addTab(tab, { | ||
defaultPanelComponent: defaultPanelComponent | ||
@@ -244,2 +229,24 @@ }); | ||
}, | ||
onChange: function onChange(_ref2) { | ||
var newState = _ref2.newState, | ||
oldState = _ref2.oldState, | ||
closedTabsId = _ref2.closedTabsId, | ||
openedTabsId = _ref2.openedTabsId, | ||
isSwitched = _ref2.isSwitched; | ||
if (isSwitched || openedTabsId.length || closedTabsId.length) { | ||
this.trigger('onChange', this.userProxy, { | ||
currentData: _extends({}, newState), | ||
perviousData: _extends({}, oldState) | ||
}); | ||
openedTabsId.length && this.trigger('onOpen', this.userProxy, openedTabsId); | ||
closedTabsId.length && this.trigger('onClose', this.userProxy, closedTabsId); | ||
isSwitched && this.trigger('onSelect', this.userProxy, { | ||
currentSelectedTabId: newState.selectedTabID, | ||
perviousSelectedTabId: oldState.selectedTabID | ||
}); | ||
} | ||
return this; | ||
}, | ||
eventHandlerFactory: function eventHandlerFactory(_ref3) { | ||
@@ -255,9 +262,5 @@ var e = _ref3.e, | ||
if (el.className.includes(closeClass) && parentEl && parentEl.lastChild && parentEl.lastChild == el && parentEl.className.includes(tabClass)) { | ||
// if just on of the beforeClose subscribers return false then it will prevent tab from close | ||
this.trigger('beforeClose', this.userProxy, e, id).includes(false) || this.close(id); | ||
this.getOption('beforeClose').call(this.userProxy, e, id) !== false && this.close(id); | ||
} else { | ||
// if just on of the beforeSelect subscribers return false then it will prevent tab from select | ||
if (!this.trigger('beforeSelect', this.userProxy, e, id).includes(false)) { | ||
this.select(id).then(function (result) {})["catch"](function (er) {}); | ||
} | ||
this.getOption('beforeSelect').call(this.userProxy, e, id) !== false && this.select(id); | ||
} | ||
@@ -264,0 +267,0 @@ } |
@@ -11,4 +11,2 @@ import helper from '../helper.js'; | ||
onSelect: [], | ||
beforeSelect: [], | ||
beforeClose: [], | ||
onInit: [], | ||
@@ -15,0 +13,0 @@ onFirstSelect: [] |
@@ -10,3 +10,3 @@ import React from 'react'; | ||
return { | ||
title: "unnamed tab", | ||
title: "", | ||
tooltip: "", | ||
@@ -13,0 +13,0 @@ panelComponent: defaultPanelComponent, |
{ | ||
"name": "react-dyn-tabs", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"private": false, | ||
@@ -29,3 +29,3 @@ "author": "dev-javascript", | ||
"prepublish": "npm run build", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "jest" | ||
}, | ||
@@ -59,3 +59,5 @@ "peerDependencies": { | ||
"webpack": "^4.44.1", | ||
"webpack-cli": "^3.3.12" | ||
"webpack-cli": "^3.3.12", | ||
"react-test-renderer": "^17.0.2", | ||
"jest": "^26.6.3" | ||
}, | ||
@@ -76,2 +78,4 @@ "files": [ | ||
"tab", | ||
"tabs", | ||
"react-dynamic-tabs", | ||
"dynamic-tabs", | ||
@@ -78,0 +82,0 @@ "multi-tabs", |
# react-dyn-tabs | ||
React Dynamic Tabs with full API | ||
### [document](https://github.com/dev-javascript/react-dyn-tabs/) | ||
## Features | ||
@@ -7,0 +9,0 @@ |
@@ -1,205 +0,262 @@ | ||
// import React, { useState } from "react"; | ||
// import ReactDom from "react-dom"; | ||
// import Tab from "./tab"; | ||
// import { act } from "react-dom/test-utils"; | ||
// import renderer from 'react-test-renderer'; | ||
// let container = document.createElement("div"), | ||
// realUseContext; | ||
// const defaultApi = { | ||
// stackedEvent: { afterActiveTab: [] }, | ||
// tabDidUpdate: jest.fn(({ tabId, isSelected, isFirstCall }) => { }), | ||
// tabDidMount: jest.fn(({ tabId, isSelected }) => { }), | ||
// activeTabEventHandler: jest.fn(() => { }), | ||
// }, | ||
// getMockOptions = () => () => ({ | ||
// data: { | ||
// allTabs: { | ||
// "1": { id: 1, title: "a1" }, | ||
// "2": { id: 2, title: "a3" }, | ||
// "3": { id: 3, title: "a2" }, | ||
// }, | ||
// }, | ||
// cssClasses: { | ||
// tab: "rdlt-default-tab defaultTab", | ||
// activeTab: "rdlt-active-tab activeTab" | ||
// }, | ||
// }), | ||
// setMockUseContext = (api) => { | ||
// React.useContext = jest.fn(() => Object.assign({}, defaultApi, api || {})); | ||
// }; | ||
// beforeAll(() => { | ||
// document.body.appendChild(container); | ||
// realUseContext = React.useContext; | ||
// }); | ||
// beforeEach(() => { | ||
// setMockUseContext({ getOptions: getMockOptions() }); | ||
// }); | ||
// afterEach(() => { | ||
// ReactDom.unmountComponentAtNode(container); | ||
// container.innerHTML = ""; | ||
// React.useContext = realUseContext; | ||
// }); | ||
// afterAll(() => { | ||
// document.body.removeChild(container); | ||
// container = null; | ||
// }); | ||
// test("tab component must expect id and selectedTabID as a props", () => { | ||
// act(() => { | ||
// ReactDom.render(<> | ||
// <Tab id="1" selectedTabID="1"></Tab> | ||
// <Tab id="2" selectedTabID="1"></Tab> | ||
// </>, container); | ||
// }); | ||
// const tab1El = document.getElementById("tab_1"), tab2El = document.getElementById("tab_2"); | ||
// expect(tab1El).not.toBe(null); | ||
// expect(tab2El).not.toBe(null); | ||
// expect(tab1El.className.includes('active')).toBe(true); | ||
// expect(tab2El.className.includes('active')).toBe(false); | ||
// }); | ||
// describe("tab classes", () => { | ||
// test(`only activeTab must have an "rdlt-active-tab" class and all tabs must have a | ||
// "rdlt-default-tab" class`, () => { | ||
// act(() => { | ||
// ReactDom.render( | ||
// <> | ||
// <Tab id="1" selectedTabID="1"></Tab> | ||
// <Tab id="2" selectedTabID="1"></Tab> | ||
// </>, | ||
// container | ||
// ); | ||
// }); | ||
// const t1c = document.getElementById("tab_1").className, | ||
// t2c = document.getElementById("tab_2").className; | ||
// expect(t1c.includes("rdlt-active-tab")).toBe(true); | ||
// expect(t1c.includes("rdlt-default-tab")).toBe(true); | ||
// expect(t2c.includes("rdlt-active-tab")).toBe(false); | ||
// expect(t2c.includes("rdlt-default-tab")).toBe(true); | ||
// }); | ||
// test('tab may have some user defined classes like "activeTab" and "defaultTab"', () => { | ||
// act(() => { | ||
// ReactDom.render( | ||
// <> | ||
// <Tab id="1" selectedTabID="1"></Tab> | ||
// <Tab id="2" selectedTabID="1"></Tab> | ||
// </>, | ||
// container | ||
// ); | ||
// }); | ||
// const tab1El = document.getElementById("tab_1"), tab2El = document.getElementById("tab_2"); | ||
// expect(tab1El.className.includes("activeTab")).toBe(true); | ||
// expect(tab1El.className.includes("defaultTab")).toBe(true); | ||
// expect(tab2El.className.includes("defaultTab")).toBe(true); | ||
// expect(tab2El.className.includes("activeTab")).toBe(false); | ||
// }); | ||
// }); | ||
// describe("tab mouse events", () => { | ||
// test(`tab must implement mousedown, click and mouseup events and all of them must call | ||
// activeTabEventHandler`, () => { | ||
// const activeTabEventHandler = jest.fn(() => { }); | ||
// setMockUseContext({ getOptions: getMockOptions(), activeTabEventHandler }); | ||
// act(() => { | ||
// ReactDom.render( | ||
// <> | ||
// <Tab id="1" selectedTabID="1"></Tab> | ||
// <Tab id="2" selectedTabID="1"></Tab> | ||
// </>, | ||
// container | ||
// ); | ||
// }); | ||
// const tab1El = document.getElementById("tab_1"), | ||
// tab2El = document.getElementById("tab_2"); | ||
// const e0 = new MouseEvent("mousedown", { bubbles: true }), | ||
// e6 = new MouseEvent("mouseup", { bubbles: true }); | ||
// tab1El.dispatchEvent(e0); | ||
// tab1El.dispatchEvent(new MouseEvent("click", { bubbles: true })); | ||
// tab1El.dispatchEvent(new MouseEvent("mouseup", { bubbles: true })); | ||
// tab2El.dispatchEvent(new MouseEvent("mousedown", { bubbles: true })); | ||
// tab2El.dispatchEvent(new MouseEvent("click", { bubbles: true })); | ||
// tab2El.dispatchEvent(e6); | ||
// expect(activeTabEventHandler).toHaveBeenCalledTimes(6); | ||
// expect(activeTabEventHandler.mock.calls[0][1]).toBe('1'); | ||
// expect(activeTabEventHandler.mock.calls[5][1]).toBe('2'); | ||
// }); | ||
// }); | ||
// describe("calling tabDidMount and tabDidUpdate inside the useEffect", () => { | ||
// test(`tabDidMount will be called just one time during the executions of tabComponent`, () => { | ||
// const tabDidMount = jest.fn(({ tabId, isSelected }) => { }); | ||
// setMockUseContext({ getOptions: getMockOptions(), tabDidMount }); | ||
// act(() => { | ||
// ReactDom.render( | ||
// <> | ||
// <Tab selectedTabID="2" id="1"></Tab> | ||
// <Tab selectedTabID="2" id="2"></Tab> | ||
// </>, | ||
// container | ||
// ); | ||
// }); | ||
// act(() => { | ||
// document.getElementById("tab_1").dispatchEvent(new MouseEvent("clik", { bubbles: true })); | ||
// document.getElementById("tab_2").dispatchEvent(new MouseEvent("clik", { bubbles: true })); | ||
// }); | ||
// expect(tabDidMount).toHaveBeenCalledTimes(2); | ||
// expect(tabDidMount).toHaveBeenNthCalledWith(1, { id: "1", isSelected: false }); | ||
// expect(tabDidMount).toHaveBeenNthCalledWith(2, { id: "2", isSelected: true }); | ||
// }); | ||
// test(`tabDidUpdate must will be called in the first execution of tabComponent`, () => { | ||
// const tabDidUpdate = jest.fn(({ tabId, isSelected, isFirstCall }) => { }), | ||
// tabDidMount = jest.fn(({ tabId, isSelected }) => { }); | ||
// setMockUseContext({ getOptions: getMockOptions(), tabDidMount, tabDidUpdate }); | ||
// act(() => { | ||
// ReactDom.render( | ||
// <> | ||
// <Tab selectedTabID="2" id="1"></Tab> | ||
// <Tab selectedTabID="2" id="2"></Tab> | ||
// </>, | ||
// container | ||
// ); | ||
// }); | ||
// expect(tabDidUpdate).toHaveBeenCalledTimes(2); | ||
// expect(tabDidUpdate).toHaveBeenNthCalledWith(1, { id: "1", isSelected: false, isFirstCall: true }); | ||
// expect(tabDidUpdate).toHaveBeenNthCalledWith(2, { id: "2", isSelected: true, isFirstCall: true }); | ||
// }); | ||
// test(`tabDidUpdate will be called twice for switching between tabs, one for activeTab component | ||
// and another one for deselectTab component(old activeTabComponent)`, () => { | ||
// const tabDidUpdate = jest.fn(({ tabId, isSelected, isFirstCall }) => { }), | ||
// tabDidMount = jest.fn(({ tabId, isSelected }) => { }); | ||
// setMockUseContext({ getOptions: getMockOptions(), tabDidMount, tabDidUpdate }); | ||
// function MockWrapprTab() { | ||
// const [activeId, setActiveId] = useState({ id: '2' }), toggelActiveTab = (e) => { | ||
// activeId === '2' ? setActiveId('1') : setActiveId('2'); | ||
// }, refresh = id => { setActiveId({ id }); }; | ||
// return <> | ||
// <button id='toggelActiveTabBtn' onClick={toggelActiveTab}></button> | ||
// <button id='forceUpdateBtn' onClick={refresh}></button> | ||
// <Tab selectedTabID={activeId} id="1"></Tab> | ||
// <Tab selectedTabID={activeId} id="2"></Tab> | ||
// <Tab selectedTabID={activeId} id="3"></Tab> | ||
// </>; | ||
// } | ||
// act(() => { ReactDom.render(<MockWrapprTab></MockWrapprTab>, container); }); | ||
// const toggelActiveTabBtn = document.getElementById('toggelActiveTabBtn'), | ||
// forceUpdateBtn = document.getElementById('forceUpdateBtn'); | ||
// act(() => { toggelActiveTabBtn.dispatchEvent(new MouseEvent("click", { bubbles: true })); }); | ||
// act(() => { toggelActiveTabBtn.dispatchEvent(new MouseEvent("click", { bubbles: true })); }); | ||
// act(() => { forceUpdateBtn.dispatchEvent(new MouseEvent("click", { bubbles: true })); }); | ||
// expect(tabDidUpdate).toHaveBeenCalledTimes(7); | ||
// expect(tabDidUpdate).toHaveBeenLastCalledWith({ id: '1', isSelected: false, isFirstCall: false }); | ||
// }); | ||
// }); | ||
// test('tab component with user defined css class "defualtTab" and "activeTab"', () => { | ||
// const tree = renderer.create( | ||
// <> | ||
// <Tab id='1' selectedTabID='1'></Tab> | ||
// <Tab id='2' selectedTabID='1'></Tab> | ||
// </> | ||
// ).toJSON(); | ||
// expect(tree).toMatchSnapshot(); | ||
// }); | ||
// test('selectedTabID props can be passed as an empty string into tab component', () => { | ||
// const tree = renderer.create( | ||
// <Tab id='1' selectedTabID=''></Tab> | ||
// ).toJSON(); | ||
// expect(tree).toMatchSnapshot(); | ||
// }); | ||
// //user defined hover class | ||
// //mock getId function | ||
import React, { useState } from "react" | ||
import { render, unmountComponentAtNode } from "react-dom"; | ||
import Tab from "./tab"; | ||
import { act } from "react-dom/test-utils"; | ||
import renderer from 'react-test-renderer'; | ||
import DefaultTabInner from './defaulTabInner.js'; | ||
let container = document.createElement("div"), realUseContext; | ||
const getDefaultApi = () => ({ | ||
getTab: jest.fn((id) => ({ | ||
title: "", | ||
tooltip: "", | ||
panelComponent: null, | ||
closable: true, | ||
iconClass: "", | ||
disable: false, | ||
id: 1 | ||
})), | ||
eventHandlerFactory: jest.fn(({ e, id }) => { }), | ||
getOption: jest.fn(opName => DefaultTabInner), | ||
userProxy: {}, | ||
optionsManager: { | ||
options: { | ||
accessibility: true, direction: 'ltr' | ||
}, | ||
setting: { | ||
tabClass: 'rc-dyn-tabs-tab', | ||
titleClass: 'rc-dyn-tabs-title', | ||
iconClass: 'rc-dyn-tabs-icon', | ||
selectedClass: 'rc-dyn-tabs-selected', | ||
closeClass: 'rc-dyn-tabs-close', | ||
disableClass: 'rc-dyn-tabs-disable', | ||
panelIdTemplate: jest.fn(id => `rc-dyn-tabs-p-${id}`), | ||
ariaLabelledbyIdTemplate: jest.fn(id => `rc-dyn-tabs-l-${id}`) | ||
} | ||
} | ||
}) | ||
, setMockUseContext = (api) => { | ||
React.useContext = jest.fn(() => Object.assign({}, getDefaultApi(), api || {})); | ||
}; | ||
beforeAll(() => { | ||
document.body.appendChild(container); | ||
realUseContext = React.useContext; | ||
}); | ||
beforeEach(() => { | ||
setMockUseContext(); | ||
}); | ||
afterEach(() => { | ||
unmountComponentAtNode(container); | ||
container.innerHTML = ""; | ||
React.useContext = realUseContext; | ||
}); | ||
afterAll(() => { | ||
document.body.removeChild(container); | ||
container = null; | ||
}); | ||
describe('tab structure with default options : ', () => { | ||
test('default tab data', () => { | ||
setMockUseContext(); | ||
const tree = renderer | ||
.create(<div> | ||
<Tab id="1" selectedTabID="1"></Tab> | ||
<Tab id="2" selectedTabID="1"></Tab> | ||
</div>) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
test('none closable tab', () => { | ||
setMockUseContext({ | ||
getTab: jest.fn((id) => ({ | ||
title: "", | ||
tooltip: "", | ||
panelComponent: null, | ||
closable: false, | ||
iconClass: "", | ||
disable: false, | ||
id: 1 | ||
})) | ||
}); | ||
const tree = renderer | ||
.create(<div> | ||
<Tab id="1" selectedTabID="1"></Tab> | ||
<Tab id="2" selectedTabID="1"></Tab> | ||
</div>) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
test('disabled tab', () => { | ||
setMockUseContext({ | ||
getTab: jest.fn((id) => ({ | ||
title: "", | ||
tooltip: "", | ||
panelComponent: null, | ||
closable: true, | ||
iconClass: "", | ||
disable: true, | ||
id: 1 | ||
})) | ||
}); | ||
const tree = renderer | ||
.create(<div> | ||
<Tab id="1" selectedTabID="1"></Tab> | ||
<Tab id="2" selectedTabID="1"></Tab> | ||
</div>) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
test('tab with provided tooltip and iconClass', () => { | ||
setMockUseContext({ | ||
getTab: jest.fn((id) => ({ | ||
title: "tab title", | ||
tooltip: "tab tooltip", | ||
panelComponent: null, | ||
closable: true, | ||
iconClass: "ui-icon ui-icon-heart", | ||
disable: false, | ||
id: 1 | ||
})) | ||
}); | ||
const tree = renderer | ||
.create(<div> | ||
<Tab id="1" selectedTabID="1"></Tab> | ||
<Tab id="2" selectedTabID="1"></Tab> | ||
</div>) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); | ||
describe('tab structure with rtl and none accessibility options : ', () => { | ||
test('default tab data', () => { | ||
setMockUseContext({ | ||
optionsManager: { | ||
options: { | ||
accessibility: false, direction: 'rtl' | ||
}, | ||
setting: { | ||
tabClass: 'rc-dyn-tabs-tab', | ||
titleClass: 'rc-dyn-tabs-title', | ||
iconClass: 'rc-dyn-tabs-icon', | ||
selectedClass: 'rc-dyn-tabs-selected', | ||
closeClass: 'rc-dyn-tabs-close', | ||
disableClass: 'rc-dyn-tabs-disable', | ||
panelIdTemplate: jest.fn(id => `rc-dyn-tabs-p-${id}`), | ||
ariaLabelledbyIdTemplate: jest.fn(id => `rc-dyn-tabs-l-${id}`) | ||
} | ||
} | ||
}); | ||
const tree = renderer | ||
.create(<div> | ||
<Tab id="1" selectedTabID="1"></Tab> | ||
<Tab id="2" selectedTabID="1"></Tab> | ||
</div>) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
test('none closable tab', () => { | ||
setMockUseContext({ | ||
optionsManager: { | ||
options: { | ||
accessibility: false, direction: 'rtl' | ||
}, | ||
setting: { | ||
tabClass: 'rc-dyn-tabs-tab', | ||
titleClass: 'rc-dyn-tabs-title', | ||
iconClass: 'rc-dyn-tabs-icon', | ||
selectedClass: 'rc-dyn-tabs-selected', | ||
closeClass: 'rc-dyn-tabs-close', | ||
disableClass: 'rc-dyn-tabs-disable', | ||
panelIdTemplate: jest.fn(id => `rc-dyn-tabs-p-${id}`), | ||
ariaLabelledbyIdTemplate: jest.fn(id => `rc-dyn-tabs-l-${id}`) | ||
} | ||
}, | ||
getTab: jest.fn((id) => ({ | ||
title: "", | ||
tooltip: "", | ||
panelComponent: null, | ||
closable: false, | ||
iconClass: "", | ||
disable: false, | ||
id: 1 | ||
})) | ||
}); | ||
const tree = renderer | ||
.create(<div> | ||
<Tab id="1" selectedTabID="1"></Tab> | ||
<Tab id="2" selectedTabID="1"></Tab> | ||
</div>) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
test('disabled tab', () => { | ||
setMockUseContext({ | ||
optionsManager: { | ||
options: { | ||
accessibility: false, direction: 'rtl' | ||
}, | ||
setting: { | ||
tabClass: 'rc-dyn-tabs-tab', | ||
titleClass: 'rc-dyn-tabs-title', | ||
iconClass: 'rc-dyn-tabs-icon', | ||
selectedClass: 'rc-dyn-tabs-selected', | ||
closeClass: 'rc-dyn-tabs-close', | ||
disableClass: 'rc-dyn-tabs-disable', | ||
panelIdTemplate: jest.fn(id => `rc-dyn-tabs-p-${id}`), | ||
ariaLabelledbyIdTemplate: jest.fn(id => `rc-dyn-tabs-l-${id}`) | ||
} | ||
}, | ||
getTab: jest.fn((id) => ({ | ||
title: "", | ||
tooltip: "", | ||
panelComponent: null, | ||
closable: true, | ||
iconClass: "", | ||
disable: true, | ||
id: 1 | ||
})) | ||
}); | ||
const tree = renderer | ||
.create(<div> | ||
<Tab id="1" selectedTabID="1"></Tab> | ||
<Tab id="2" selectedTabID="1"></Tab> | ||
</div>) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
test('tab with provided tooltip and iconClass', () => { | ||
setMockUseContext({ | ||
optionsManager: { | ||
options: { | ||
accessibility: false, direction: 'rtl' | ||
}, | ||
setting: { | ||
tabClass: 'rc-dyn-tabs-tab', | ||
titleClass: 'rc-dyn-tabs-title', | ||
iconClass: 'rc-dyn-tabs-icon', | ||
selectedClass: 'rc-dyn-tabs-selected', | ||
closeClass: 'rc-dyn-tabs-close', | ||
disableClass: 'rc-dyn-tabs-disable', | ||
panelIdTemplate: jest.fn(id => `rc-dyn-tabs-p-${id}`), | ||
ariaLabelledbyIdTemplate: jest.fn(id => `rc-dyn-tabs-l-${id}`) | ||
} | ||
}, | ||
getTab: jest.fn((id) => ({ | ||
title: "tab title", | ||
tooltip: "tab tooltip", | ||
panelComponent: null, | ||
closable: true, | ||
iconClass: "ui-icon ui-icon-heart", | ||
disable: false, | ||
id: 1 | ||
})) | ||
}); | ||
const tree = renderer | ||
.create(<div> | ||
<Tab id="1" selectedTabID="1"></Tab> | ||
<Tab id="2" selectedTabID="1"></Tab> | ||
</div>) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); | ||
@@ -45,2 +45,3 @@ const TabPropsManager = function ({ api, id, isSelected }) { | ||
className: this._setting.titleClass, | ||
title: this._tabObj.tooltip, | ||
tabIndex: -1 | ||
@@ -47,0 +48,0 @@ } |
@@ -27,3 +27,3 @@ | ||
, isSwitched = oldState.selectedTabID !== state.selectedTabID; | ||
api.trigger('onChange', api.userProxy, { newState: state, oldState, closedTabsId, openedTabsId, isSwitched }); | ||
api.onChange({ newState: state, oldState, closedTabsId, openedTabsId, isSwitched }); | ||
}, [state]); | ||
@@ -30,0 +30,0 @@ if (!_ref.TabListComponent) |
@@ -6,3 +6,3 @@ import Helper from '../helper.js'; | ||
helper.setNoneEnumProps(this, { optionsManager, helper, activedTabsHistory }); | ||
this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions()._subscribeOnChange(); | ||
this._setUserProxy()._subscribeSelectedTabsHistory()._subscribeCallbacksOptions();//._subscribeOnChange(); | ||
}; | ||
@@ -27,13 +27,2 @@ const _apiProps = { | ||
}, | ||
_subscribeOnChange: function () { | ||
this.on('onChange', ({ newState, oldState, closedTabsId, openedTabsId, isSwitched }) => { | ||
openedTabsId.length && this.trigger('onOpen', this.userProxy, openedTabsId); | ||
closedTabsId.length && this.trigger('onClose', this.userProxy, closedTabsId); | ||
isSwitched && this.trigger('onSelect', this.userProxy, { | ||
currentSelectedTabId: newState.selectedTabID, | ||
perviousSelectedTabId: oldState.selectedTabID | ||
}); | ||
}); | ||
return this; | ||
}, | ||
_subscribeCallbacksOptions: function () { | ||
@@ -43,3 +32,3 @@ const op = this.optionsManager.options; | ||
this.on(eventName, function () { | ||
op[eventName].apply(this.userProxy, arguments); | ||
op[eventName].apply(this, arguments); | ||
}); | ||
@@ -133,2 +122,17 @@ }); | ||
}, | ||
onChange: function ({ newState, oldState, closedTabsId, openedTabsId, isSwitched }) { | ||
if (isSwitched || openedTabsId.length || closedTabsId.length) { | ||
this.trigger('onChange', this.userProxy, { | ||
currentData: { ...newState }, | ||
perviousData: { ...oldState } | ||
}); | ||
openedTabsId.length && this.trigger('onOpen', this.userProxy, openedTabsId); | ||
closedTabsId.length && this.trigger('onClose', this.userProxy, closedTabsId); | ||
isSwitched && this.trigger('onSelect', this.userProxy, { | ||
currentSelectedTabId: newState.selectedTabID, | ||
perviousSelectedTabId: oldState.selectedTabID | ||
}); | ||
} | ||
return this; | ||
}, | ||
eventHandlerFactory: function ({ e, id }) { | ||
@@ -138,12 +142,6 @@ const el = e.target, parentEl = el.parentElement, { closeClass, tabClass } = this.optionsManager.setting; | ||
&& parentEl.className.includes(tabClass)) { | ||
// if just on of the beforeClose subscribers return false then it will prevent tab from close | ||
this.trigger('beforeClose', this.userProxy, e, id).includes(false) || this.close(id); | ||
(this.getOption('beforeClose').call(this.userProxy, e, id) !== false) && this.close(id); | ||
} | ||
else { | ||
// if just on of the beforeSelect subscribers return false then it will prevent tab from select | ||
if (!this.trigger('beforeSelect', this.userProxy, e, id).includes(false)) { | ||
this.select(id).then(result => { | ||
}).catch(er => { | ||
}); | ||
} | ||
(this.getOption('beforeSelect').call(this.userProxy, e, id) !== false) && this.select(id); | ||
} | ||
@@ -150,0 +148,0 @@ } |
@@ -10,4 +10,2 @@ import helper from '../helper.js'; | ||
, onSelect: [] | ||
, beforeSelect: [] | ||
, beforeClose: [] | ||
, onInit: [] | ||
@@ -14,0 +12,0 @@ , onFirstSelect: [] |
@@ -8,3 +8,3 @@ import React from 'react'; | ||
return { | ||
title: "unnamed tab", | ||
title: "", | ||
tooltip: "", | ||
@@ -11,0 +11,0 @@ panelComponent: defaultPanelComponent, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
1307821
119
11788
2
37
24