2 lines
2.0 KiB
JavaScript
2 lines
2.0 KiB
JavaScript
import{L as x,z as E,G as P,R as i,bg as V,bP as I,dt as p,bx as L,a8 as m}from"./index-B-sDl1ER.js";const u=["wrap","nowrap","wrap-reverse"],d=["flex-start","flex-end","start","end","center","space-between","space-around","space-evenly","stretch","normal","left","right"],y=["center","start","end","flex-start","flex-end","self-start","self-end","baseline","normal","stretch"],W=(e,t)=>{const n=t.wrap===!0?"wrap":t.wrap;return{[`${e}-wrap-${n}`]:n&&u.includes(n)}},z=(e,t)=>{const n={};return y.forEach(s=>{n[`${e}-align-${s}`]=t.align===s}),n[`${e}-align-stretch`]=!t.align&&!!t.vertical,n},R=(e,t)=>{const n={};return d.forEach(s=>{n[`${e}-justify-${s}`]=t.justify===s}),n},A=(e,t)=>x({...W(e,t),...z(e,t),...R(e,t)}),D=e=>{const{componentCls:t}=e;return{[t]:{display:"flex",margin:0,padding:0,"&-vertical":{flexDirection:"column"},"&-rtl":{direction:"rtl"},"&:empty":{display:"none"}}}},J=e=>{const{componentCls:t}=e;return{[t]:{"&-gap-small":{gap:e.flexGapSM},"&-gap-medium, &-gap-middle":{gap:e.flexGap},"&-gap-large":{gap:e.flexGapLG}}}},M=e=>{const{componentCls:t}=e,n={};return u.forEach(s=>{n[`${t}-wrap-${s}`]={flexWrap:s}}),n},T=e=>{const{componentCls:t}=e,n={};return y.forEach(s=>{n[`${t}-align-${s}`]={alignItems:s}}),n},H=e=>{const{componentCls:t}=e,n={};return d.forEach(s=>{n[`${t}-justify-${s}`]={justifyContent:s}}),n},O=()=>({}),X=E("Flex",e=>{const{paddingXS:t,padding:n,paddingLG:s}=e,a=P(e,{flexGapSM:t,flexGap:n,flexGapLG:s});return[D(a),J(a),M(a),T(a),H(a)]},O,{resetStyle:!1}),B=i.forwardRef((e,t)=>{const{prefixCls:n,rootClassName:s,className:a,style:C,flex:f,gap:r,vertical:$,orientation:S,component:h="div",children:w,...G}=e,{flex:o,direction:j,getPrefixCls:F}=i.useContext(V),l=F("flex",n),[N,b]=X(l),[,g]=I(S,$??o?.vertical),v=x(a,s,o?.className,l,N,b,A(l,{...e,vertical:g}),{[`${l}-rtl`]:j==="rtl",[`${l}-gap-${r}`]:p(r),[`${l}-vertical`]:g}),c={...o?.style,...C};return m(f)&&(c.flex=f),m(r)&&!p(r)&&(c.gap=r),i.createElement(h,{ref:t,className:v,style:c,...L(G,["justify","wrap","align"])},w)});export{B as F};
|