9 lines
10 KiB
JavaScript
9 lines
10 KiB
JavaScript
import{R as g,z as q,h as K,d as _,l as V,g as z,a4 as Y,X as G,a5 as W,y as Z,a6 as ee,m as ne,J as ae,s as M,C as F,o as te,p as oe,q as k,r as ie,a7 as le,a2 as re,a8 as L,a9 as ce,H as X}from"./index-i64aAU4V.js";import{R as se}from"./RightOutlined-0xyosP8R.js";const de=e=>({[e.componentCls]:{[`${e.antCls}-motion-collapse-legacy`]:{overflow:"hidden","&-active":{transition:`height ${e.motionDurationMid} ${e.motionEaseInOut},
|
|
opacity ${e.motionDurationMid} ${e.motionEaseInOut} !important`}},[`${e.antCls}-motion-collapse`]:{overflow:"hidden",transition:`height ${e.motionDurationMid} ${e.motionEaseInOut},
|
|
opacity ${e.motionDurationMid} ${e.motionEaseInOut} !important`}}});var J=g.forwardRef(function(e,n){var a,t=e.prefixCls,o=e.forceRender,C=e.className,b=e.style,s=e.children,l=e.isActive,h=e.role,N=g.useState(l||o),i=q(N,2),c=i[0],d=i[1];return g.useEffect(function(){(o||l)&&d(!0)},[o,l]),c?g.createElement("div",{ref:n,className:K("".concat(t,"-content"),(a={},_(a,"".concat(t,"-content-active"),l),_(a,"".concat(t,"-content-inactive"),!l),a),C),style:b,role:h},g.createElement("div",{className:"".concat(t,"-content-box")},s)):null});J.displayName="PanelContent";var me=["showArrow","headerClass","isActive","onItemClick","forceRender","className","prefixCls","collapsible","accordion","panelKey","extra","header","expandIcon","openMotion","destroyInactivePanel","children"],Q=g.forwardRef(function(e,n){var a,t,o=e.showArrow,C=o===void 0?!0:o,b=e.headerClass,s=e.isActive,l=e.onItemClick,h=e.forceRender,N=e.className,i=e.prefixCls,c=e.collapsible,d=e.accordion,w=e.panelKey,u=e.extra,r=e.header,$=e.expandIcon,y=e.openMotion,x=e.destroyInactivePanel,m=e.children,E=V(e,me),v=c==="disabled",P=c==="header",I=c==="icon",S=u!=null&&typeof u!="boolean",A=function(){l==null||l(w)},f=function(O){(O.key==="Enter"||O.keyCode===G.ENTER||O.which===G.ENTER)&&A()},p=typeof $=="function"?$(e):g.createElement("i",{className:"arrow"});p&&(p=g.createElement("div",{className:"".concat(i,"-expand-icon"),onClick:["header","icon"].includes(c)?A:void 0},p));var R=K((a={},_(a,"".concat(i,"-item"),!0),_(a,"".concat(i,"-item-active"),s),_(a,"".concat(i,"-item-disabled"),v),a),N),H=K(b,(t={},_(t,"".concat(i,"-header"),!0),_(t,"".concat(i,"-header-collapsible-only"),P),_(t,"".concat(i,"-icon-collapsible-only"),I),t)),B={className:H,"aria-expanded":s,"aria-disabled":v,onKeyDown:f};return!P&&!I&&(B.onClick=A,B.role=d?"tab":"button",B.tabIndex=v?-1:0),g.createElement("div",z({},E,{ref:n,className:R}),g.createElement("div",B,C&&p,g.createElement("span",{className:"".concat(i,"-header-text"),onClick:c==="header"?A:void 0},r),S&&g.createElement("div",{className:"".concat(i,"-extra")},u)),g.createElement(Y,z({visible:s,leavedClassName:"".concat(i,"-content-hidden")},y,{forceRender:h,removeOnLeave:x}),function(j,O){var T=j.className,U=j.style;return g.createElement(J,{ref:O,prefixCls:i,className:T,style:U,isActive:s,forceRender:h,role:d?"tabpanel":void 0},m)}))}),ue=["children","label","key","collapsible","onItemClick","destroyInactivePanel"],ve=function(n,a){var t=a.prefixCls,o=a.accordion,C=a.collapsible,b=a.destroyInactivePanel,s=a.onItemClick,l=a.activeKey,h=a.openMotion,N=a.expandIcon;return n.map(function(i,c){var d=i.children,w=i.label,u=i.key,r=i.collapsible,$=i.onItemClick,y=i.destroyInactivePanel,x=V(i,ue),m=String(u??c),E=r??C,v=y??b,P=function(A){E!=="disabled"&&(s(A),$==null||$(A))},I=!1;return o?I=l[0]===m:I=l.indexOf(m)>-1,g.createElement(Q,z({},x,{prefixCls:t,key:m,panelKey:m,isActive:I,accordion:o,openMotion:h,expandIcon:N,header:w,collapsible:E,onItemClick:P,destroyInactivePanel:v}),d)})},fe=function(n,a,t){if(!n)return null;var o=t.prefixCls,C=t.accordion,b=t.collapsible,s=t.destroyInactivePanel,l=t.onItemClick,h=t.activeKey,N=t.openMotion,i=t.expandIcon,c=n.key||String(a),d=n.props,w=d.header,u=d.headerClass,r=d.destroyInactivePanel,$=d.collapsible,y=d.onItemClick,x=!1;C?x=h[0]===c:x=h.indexOf(c)>-1;var m=$??b,E=function(I){m!=="disabled"&&(l(I),y==null||y(I))},v={key:c,panelKey:c,header:w,headerClass:u,isActive:x,prefixCls:o,destroyInactivePanel:r??s,openMotion:N,accordion:C,children:n.props.children,onItemClick:E,expandIcon:i,collapsible:m};return typeof n.type=="string"?n:(Object.keys(v).forEach(function(P){typeof v[P]>"u"&&delete v[P]}),g.cloneElement(n,v))};function ge(e,n,a){return Array.isArray(e)?ve(e,a):W(n).map(function(t,o){return fe(t,o,a)})}function pe(e){var n=e;if(!Array.isArray(n)){var a=ne(n);n=a==="number"||a==="string"?[n]:[]}return n.map(function(t){return String(t)})}var Ce=g.forwardRef(function(e,n){var a=e.prefixCls,t=a===void 0?"rc-collapse":a,o=e.destroyInactivePanel,C=o===void 0?!1:o,b=e.style,s=e.accordion,l=e.className,h=e.children,N=e.collapsible,i=e.openMotion,c=e.expandIcon,d=e.activeKey,w=e.defaultActiveKey,u=e.onChange,r=e.items,$=K(t,l),y=Z([],{value:d,onChange:function(S){return u==null?void 0:u(S)},defaultValue:w,postState:pe}),x=q(y,2),m=x[0],E=x[1],v=function(S){return E(function(){if(s)return m[0]===S?[]:[S];var A=m.indexOf(S),f=A>-1;return f?m.filter(function(p){return p!==S}):[].concat(ae(m),[S])})};ee(!h,"[rc-collapse] `children` will be removed in next major version. Please use `items` instead.");var P=ge(r,h,{prefixCls:t,accordion:s,openMotion:i,expandIcon:c,collapsible:N,destroyInactivePanel:C,onItemClick:v,activeKey:m});return g.createElement("div",{ref:n,className:$,style:b,role:s?"tablist":void 0},P)});const D=Object.assign(Ce,{Panel:Q});D.Panel;const be=M.forwardRef((e,n)=>{const{getPrefixCls:a}=M.useContext(F),{prefixCls:t,className:o,showArrow:C=!0}=e,b=a("collapse",t),s=K({[`${b}-no-arrow`]:!C},o);return M.createElement(D.Panel,Object.assign({ref:n},e,{prefixCls:b,className:s}))}),he=e=>{const{componentCls:n,contentBg:a,padding:t,headerBg:o,headerPadding:C,collapseHeaderPaddingSM:b,collapseHeaderPaddingLG:s,collapsePanelBorderRadius:l,lineWidth:h,lineType:N,colorBorder:i,colorText:c,colorTextHeading:d,colorTextDisabled:w,fontSizeLG:u,lineHeight:r,lineHeightLG:$,marginSM:y,paddingSM:x,paddingLG:m,paddingXS:E,motionDurationSlow:v,fontSizeIcon:P,contentPadding:I,fontHeight:S,fontHeightLG:A}=e,f=`${k(h)} ${N} ${i}`;return{[n]:Object.assign(Object.assign({},ie(e)),{backgroundColor:o,border:f,borderBottom:0,borderRadius:l,"&-rtl":{direction:"rtl"},[`& > ${n}-item`]:{borderBottom:f,"&:last-child":{[`
|
|
&,
|
|
& > ${n}-header`]:{borderRadius:`0 0 ${k(l)} ${k(l)}`}},[`> ${n}-header`]:{position:"relative",display:"flex",flexWrap:"nowrap",alignItems:"flex-start",padding:C,color:d,lineHeight:r,cursor:"pointer",transition:`all ${v}, visibility 0s`,[`> ${n}-header-text`]:{flex:"auto"},"&:focus":{outline:"none"},[`${n}-expand-icon`]:{height:S,display:"flex",alignItems:"center",paddingInlineEnd:y},[`${n}-arrow`]:Object.assign(Object.assign({},le()),{fontSize:P,svg:{transition:`transform ${v}`}}),[`${n}-header-text`]:{marginInlineEnd:"auto"}},[`${n}-icon-collapsible-only`]:{cursor:"unset",[`${n}-expand-icon`]:{cursor:"pointer"}}},[`${n}-content`]:{color:c,backgroundColor:a,borderTop:f,[`& > ${n}-content-box`]:{padding:I},"&-hidden":{display:"none"}},"&-small":{[`> ${n}-item`]:{[`> ${n}-header`]:{padding:b,paddingInlineStart:E,[`> ${n}-expand-icon`]:{marginInlineStart:e.calc(x).sub(E).equal()}},[`> ${n}-content > ${n}-content-box`]:{padding:x}}},"&-large":{[`> ${n}-item`]:{fontSize:u,lineHeight:$,[`> ${n}-header`]:{padding:s,paddingInlineStart:t,[`> ${n}-expand-icon`]:{height:A,marginInlineStart:e.calc(m).sub(t).equal()}},[`> ${n}-content > ${n}-content-box`]:{padding:m}}},[`${n}-item:last-child`]:{[`> ${n}-content`]:{borderRadius:`0 0 ${k(l)} ${k(l)}`}},[`& ${n}-item-disabled > ${n}-header`]:{"\n &,\n & > .arrow\n ":{color:w,cursor:"not-allowed"}},[`&${n}-icon-position-end`]:{[`& > ${n}-item`]:{[`> ${n}-header`]:{[`${n}-expand-icon`]:{order:1,paddingInlineEnd:0,paddingInlineStart:y}}}}})}},$e=e=>{const{componentCls:n}=e,a=`> ${n}-item > ${n}-header ${n}-arrow svg`;return{[`${n}-rtl`]:{[a]:{transform:"rotate(180deg)"}}}},ye=e=>{const{componentCls:n,headerBg:a,paddingXXS:t,colorBorder:o}=e;return{[`${n}-borderless`]:{backgroundColor:a,border:0,[`> ${n}-item`]:{borderBottom:`1px solid ${o}`},[`
|
|
> ${n}-item:last-child,
|
|
> ${n}-item:last-child ${n}-header
|
|
`]:{borderRadius:0},[`> ${n}-item:last-child`]:{borderBottom:0},[`> ${n}-item > ${n}-content`]:{backgroundColor:"transparent",borderTop:0},[`> ${n}-item > ${n}-content > ${n}-content-box`]:{paddingTop:t}}}},xe=e=>{const{componentCls:n,paddingSM:a}=e;return{[`${n}-ghost`]:{backgroundColor:"transparent",border:0,[`> ${n}-item`]:{borderBottom:0,[`> ${n}-content`]:{backgroundColor:"transparent",border:0,[`> ${n}-content-box`]:{paddingBlock:a}}}}}},Ie=e=>({headerPadding:`${e.paddingSM}px ${e.padding}px`,headerBg:e.colorFillAlter,contentPadding:`${e.padding}px 16px`,contentBg:e.colorBgContainer}),Pe=te("Collapse",e=>{const n=oe(e,{collapseHeaderPaddingSM:`${k(e.paddingXS)} ${k(e.paddingSM)}`,collapseHeaderPaddingLG:`${k(e.padding)} ${k(e.paddingLG)}`,collapsePanelBorderRadius:e.borderRadiusLG});return[he(n),ye(n),xe(n),$e(n),de(n)]},Ie),Se=M.forwardRef((e,n)=>{const{getPrefixCls:a,direction:t,collapse:o}=M.useContext(F),{prefixCls:C,className:b,rootClassName:s,style:l,bordered:h=!0,ghost:N,size:i,expandIconPosition:c="start",children:d,expandIcon:w}=e,u=re(f=>{var p;return(p=i??f)!==null&&p!==void 0?p:"middle"}),r=a("collapse",C),$=a(),[y,x,m]=Pe(r),E=M.useMemo(()=>c==="left"?"start":c==="right"?"end":c,[c]),v=w??(o==null?void 0:o.expandIcon),P=M.useCallback(function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const p=typeof v=="function"?v(f):M.createElement(se,{rotate:f.isActive?90:void 0});return L(p,()=>{var R;return{className:K((R=p==null?void 0:p.props)===null||R===void 0?void 0:R.className,`${r}-arrow`)}})},[v,r]),I=K(`${r}-icon-position-${E}`,{[`${r}-borderless`]:!h,[`${r}-rtl`]:t==="rtl",[`${r}-ghost`]:!!N,[`${r}-${u}`]:u!=="middle"},o==null?void 0:o.className,b,s,x,m),S=Object.assign(Object.assign({},ce($)),{motionAppear:!1,leavedClassName:`${r}-content-hidden`}),A=M.useMemo(()=>d?W(d).map((f,p)=>{var R,H;if(!((R=f.props)===null||R===void 0)&&R.disabled){const B=(H=f.key)!==null&&H!==void 0?H:String(p),{disabled:j,collapsible:O}=f.props,T=Object.assign(Object.assign({},X(f.props,["disabled"])),{key:B,collapsible:O??(j?"disabled":void 0)});return L(f,T)}return f}):null,[d]);return y(M.createElement(D,Object.assign({ref:n,openMotion:S},X(e,["rootClassName"]),{expandIcon:P,prefixCls:r,className:I,style:Object.assign(Object.assign({},o==null?void 0:o.style),l)}),A))}),Ee=Object.assign(Se,{Panel:be});export{Ee as C};
|