-
Notifications
You must be signed in to change notification settings - Fork 0
/
3420-628e2315fc6576127500.js
1 lines (1 loc) · 13.7 KB
/
3420-628e2315fc6576127500.js
1
(self.webpackChunkzent_docs=self.webpackChunkzent_docs||[]).push([[3420],{33420:(t,e,n)=>{"use strict";n.d(e,{m:()=>O,Z:()=>w});var r=n(59312),a=n(24246),i=n(19185),s=n(60042),o=n.n(s),d=n(27378),l=n(31256),c=n(42690),u=n(12856),p=n(87396),h=n(98454),v=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.typeName="normal",e}return(0,r.ZT)(e,t),e.prototype.render=function(){var t=this.props,e=t.actived,n=t.disabled,i=t.children;return(0,a.jsx)("div",(0,r.pi)({role:"tab",className:this.tabsCls,"aria-disabled":n,"aria-selected":e,onClick:this.onClick,"data-zv":"9.12.16"},{children:(0,a.jsxs)("div",(0,r.pi)({className:"zent-tabs-tab-inner","data-zv":"9.12.16"},{children:[i,this.renderDelOperater()]}),void 0)}),void 0)},e}(h.Z),b=n(53789),f=n(27036),m=n(33806),g=n(77828),y=function(t){var e=t.tabs,n=t.onChange,i=(0,g.Q)(n),s=(0,d.useState)(!1),l=s[0],c=s[1],u=(0,d.useCallback)((function(t){i.current(t),!t.disabled&&c(!1)}),[i]);return(0,a.jsxs)(m.ZP,(0,r.pi)({position:m.ZP.Position.BottomLeft,cushion:3,visible:l,onVisibleChange:c},{children:[(0,a.jsx)(m.ZP.Trigger.Hover,{children:(0,a.jsx)(f.Z,{type:"more"},void 0)},void 0),(0,a.jsx)(m.ZP.Content,{children:(0,a.jsx)("div",(0,r.pi)({className:"zent-tabs-hidden-tabs","data-zv":"9.12.16"},{children:e.map((function(t){return(0,a.jsx)("div",(0,r.pi)({className:o()("zent-tabs-hidden-tab",{"zent-tabs-hidden-tab-disabled":t.disabled}),onClick:function(){return u(t)},"data-zv":"9.12.16"},{children:t.title}),t.key)}))}),void 0)},void 0)]}),void 0)},x=function(t){var e=t.disablePrev,n=t.disableNext,r=t.onPrevChange,i=t.onNextChange;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(f.Z,{type:"left",className:o()({"icon-disabled":e}),onClick:r},void 0),(0,a.jsx)(f.Z,{type:"right",className:o()({"icon-disabled":n}),onClick:i},void 0)]},void 0)},C=n(14322),T=n(41925),N=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tabsWrapperRef=(0,d.createRef)(),e.tabsMainRef=(0,d.createRef)(),e.state={startIndex:0,endIndex:0,translateX:0},e.getTargetIndex=function(t,e,n){void 0===n&&(n=!1);var r=e.list,a=e.tabsTotalWidth,i=n?r.length-1:0,s=n?-1:1;if(t<=0)return 0;if(t>=a)return r.length-1;for(var o=0;o<r.length;o++){var d=r[o],l=d.width,c=d.accumWidth;if(c+l>=t&&c<t)return o+s}return i},e.getHiddenTabs=(0,T.Z)((function(t,e,n){return t.reduce((function(t,r,a){return(a<e||a>n)&&t.push(r),t}),[])})),e.onStartChange=function(t,n){var r=n.list,a=n.tabsTotalWidth,i=e.tabsWrapperWidth,s=r[t].accumWidth+i,o=Math.min(s,a);s>a&&(t=e.getTargetIndex(a-i,n));var d=e.getTargetIndex(o,n,!0),l=o-i;e.setState({startIndex:t,endIndex:d,translateX:l})},e.onEndChange=function(t,n){var r=n.list,a=e.tabsWrapperWidth,i=r[t],s=i.accumWidth+i.width-a,o=Math.max(s,0);s<0&&(t=e.getTargetIndex(a,n,!0));var d=e.getTargetIndex(o,n);e.setState({startIndex:d,endIndex:t,translateX:o})},e.onAnchorPageChange=function(t){var n,r;if(!t.disabled){var a=e.getTabsInfo(),i=a.list.findIndex((function(e){return e.id===t.key})),s=e.state,o=s.startIndex,d=s.endIndex;i<=o&&e.onStartChange(i,a),i>=d&&e.onEndChange(i,a),null===(r=(n=e.props).onChange)||void 0===r||r.call(n,t.key)}},e.onSlidePageChange=function(t,n){if(void 0===n&&(n=!1),!n){var r=e.state,a=r.startIndex,i=r.endIndex,s=e.getTabsInfo();t?e.onEndChange(a-1,s):e.onStartChange(i+1,s)}},e.onResize=function(){e.onStartChange(e.state.startIndex,e.getTabsInfo())},e}return(0,r.ZT)(e,t),Object.defineProperty(e.prototype,"tabsWrapperWidth",{get:function(){var t;return(null===(t=this.tabsWrapperRef.current)||void 0===t?void 0:t.offsetWidth)||0},enumerable:!1,configurable:!0}),e.prototype.getTabsInfo=function(){for(var t,e=this.props.tabDataList,n=(null===(t=this.tabsMainRef.current)||void 0===t?void 0:t.children)||[],r=[],a=0,i=0;i<n.length;i++){var s=n[i].offsetWidth,o=e[i].key;r.push({id:o,width:s,accumWidth:a}),a+=s}return{list:r,tabsTotalWidth:a}},e.prototype.renderSlideOperations=function(){var t=this,e=this.props.tabDataList,n=this.state,r=n.startIndex,i=n.endIndex,s=!r,o=i>=e.length-1;return(0,a.jsx)(x,{disablePrev:s,disableNext:o,onPrevChange:function(){return t.onSlidePageChange(!0,s)},onNextChange:function(){return t.onSlidePageChange(!1,o)}},void 0)},e.prototype.renderAnchorOperations=function(t){return t.length?(0,a.jsx)(y,{tabs:t,onChange:this.onAnchorPageChange},void 0):null},e.prototype.componentDidMount=function(){this.onStartChange(0,this.getTabsInfo())},e.prototype.render=function(){var t,e=this.props,n=e.overflowMode,i=e.tabs,s=e.tabDataList,d=this.state,l=d.translateX,c=d.startIndex,u=d.endIndex,p="zent-tabs-nav-tabs-content-"+n,h=this.getHiddenTabs(s,c,u);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",(0,r.pi)({className:o()(p,(t={},t[p+"-left"]=!!c,t[p+"-right"]=u!==i.length-1,t)),ref:this.tabsWrapperRef,"data-zv":"9.12.16"},{children:(0,a.jsx)("div",(0,r.pi)({className:o()(p+"-main"),ref:this.tabsMainRef,style:{transform:"translate(-"+l+"px, 0)"},"data-zv":"9.12.16"},{children:i}),void 0)}),void 0),!!h.length&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",(0,r.pi)({className:p+"-option","data-zv":"9.12.16"},{children:["slide"===n&&this.renderSlideOperations(),"anchor"===n&&this.renderAnchorOperations(h)]}),void 0),(0,a.jsx)(C.w,{onResize:this.onResize},void 0)]},void 0)]},void 0)},e}(d.Component),z=n(77465),j=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.onTabDel=function(t){(0,e.props.onDelete)(t)},e}return(0,r.ZT)(e,t),Object.defineProperty(e.prototype,"tabsNavCls",{get:function(){var t,e=this.props.stretch;return o()("zent-tabs-nav","zent-tabs-nav-type__"+this.typeName,((t={})["zent-tabs-nav__stretch"]=e,t))},enumerable:!1,configurable:!0}),e.prototype.renderNavExtraContent=function(){var t=this.props.navExtraContent;return t?(0,a.jsx)("div",(0,r.pi)({className:"zent-tabs-nav-extra-content","data-zv":"9.12.16"},{children:t}),void 0):null},e.prototype.transformTabDataList=function(t){var e=this.props.candel;return t.map((function(t){return(0,z.V)(t,e)}))},e.prototype.render=function(){var t=this.renderNavExtraContent(),e=this.props,n=e.tabDataList,i=e.overflowMode,s=e.onChange,o=e.type,d=this.renderTabs(),l=i&&("normal"===o||"card"===o);return(0,a.jsxs)("div",(0,r.pi)({className:this.tabsNavCls,"data-zv":"9.12.16"},{children:[l?(0,a.jsx)(N,{overflowMode:i,onChange:s,tabDataList:n,tabs:d},void 0):(0,a.jsx)("div",(0,r.pi)({className:"zent-tabs-nav-content","data-zv":"9.12.16"},{children:(0,a.jsx)("div",(0,r.pi)({className:"zent-tabs-scroll",role:"tablist","data-zv":"9.12.16"},{children:d}),void 0)}),void 0),t]}),void 0)},e}(b.Z),Z=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.typeName="normal",e}return(0,r.ZT)(e,t),e.prototype.renderTab=function(t){return(0,a.jsx)(v,(0,r.pi)({onSelected:this.onTabSelected,onDelete:this.onTabDel},t,{id:t.key},{children:t.title}),void 0)},e}(j),P=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.typeName="card",e}return(0,r.ZT)(e,t),e.prototype.render=function(){var t=this.props,e=t.actived,n=t.disabled,i=t.children;return(0,a.jsx)("div",(0,r.pi)({role:"tab",className:this.tabsCls,"aria-disabled":n,"aria-selected":e,onClick:this.onClick,"data-zv":"9.12.16"},{children:(0,a.jsxs)("div",(0,r.pi)({className:"zent-tabs-tab-inner","data-zv":"9.12.16"},{children:[i,this.renderDelOperater()]}),void 0)}),void 0)},e}(h.Z),D=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.typeName="card",e}return(0,r.ZT)(e,t),e.prototype.renderTab=function(t){return(0,a.jsx)(P,(0,r.pi)({onSelected:this.onTabSelected,onDelete:this.onTabDel},t,{id:t.key},{children:t.title}),void 0)},e}(j),k=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.typeName="button",e}return(0,r.ZT)(e,t),e.prototype.render=function(){var t=this.props,e=t.actived,n=t.disabled,i=t.children;return(0,a.jsx)("div",(0,r.pi)({role:"tab",className:this.tabsCls,"aria-disabled":n,"aria-selected":e,onClick:this.onClick,"data-zv":"9.12.16"},{children:(0,a.jsx)("div",(0,r.pi)({className:"zent-tabs-tab-inner","data-zv":"9.12.16"},{children:i}),void 0)}),void 0)},e}(h.Z),I=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.typeName="button",e}return(0,r.ZT)(e,t),e.prototype.renderTab=function(t){return(0,a.jsx)(k,(0,r.pi)({onSelected:this.onTabSelected,onDelete:this.onTabDel},t,{id:t.key},{children:t.title}),void 0)},e}(j),S=n(87057),W={normal:Z,card:D,button:I},O=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),Object.defineProperty(e.prototype,"tabsCls",{get:function(){var t=this.props,e=t.className,n=t.type;return o()("zent-tabs","zent-tabs-type__"+n,e)},enumerable:!1,configurable:!0}),e.prototype.getTabDataListFromTabs=function(t){var e=this.props.activeId;return t.map((function(t){return(0,r.pi)((0,r.pi)({},t),{actived:t.key===e})}))},e.prototype.getTabDataListFromChildren=function(t){var e=this.props.activeId;return d.Children.map(t,(function(t){return(0,i.isElement)(t)?(0,z.A)(t,e):null})).filter((function(t){return!(0,l.Z)(t)}))},e.prototype.renderNav=function(t){var e=this.props,n=e.type,r=e.candel,i=e.stretch,s=e.navExtraContent,o=e.onChange,d=e.onDelete,l=e.overflowMode,c=W[n]||W.normal;return(0,a.jsx)(c,{onChange:o,tabDataList:t,onDelete:d,candel:r,stretch:i,overflowMode:l,navExtraContent:s,type:n},void 0)},e.prototype.renderTabPanel=function(t){var e=this.props,n=e.unmountPanelOnHide,i=e.disableLazyMount;return(0,a.jsx)(u.Z,(0,r.pi)({mount:i||t.actived},{children:(0,a.jsx)(p.Z,(0,r.pi)({tab:t.title,actived:t.actived,unmountOnHide:t.unmountOnHide||n,className:t.className,id:t.key},{children:t.panelChildren}),void 0)}),t.key)},e.TabPanel=p.Z,e.defaultProps={type:"normal",activeId:"",candel:!1,stretch:!1,onChange:c.Z,onDelete:c.Z,unmountPanelOnHide:!1},e}(S.Z),w=O},87396:(t,e,n)=>{"use strict";var r=n(59312),a=n(24246),i=n(60042),s=n.n(i);e.Z=function(t){var e=t.actived,n=t.className,i=t.unmountOnHide,o=t.children;if(!e&&i)return null;var d=e?{}:{display:"none"},l=s()("zent-tabs-panel",n);return(0,a.jsx)("div",(0,r.pi)({role:"tabpanel",style:d,className:l,"data-zv":"9.12.16"},{children:o}),void 0)}},98454:(t,e,n)=>{"use strict";var r=n(59312),a=n(24246),i=n(27378),s=n(60042),o=n.n(s),d=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.onDel=function(t){t.stopPropagation();var n=e.props,r=n.onDelete,a=n.id;r&&r(a)},e.onClick=function(){var t=e.props,n=t.onSelected,r=t.id,a=t.actived,i=t.disabled;a||i||n&&n(r)},e}return(0,r.ZT)(e,t),Object.defineProperty(e.prototype,"tabsCls",{get:function(){var t,e=this.props,n=e.actived,r=e.disabled;return o()("zent-tabs-tab","zent-tabs-tab-type__"+this.typeName,((t={})["zent-tabs-tab__actived"]=n,t["zent-tabs-tab__disabled"]=r,t))},enumerable:!1,configurable:!0}),e.prototype.renderDelOperater=function(){return this.props.candel?(0,a.jsx)("span",(0,r.pi)({className:"zent-tabs-tab-delete",onClick:this.onDel,"data-zv":"9.12.16"},{children:"✕"}),void 0):null},e}(i.Component);e.Z=d},87057:(t,e,n)=>{"use strict";var r=n(59312),a=n(24246),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),e.prototype.renderWithPanel=function(){var t=this.props.children,e=this.getTabDataListFromChildren(t);return(0,a.jsxs)("div",(0,r.pi)({className:this.tabsCls,"data-zv":"9.12.16"},{children:[this.renderNav(e),(0,a.jsx)("div",(0,r.pi)({className:"zent-tabs-panel-wrapper","data-zv":"9.12.16"},{children:e.map(this.renderTabPanel.bind(this))}),void 0)]}),void 0)},e.prototype.renderWithoutPanel=function(){var t=this.props.tabs;return(0,a.jsx)("div",(0,r.pi)({className:this.tabsCls,"data-zv":"9.12.16"},{children:this.renderNav(this.getTabDataListFromTabs(t))}),void 0)},e.prototype.render=function(){var t=this.props,e=t.tabs,n=t.children;if(!e&&!n)throw new Error("Tabs Componment must receive one prop of 'tabs' and 'children'");return e?this.renderWithoutPanel():this.renderWithPanel()},e}(n(27378).Component);e.Z=i},53789:(t,e,n)=>{"use strict";var r=n(59312),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.onTabSelected=function(t){(0,e.props.onChange)(t)},e}return(0,r.ZT)(e,t),e.prototype.renderTabs=function(){var t=this.props.tabDataList;return this.transformTabDataList(t).map(this.renderTab,this)},e}(n(27378).PureComponent);e.Z=a},77465:(t,e,n)=>{"use strict";function r(t,e){var n=t.props,r=n.id,a=n.disabled;return{title:n.tab,disabled:a,key:r,actived:e===r,panelChildren:n.children,className:n.className,unmountOnHide:n.unmountOnHide}}function a(t,e){return{key:t.key,actived:t.actived,disabled:t.disabled,title:t.title,className:t.className,candel:e&&!t.disabled}}n.d(e,{A:()=>r,V:()=>a})},12856:(t,e,n)=>{"use strict";var r=n(59312),a=function(t){function e(e){var n=t.call(this,e)||this;return n.state={mounted:e.mount},n}return(0,r.ZT)(e,t),e.prototype.render=function(){var t=this.props.children;return this.state.mounted?t:null},e.getDerivedStateFromProps=function(t,e){return t.mount&&!e.mounted?{mounted:!0}:null},e.defaultProps={mount:!1},e}(n(27378).Component);e.Z=a},14322:(t,e,n)=>{"use strict";n.d(e,{w:()=>l});var r=n(24246),a=n(27378),i=n(27468),s=n(80186),o=n(17127),d={passive:!0},l=function(t){var e=t.disableThrottle,n=void 0!==e&&e,l=t.onResize,c=(0,a.useRef)(null),u=(0,a.useRef)(l);u.current=l;var p=(0,a.useCallback)((function(t){var e=(0,i.ZP)();c.current||(c.current=e);var n=c.current,r={deltaX:e.width-n.width,deltaY:e.height-n.height};0===r.deltaX&&0===r.deltaY||(u.current(t,r),c.current=e)}),[]),h=(0,o.BN)(p,n);return(0,a.useEffect)((function(){return c.current=(0,i.ZP)(),h.cancel}),[h]),(0,r.jsx)(s.ZP,{eventName:"resize",listener:h,options:d},void 0)}},77828:(t,e,n)=>{"use strict";n.d(e,{Q:()=>a});var r=n(27378);function a(t){var e=(0,r.useRef)(t);return(0,r.useEffect)((function(){e.current=t}),[t]),e}},31256:(t,e,n)=>{"use strict";function r(t){return null==t}n.d(e,{Z:()=>r})}}]);