8 lines
15 KiB
JavaScript
8 lines
15 KiB
JavaScript
import{i as e}from"./rolldown-runtime-BgaNhQyE.js";import{Ct as t,Dr as n,Ht as r,Jn as i,Jt as a,L as o,Ln as s,M as c,Mt as l,N as u,O as d,Pn as f,Q as p,Qt as m,R as h,St as g,Un as _,Ut as v,Vn as y,Wn as b,Wt as x,Xn as S,Yn as C,Zn as w,Zt as T,en as E,et as D,fr as O,ir as k,jt as A,kt as j,mr as M,pt as N,sr as P,st as ee,tr as F,ur as I,wr as L,xn as R,xt as te,yr as z,zn as ne}from"./jsx-runtime-ADHq9IcL.js";var B=e(n()),V=r(`Wave`,e=>{let{componentCls:t,colorPrimary:n,motionDurationSlow:r,motionEaseInOut:i,motionEaseOutCirc:a,antCls:o}=e,[,s]=v(o,`wave`);return{[t]:{position:`absolute`,background:`transparent`,pointerEvents:`none`,boxSizing:`border-box`,color:s(`color`,n),boxShadow:`0 0 0 0 currentcolor`,opacity:.2,"&.wave-motion-appear":{transition:[`box-shadow 0.4s`,`opacity 2s`].map(e=>`${e} ${a}`).join(`,`),"&-active":{boxShadow:`0 0 0 6px currentcolor`,opacity:0},"&.wave-quick":{transition:[`box-shadow`,`opacity`].map(e=>`${e} ${r} ${i}`).join(`,`)}}}}}),H=`ant-wave-target`,U=e=>e?j(e)&&e!==`#fff`&&e!==`#ffffff`&&e!==`rgb(255, 255, 255)`&&e!==`rgba(255, 255, 255, 1)`&&!/rgba\((?:\d*, ){3}0\)/i.test(e)&&!/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i.test(e)&&e!==`transparent`&&e!==`canvastext`:!1;function W(e,t=null){let n=getComputedStyle(e),{borderTopColor:r,borderColor:i,backgroundColor:a}=n;return t&&U(n[t])?n[t]:[r,i,a].find(U)??null}function G(e){return Number.isNaN(e)?0:e}var K=e=>{let{className:t,target:n,component:r,colorSource:i}=e,a=B.useRef(null),{getPrefixCls:o}=B.useContext(s),[c]=v(o(),`wave`),[u,d]=B.useState(null),[f,p]=B.useState([]),[m,h]=B.useState(0),[g,_]=B.useState(0),[x,S]=B.useState(0),[w,T]=B.useState(0),[E,D]=B.useState(!1),O={left:m,top:g,width:x,height:w,borderRadius:f.map(e=>`${e}px`).join(` `)};u&&(O[c(`color`)]=u);function k(){let e=getComputedStyle(n);d(W(n,i));let t=e.position===`static`,{borderLeftWidth:r,borderTopWidth:a}=e;h(t?n.offsetLeft:G(-Number.parseFloat(r))),_(t?n.offsetTop:G(-Number.parseFloat(a))),S(n.offsetWidth),T(n.offsetHeight);let{borderTopLeftRadius:o,borderTopRightRadius:s,borderBottomLeftRadius:c,borderBottomRightRadius:l}=e;p([o,s,l,c].map(e=>G(Number.parseFloat(e))))}if(B.useEffect(()=>{if(n){let e=C(()=>{k(),D(!0)}),t;return typeof ResizeObserver<`u`&&(t=new ResizeObserver(k),t.observe(n)),()=>{C.cancel(e),t?.disconnect()}}},[n]),!E)return null;let j=(r===`Checkbox`||r===`Radio`)&&n?.classList.contains(H);return B.createElement(l,{visible:!0,motionAppear:!0,motionName:`wave-motion`,motionDeadline:5e3,onAppearEnd:(e,t)=>{if(t.deadline||A(t)&&t.propertyName===`opacity`){let e=a.current?.parentElement;b(e).then(()=>{e?.remove()})}return!1}},({className:e},n)=>B.createElement(`div`,{ref:I(a,n),className:y(t,e,{"wave-quick":j}),style:O}))},q=(e,t)=>{let{component:n}=t;if(n===`Checkbox`&&!e.querySelector(`input`)?.checked)return;let r=document.createElement(`div`);r.style.position=`absolute`,r.style.left=`0px`,r.style.top=`0px`,e?.insertBefore(r,e?.firstChild),_(B.createElement(K,{...t,target:e}),r)},J=(e,t,n,r)=>{let{wave:i}=B.useContext(s),[,a,o]=E(),c=L(s=>{let c=e.current;if(i?.disabled||!c)return;let l=c.querySelector(`.${H}`)||c,{showEffect:u}=i||{};(u||q)(l,{className:t,token:a,component:n,event:s,hashId:o,colorSource:r})}),l=B.useRef(null);return B.useEffect(()=>()=>{C.cancel(l.current)},[]),e=>{C.cancel(l.current),l.current=C(()=>{c(e)})}},Y={click:`click`,mousedown:`mousedown`,mouseup:`mouseup`,pointerdown:`pointerdown`,pointerup:`pointerup`},re=e=>{let{children:t,disabled:n,component:r,colorSource:i}=e,{getPrefixCls:a,wave:o}=(0,B.useContext)(s),c=(0,B.useRef)(null),l=a(`wave`),u=J(c,y(l,V(l)),r,i);return B.useEffect(()=>{let e=c.current;if(!e||e.nodeType!==window.Node.ELEMENT_NODE||n)return;let t=t=>{!P(t.target)||!e.getAttribute||e.getAttribute(`disabled`)||e.disabled||e.className.includes(`disabled`)&&!e.className.includes(`disabled:`)||e.getAttribute(`aria-disabled`)===`true`||e.className.includes(`-leave`)||u(t)},r=o?.triggerType,i=r&&r in Y?Y[r]:`click`;return e.addEventListener(i,t,!0),()=>{e.removeEventListener(i,t,!0)}},[n,o?.triggerType]),B.isValidElement(t)?ee(t,{ref:M(t)?I(O(t),c):c}):t??null},X=e=>{let{componentCls:t,antCls:n,motionDurationMid:r,motionEaseInOut:i}=e;return{[t]:{[`${n}-motion-collapse-legacy`]:{overflow:`hidden`,"&-active":{transition:`${[`height`,`opacity`].map(e=>`${e} ${r} ${i}`).join(`, `)} !important`}},[`${n}-motion-collapse`]:{overflow:`hidden`,transition:`${[`height`,`opacity`].map(e=>`${e} ${r} ${i}`).join(`, `)} !important`}}}},ie=B.forwardRef((e,t)=>{let{prefixCls:n,forceRender:r,className:i,style:a,children:o,isActive:s,role:c,classNames:l,styles:u}=e,[d,f]=B.useState(s||r);return B.useEffect(()=>{(r||s)&&f(!0)},[r,s]),d?B.createElement(`div`,{ref:t,className:y(`${n}-panel`,{[`${n}-panel-active`]:s,[`${n}-panel-inactive`]:!s},i),style:a,role:c},B.createElement(`div`,{className:y(`${n}-body`,l?.body),style:u?.body},o)):null}),Z=B.forwardRef((e,t)=>{let{showArrow:n=!0,headerClass:r,isActive:i,onItemClick:a,forceRender:o,className:s,classNames:u={},styles:d={},prefixCls:f,collapsible:p,accordion:m,panelKey:h,extra:g,header:_,expandIcon:v,openMotion:b,destroyOnHidden:x,children:S,...C}=e,w=p===`disabled`,T=g!=null&&typeof g!=`boolean`,E={onClick:()=>{a?.(h)},onKeyDown:e=>{(e.key===`Enter`||e.keyCode===k.ENTER||e.which===k.ENTER)&&a?.(h)},role:m?`tab`:`button`,"aria-expanded":i,"aria-disabled":w,tabIndex:w?-1:0},D=typeof v==`function`?v(e):B.createElement(`i`,{className:`arrow`}),O=D&&B.createElement(`div`,c({className:y(`${f}-expand-icon`,u?.icon),style:d?.icon},[`header`,`icon`].includes(p)?E:{}),D),A=y(`${f}-item`,{[`${f}-item-active`]:i,[`${f}-item-disabled`]:w},s),j={className:y(r,`${f}-header`,{[`${f}-collapsible-${p}`]:!!p},u?.header),style:d?.header,...[`header`,`icon`].includes(p)?{}:E};return B.createElement(`div`,c({},C,{ref:t,className:A}),B.createElement(`div`,j,n&&O,B.createElement(`span`,c({className:y(`${f}-title`,u?.title),style:d?.title},p===`header`?E:{}),_),T&&B.createElement(`div`,{className:`${f}-extra`},g)),B.createElement(l,c({visible:i,leavedClassName:`${f}-panel-hidden`},b,{forceRender:o,removeOnLeave:x}),({className:e,style:t},n)=>B.createElement(ie,{ref:n,prefixCls:f,className:e,classNames:u,style:t,styles:d,isActive:i,forceRender:o,role:m?`tabpanel`:void 0},S)))});function Q(e,t,n){if(!e||!t)return e||t;let r=Array.from(new Set([...Object.keys(e),...Object.keys(t)])),i={};return r.forEach(r=>{i[r]=n(e[r],t[r])}),i}function ae(e,t){return Q(e,t,(e,t)=>y(e,t))}function oe(e,t){return Q(e,t,(e,t)=>({...e,...t}))}var se=(e,t)=>{let{prefixCls:n,accordion:r,collapsible:i,destroyOnHidden:a,onItemClick:o,activeKey:s,openMotion:l,expandIcon:u,classNames:d,styles:f}=t;return e.map((e,t)=>{let{children:p,label:m,key:h,collapsible:g,onItemClick:_,destroyOnHidden:v,classNames:y,styles:b,...x}=e,S=String(h??t),C=g??i,w=v??a,T=e=>{C!==`disabled`&&(o(e),_?.(e))},E=!1;return E=r?s[0]===S:s.indexOf(S)>-1,B.createElement(Z,c({},x,{classNames:ae(d,y),styles:oe(f,b),prefixCls:n,key:S,panelKey:S,isActive:E,accordion:r,openMotion:l,expandIcon:u,header:m,collapsible:C,onItemClick:T,destroyOnHidden:w}),p)})},ce=(e,t,n)=>{if(!e)return null;let{prefixCls:r,accordion:i,collapsible:a,destroyOnHidden:o,onItemClick:s,activeKey:c,openMotion:l,expandIcon:u,classNames:d,styles:f}=n,p=e.key||String(t),{header:m,headerClass:h,destroyOnHidden:g,collapsible:_,onItemClick:v}=e.props,y=!1;y=i?c[0]===p:c.indexOf(p)>-1;let b=_??a,x={key:p,panelKey:p,header:m,headerClass:h,classNames:d,styles:f,isActive:y,prefixCls:r,destroyOnHidden:g??o,openMotion:l,accordion:i,children:e.props.children,onItemClick:e=>{b!==`disabled`&&(s(e),v?.(e))},expandIcon:u,collapsible:b};return typeof e.type==`string`?e:(Object.keys(x).forEach(e=>{x[e]===void 0&&delete x[e]}),B.cloneElement(e,x))};function le(e,t,n){return Array.isArray(e)?se(e,n):i(t).map((e,t)=>ce(e,t,n))}function $(e){let t=e;if(!Array.isArray(t)){let e=typeof t;t=e===`number`||e===`string`?[t]:[]}return t.map(e=>String(e))}var ue=Object.assign(B.forwardRef((e,t)=>{let{prefixCls:n=`rc-collapse`,destroyOnHidden:r=!1,style:i,accordion:a,className:o,children:s,collapsible:l,openMotion:u,expandIcon:d,activeKey:f,defaultActiveKey:p,onChange:m,items:h,classNames:g,styles:_}=e,v=y(n,o),[b,x]=z(p,f),C=$(b),w=L(e=>{let t=$(e);x(t),m?.(t)}),T=e=>{w(a?C[0]===e?[]:[e]:C.includes(e)?C.filter(t=>t!==e):[...C,e])};F(!s,"[rc-collapse] `children` will be removed in next major version. Please use `items` instead.");let E=le(h,s,{prefixCls:n,accordion:a,openMotion:u,expandIcon:d,collapsible:l,destroyOnHidden:r,onItemClick:T,activeKey:C,classNames:g,styles:_});return B.createElement(`div`,c({ref:t,className:v,style:i,role:a?`tablist`:void 0},S(e,{aria:!0,data:!0})),E)}),{Panel:Z}),de=ue,{Panel:fe}=ue,pe=B.forwardRef((e,t)=>{let{getPrefixCls:n}=B.useContext(s),{prefixCls:r,className:i,showArrow:a=!0}=e,o=n(`collapse`,r),c=y({[`${o}-no-arrow`]:!a},i);return B.createElement(de.Panel,{ref:t,...e,prefixCls:o,className:c})}),me=e=>{let{componentCls:t,contentBg:n,padding:r,headerBg:i,headerPadding:o,headerPaddingSM:s,headerPaddingLG:c,collapsePanelBorderRadius:l,lineWidth:u,lineType:d,colorBorder:p,colorText:h,colorTextHeading:g,colorTextDisabled:_,fontSizeLG:v,lineHeight:y,lineHeightLG:b,marginSM:x,paddingSM:S,paddingLG:C,paddingXS:w,motionDurationSlow:E,fontSizeIcon:D,contentPadding:O,contentPaddingSM:k,contentPaddingLG:A,fontHeight:j,fontHeightLG:M}=e,N=`${f(u)} ${d} ${p}`;return{[t]:{...T(e),backgroundColor:i,border:N,borderRadius:l,"&-rtl":{direction:`rtl`},[`& > ${t}-item`]:{borderBottom:N,"&:first-child":{[`
|
|
&,
|
|
& > ${t}-header`]:{borderRadius:`${f(l)} ${f(l)} 0 0`}},"&:last-child":{[`
|
|
&,
|
|
& > ${t}-header`]:{borderRadius:`0 0 ${f(l)} ${f(l)}`}},[`> ${t}-header`]:{position:`relative`,display:`flex`,flexWrap:`nowrap`,alignItems:`flex-start`,padding:o,color:g,lineHeight:y,cursor:`pointer`,transition:`all ${E}, visibility 0s`,...a(e),[`> ${t}-title`]:{flex:`auto`},[`${t}-expand-icon`]:{height:j,display:`flex`,alignItems:`center`,marginInlineEnd:x},[`${t}-arrow`]:{...m(),fontSize:D,transition:`transform ${E}`,svg:{transition:`transform ${E}`}},[`${t}-title`]:{marginInlineEnd:`auto`}},[`${t}-collapsible-header`]:{cursor:`default`,[`${t}-title`]:{flex:`none`,cursor:`pointer`},[`${t}-expand-icon`]:{cursor:`pointer`}},[`${t}-collapsible-icon`]:{cursor:`unset`,[`${t}-expand-icon`]:{cursor:`pointer`}}},[`${t}-panel`]:{color:h,backgroundColor:n,borderTop:N,[`& > ${t}-body`]:{padding:O},"&-hidden":{display:`none`}},"&-small":{[`> ${t}-item`]:{[`> ${t}-header`]:{padding:s,[`> ${t}-expand-icon`]:{marginInlineStart:e.calc(S).sub(w).equal()}},[`> ${t}-panel > ${t}-body`]:{padding:k}}},"&-large":{[`> ${t}-item`]:{fontSize:v,lineHeight:b,[`> ${t}-header`]:{padding:c,[`> ${t}-expand-icon`]:{height:M,marginInlineStart:e.calc(C).sub(r).equal()}},[`> ${t}-panel > ${t}-body`]:{padding:A}}},[`${t}-item:last-child`]:{borderBottom:0,[`> ${t}-panel`]:{borderRadius:`0 0 ${f(l)} ${f(l)}`}},[`& ${t}-item-disabled > ${t}-header`]:{"&, & > .arrow":{color:_,cursor:`not-allowed`}},[`&${t}-icon-placement-end`]:{[`& > ${t}-item`]:{[`> ${t}-header`]:{[`${t}-expand-icon`]:{order:1,marginInlineEnd:0,marginInlineStart:x}}}}}}},he=e=>{let{componentCls:t}=e,n=`> ${t}-item > ${t}-header ${t}-arrow`;return{[`${t}-rtl`]:{[n]:{transform:`rotate(180deg)`}}}},ge=e=>{let{componentCls:t,headerBg:n,borderlessContentPadding:r,borderlessContentBg:i,colorBorder:a}=e;return{[`${t}-borderless`]:{backgroundColor:n,border:0,[`> ${t}-item`]:{borderBottom:`1px solid ${a}`},[`
|
|
> ${t}-item:last-child,
|
|
> ${t}-item:last-child ${t}-header
|
|
`]:{borderRadius:0},[`> ${t}-item:last-child`]:{borderBottom:0},[`> ${t}-item > ${t}-panel`]:{backgroundColor:i,borderTop:0},[`> ${t}-item > ${t}-panel > ${t}-body`]:{padding:r}}}},_e=e=>{let{componentCls:t,paddingSM:n}=e;return{[`${t}-ghost`]:{backgroundColor:`transparent`,border:0,[`> ${t}-item`]:{borderBottom:0,[`> ${t}-panel`]:{backgroundColor:`transparent`,border:0,[`> ${t}-body`]:{paddingBlock:n}}}}}},ve=x(`Collapse`,e=>{let t=R(e,{collapsePanelBorderRadius:e.borderRadiusLG});return[me(t),ge(t),_e(t),he(t),X(t)]},e=>({headerPadding:`${f(e.paddingSM)} ${f(e.padding)}`,headerPaddingSM:`${f(e.paddingXS)} ${f(e.paddingSM)} ${f(e.paddingXS)} ${f(e.paddingXS)}`,headerPaddingLG:`${f(e.padding)} ${f(e.paddingLG)} ${f(e.padding)} ${f(e.padding)}`,headerBg:e.colorFillAlter,contentPadding:`${f(e.padding)} ${f(16)}`,contentPaddingSM:e.paddingSM,contentPaddingLG:e.paddingLG,contentBg:e.colorBgContainer,borderlessContentPadding:`${f(e.paddingXXS)} ${f(16)} ${f(e.padding)}`,borderlessContentBg:`transparent`})),ye=Object.assign(B.forwardRef((e,n)=>{let{getPrefixCls:r,direction:a,expandIcon:o,className:s,style:c,classNames:l,styles:d}=ne(`collapse`),{prefixCls:f,className:m,rootClassName:h,style:_,bordered:v=!0,ghost:b,size:x,expandIconPlacement:S,expandIconPosition:C,children:T,destroyInactivePanel:E,destroyOnHidden:O,expandIcon:k,classNames:A,styles:j}=e,M=p(e=>x??e??`middle`),N=r(`collapse`,f),P=r(),[F,I]=ve(N),L=S??C??`start`,R={...e,size:M,bordered:v,expandIconPlacement:L},z=g(c),V=g(_),[H,U]=te([l,A],[d,z,j,V],{props:R}),W=k??o,G=B.useCallback((e={})=>ee(t(W)?W(e):B.createElement(u,{rotate:e.isActive?a===`rtl`?-90:90:void 0,"aria-label":e.isActive?`expanded`:`collapsed`}),e=>({className:y(e.className,`${N}-arrow`)})),[W,N,a]),K=y(`${N}-icon-placement-${L}`,{[`${N}-borderless`]:!v,[`${N}-rtl`]:a===`rtl`,[`${N}-ghost`]:!!b,[`${N}-large`]:M===`large`,[`${N}-small`]:M===`small`},s,m,h,F,I,H.root),q=B.useMemo(()=>({...D(P),motionAppear:!1,leavedClassName:`${N}-panel-hidden`}),[P,N]),J=B.useMemo(()=>T?i(T).map(e=>e):null,[T]);return B.createElement(de,{ref:n,openMotion:q,...w(e,[`rootClassName`]),expandIcon:G,prefixCls:N,className:K,style:U.root,classNames:H,styles:U,destroyOnHidden:O??E},J)}),{Panel:pe}),be=e=>e.map(e=>(e.colors=e.colors.map(d),e)),xe=(e,t)=>{let{r:n,g:r,b:i,a}=e.toRgb(),o=new h(e.toRgbString()).onBackground(t).toHsv();return a<=.5?o.v>.5:n*.299+r*.587+i*.114>192},Se=(e,t)=>`panel-${e.key??t}`,Ce=({prefixCls:e,presets:t,value:n,onChange:r})=>{let[i]=N(`ColorPicker`),[,a]=E(),s=(0,B.useMemo)(()=>be(t),[t]),c=`${e}-presets`,l=(0,B.useMemo)(()=>s.reduce((e,t,n)=>{let{defaultOpen:r=!0}=t;return r&&e.push(Se(t,n)),e},[]),[s]),u=e=>{r?.(e)},f=s.map((t,r)=>({key:Se(t,r),label:B.createElement(`div`,{className:`${c}-label`},t?.label),children:B.createElement(`div`,{className:`${c}-items`},Array.isArray(t?.colors)&&t.colors?.length>0?t.colors.map((t,r)=>{let i=d(t);return B.createElement(o,{key:`preset-${r}-${t.toHexString()}`,color:i.toCssString(),prefixCls:e,className:y(`${c}-color`,{[`${c}-color-checked`]:t.toCssString()===n?.toCssString(),[`${c}-color-bright`]:xe(t,a.colorBgElevated)}),onClick:()=>u(t)})}):B.createElement(`span`,{className:`${c}-empty`},i.presetEmpty))}));return B.createElement(`div`,{className:c},B.createElement(ye,{defaultActiveKey:l,ghost:!0,items:f}))};export{H as a,re as i,xe as n,X as r,Ce as t}; |