@cntrl-site/components 1.0.12-alpha.2 → 1.0.12-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2541 -2541
- package/dist/index.mjs +2542 -2542
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4662,2545 +4662,2545 @@ a.${e}-list-item {
|
|
|
4662
4662
|
overflow-wrap: anywhere;
|
|
4663
4663
|
word-break: break-word;
|
|
4664
4664
|
}
|
|
4665
|
-
`}const Pt=["AColumn","BColumnWidth","CColumnWidth","DColumnWidth","EColumnWidth"],eo=["AColumn","BColumn","CColumn","DColumn","EColumn"],vt="cutLabel",Pn=[...eo,vt],to=["A","B","C","D","E"];function Ai(e){return`${e}ColumnVerticalAlign`}const Xc=["Top","Center","Bottom"];function Zc(e){const t=String(e??"Top").trim();return t.toLowerCase().startsWith("baseline")?!1:t==="Top"||t==="Center"||t==="Bottom"}function Jc(e){const t=String(e??"").trim();if(!t.toLowerCase().startsWith("baseline"))return null;const n=t.slice(-1).toUpperCase();return to.includes(n)?n:null}function Ri(e,t,n){const r=Jc(e);return r?r===t?!1:Zc(n[Ai(r)]):!0}function Rr(e){const t=String(e??"Top").trim();if(t.toLowerCase().startsWith("baseline")){const n=t.slice(-1).toUpperCase();return to.includes(n)?{kind:"baseline",anchorLetter:n}:{kind:"top"}}return t==="Center"?{kind:"center"}:t==="Bottom"?{kind:"bottom"}:{kind:"top"}}function Qc(e,t,n){if(Ii(e,t,n))return Rr(e);const r=Rr(e);return r.kind==="baseline"?{kind:"top"}:r}function Ii(e,t,n){return Ri(e,n,t)?Rr(e).kind==="baseline":!1}function ed(e){if(e.type==="B")return null;const t={};let n=!1;for(const r of to){const o=Ai(r),s=e[o];Ri(s,r,e)||(t[o]="Top",n=!0)}return n?t:null}function td(e){return e==="center"?{marginTop:"auto",marginBottom:"auto"}:e==="bottom"?{marginTop:"auto"}:{}}function nd(e,t){const n=document.createElement("i");n.className=t,n.setAttribute("aria-hidden","true"),e.prepend(n);const{top:r}=e.getBoundingClientRect(),{bottom:o}=n.getBoundingClientRect(),s=o-r;return n.remove(),s}function br(e,t,n,r){const o=e.titleEl;if(!o)return 0;const s=o.closest(`.${n}`);if(!s)return 0;const i=nd(o,r);if(e.kind==="baseline")return o.getBoundingClientRect().top-t+i;const a=s.getBoundingClientRect(),c=o.getBoundingClientRect().height;let u=0;return e.kind==="center"?u=(a.height-c)/2:e.kind==="bottom"&&(u=a.height-c),a.top-t+u+i}function rd(e,t,n){const r=e.getBoundingClientRect().height;return r<=0?0:(t.forEach(o=>{const s=o.querySelector(`.${n}`);s&&(s.style.minHeight=`${r}px`,s.style.height=`${r}px`)}),e.offsetHeight,r)}function od(e,t){return!e||!t?(e&&(e.style.transform=""),0):(e.style.transform=`translateY(${t}px)`,t)}const id={AColumn:"AColumn",BColumnWidth:"BColumn",CColumnWidth:"CColumn",DColumnWidth:"DColumn",EColumnWidth:"EColumn"},ad=["textFontFamily","textFontSettings","textFontSize","textLineHeight","textLetterSpacing","textWordSpacing","textTextAppearance"];function we(e,t){return`${e}${t.replace(/^text/,"Text")}`}function Zn(e,t){const n=r=>{const o=we(t,r),s=e[o];return s!==void 0?s:e[r]};return{textFontFamily:n("textFontFamily")??"Arial",textFontSettings:n("textFontSettings")??{fontWeight:400,fontStyle:"normal"},textFontSize:n("textFontSize"),textLineHeight:n("textLineHeight"),textLetterSpacing:n("textLetterSpacing")??0,textWordSpacing:n("textWordSpacing")??0,textTextAppearance:n("textTextAppearance"),textColor:e.textColor}}function Ho(e,t){var r,o;const n={fontSettings:{fontFamily:e.textFontFamily,fontWeight:((r=e.textFontSettings)==null?void 0:r.fontWeight)??400,fontStyle:((o=e.textFontSettings)==null?void 0:o.fontStyle)??"normal"},fontSize:e.textFontSize??.01,lineHeight:e.textLineHeight,letterSpacing:e.textLetterSpacing,wordSpacing:e.textWordSpacing,textAppearance:e.textTextAppearance,color:e.textColor??"#767676"};return yt(Je(n,t))}function Oo(e,t,n,r){const o=Zn(e,t),s=o.textFontSize??.01,i=o.textLineHeight;return i!==void 0&&i<s?`${n} ${r}`:n}function Bo(e,t,n,r){const o=Zn(e,t),s=o.textFontSize??.01,i=o.textLineHeight;return i===void 0||i>=s?{}:{[`--${n}-title-leading-gap`]:T.scalingValue((s-i)/2,r)}}function sd(e,t){const n={};let r=!1;for(const o of ad)if(e[o]!==t[o]&&e[o]!==void 0){r=!0;for(const s of Pn)Object.assign(n,{[we(s,o)]:e[o]})}return r?n:null}const nt=["AColumnWidth","BColumnWidth","CColumnWidth","DColumnWidth","EColumnWidth"],Zt=["AColumnPaddingLeft","BColumnPaddingLeft","CColumnPaddingLeft","DColumnPaddingLeft","EColumnPaddingLeft"],Jt=["AColumnPaddingRight","BColumnPaddingRight","CColumnPaddingRight","DColumnPaddingRight","EColumnPaddingRight"],Qt=["AColumnPaddingBottom","BColumnPaddingBottom","CColumnPaddingBottom","DColumnPaddingBottom","EColumnPaddingBottom"],ld={textColor:"text-color",backgroundColor:"background-color",dividerColor:"divider-color",textHoverColor:"text-hover-color",backgroundHoverColor:"background-hover-color",dividerHoverColor:"divider-hover-color"},cd=["hover","focus","filled","success","error"],Vo=.004,ln=.004,no=50,bn=1440,xn=no/bn;function Wi(e){const t=typeof e=="number"&&e>0?e:bn;return no/t}function dd(e){let t=e??null;for(;t;){const n=t.style.getPropertyValue("--cntrl-article-width").trim();if(n){const o=parseFloat(n);if(Number.isFinite(o)&&o>0)return o}const r=getComputedStyle(t).getPropertyValue("--cntrl-article-width").trim();if(r){const o=parseFloat(r);if(Number.isFinite(o)&&o>0)return o}t=t.parentElement}return bn}const Fi={AColumnWidth:.02,BColumnWidth:.02,CColumnWidth:.02,DColumnWidth:.02,EColumnWidth:.02};function jn(e){const t=typeof e.wrapperWidth=="number"?e.wrapperWidth:1;return Math.max(0,t)}function ud(e,t=1){const n=t/e;return Object.fromEntries(nt.map(r=>[r,n]))}function pd(){return Object.fromEntries([...Zt.map(e=>[e,0]),...Jt.map(e=>[e,0])])}function md(){return Object.fromEntries(Qt.map(e=>[e,0]))}function Nn(e){return Object.fromEntries(nt.map(t=>[t,typeof e[t]=="number"?e[t]:Fi[t]]))}function ki(e,t,n){const r=e-xn,o=t+n;if(o<=0||o<=r)return{paddingLeft:t,paddingRight:n};if(r<=0)return{paddingLeft:0,paddingRight:0};const s=r/o;return{paddingLeft:t*s,paddingRight:n*s}}function Kn(e,t,n){const r=ro(e,t,n);if(e<=0)return[];const o=r.slice(0,e-1).reduce((s,i)=>s+i,0);return[...r.slice(0,e-1),Math.max(0,t-o)]}function gd(e,t,n){const r={};for(let o=0;o<e;o+=1){const s=Zt[o],i=Jt[o],a=typeof n[s]=="number"?n[s]:0,c=typeof n[i]=="number"?n[i]:0,u=ki(t[o]??0,a,c);u.paddingLeft!==a&&(r[s]=u.paddingLeft),u.paddingRight!==c&&(r[i]=u.paddingRight)}return r}function ro(e,t,n){if(e<=0)return[];const r=nt.slice(0,e).map(u=>n[u]);if(e===1)return r;const o=r.slice(0,e-1),i=o.reduce((u,d)=>u+d,0)+xn;if(t>=i)return r;const a=[...o];let c=i-t;for(let u=a.length-1;u>=0&&c>0;u-=1){const d=a[u]-xn;if(d<=0)continue;const $=Math.min(c,d);a[u]-=$,c-=$}return[...a,r[e-1]]}function hd(e,t,n){if(e<=1)return{};const r=ro(e,t,n),o={};for(let s=0;s<e-1;s+=1){const i=nt[s];r[s]!==n[i]&&(o[i]=r[s])}return o}function Do(e){return Array.isArray(e.columnsOrder)&&e.columnsOrder.length>0?e.columnsOrder:[...Pt]}function fd(e,t){return e.length!==t.length?!1:e.every((n,r)=>n===t[r])}function yd(e,t,n,r){const o=Math.min(r,e.length,nt.length),s={};for(let i=0;i<o;i+=1){const a=e[i],c=t.indexOf(a);if(c===-1)continue;const u=nt[c],d=Zt[c],$=Jt[c],h=Qt[c],f=nt[i],m=Zt[i],g=Jt[i],C=Qt[i],y=n[u],x=n[d],P=n[$],L=n[h];typeof y=="number"&&(s[f]=y),typeof x=="number"&&(s[m]=x),typeof P=="number"&&(s[g]=P),typeof L=="number"&&(s[C]=L)}return s}function vd(e,t,n){const r=sd(e,t);r&&(e={...e,...r});const o=ed(e);o&&(e={...e,...o});const s=Wi(n==null?void 0:n.designWidth),i=e.columns,a=t.columns,c=jn(e),u=jn(t),d=e.type==="B"||e.type===void 0&&t.type==="B",$=typeof i=="number"?i:typeof a=="number"?a:Pt.length,h=L=>{if(d)return L;const _=Nn({...t,...L}),E=jn(L),v=Kn($,E,_),S=gd($,v,{...t,...L});return Object.keys(S).length===0?L:{...L,...S}};if(typeof i=="number"&&i!==a){const L={...e,...ud(i,c),...pd()};if(d)for(const _ of Qt)typeof t[_]=="number"&&(L[_]=t[_]);else Object.assign(L,md());return L}const f=Do(e),m=Do(t);if(!fd(f,m))return h({...e,...yd(f,m,t,$)});if(c<u&&typeof $=="number"&&!d){const L=Nn({...t,...e});return h({...e,...hd($,c,L)})}if(d){const L=typeof e.textPaddingLR=="number"?e.textPaddingLR:0,_=Math.max(0,(c-s)/2);return L>_?{...e,textPaddingLR:_}:e}const g=Nn({...t,...e}),C=Kn($,u,Nn(t)),x=Kn($,c,g).some((L,_)=>L<(C[_]??L)),P=nt.some(L=>{const _=e[L],E=t[L];return typeof _=="number"&&typeof E=="number"&&_!==E});return x||P?h(e):e}function bd(e,t,n,r){const o=t.slice(0,e).reduce((i,a)=>i+a,0),s=n.slice(e+1,t.length-1).reduce((i,a)=>i+a,0);return Math.max(xn,r-o-s-xn)}function xd(e,t){return Math.random()*(t-e)+e}function Cd(e){return Object.fromEntries(nt.map(t=>[t,typeof e[t]=="number"?e[t]:Fi[t]]))}function xr(e,t,n=0){return Object.fromEntries(t.map(r=>[r,typeof e[r]=="number"?e[r]:n]))}function Sd(e,t,n,r,o,s){return e.slice(0,t).map((i,a)=>{const c=Zt[a],u=Jt[a],d=Qt[a];return{key:i,textPrefix:id[i],widthKey:nt[a],width:n[nt[a]],paddingLeftKey:c,paddingRightKey:u,paddingBottomKey:d,paddingLeft:r[c],paddingRight:o[u],paddingBottom:s[d]}})}function wd({settings:e,content:t,isEditor:n,isPreviewMode:r,activeEvent:o,layoutId:s,onUpdateSettings:i}){const{prefix:a}=T.useScopedStyles(),c=!!(n&&r),{columns:u,type:d,wrapperWidth:$,entriesCount:h,cellMinHeight:f,dividerWidth:m,showVisibility:g,cut:C,showCut:y,cutCellMinHeight:x,cutLabel:P,imageSize:L,imageOnHover:_,entryHoverEffect:E,rowPaddingTop:v,rowPaddingBottom:S,rowPaddingTopB:F,columnsOrder:V,textPaddingLR:A,textColor:O,textFontFamily:D,textFontSettings:j,textFontSize:U,textLineHeight:w,textLetterSpacing:N,textWordSpacing:k,textTextAppearance:M,backgroundColor:R,dividerColor:B,textHoverColor:te,backgroundHoverColor:ue,dividerHoverColor:ie}=e,[me,H]=p.useState(void 0),[Q,G]=p.useState(null),Y=_==="On",oe=(C??0)>0,W=d==="B",ne=p.useRef(null),[I,b]=p.useState(bn),z=Wi(I),q=Math.max(0,(($??0)-z)/2),J=Math.min(A??0,q),se=Math.max(J,ln),le=(($??0)+z)/2;p.useLayoutEffect(()=>{if(!n){b(bn);return}const ge=()=>{b(dd(ne.current))};ge();const xe=ne.current;if(!xe)return;const Se=new ResizeObserver(ge);Se.observe(xe);let Re=xe;for(;Re&&!Re.style.getPropertyValue("--cntrl-article-width");)Re=Re.parentElement;return Re&&Se.observe(Re),()=>Se.disconnect()},[n,s]),p.useEffect(()=>{H(void 0)},[C,y,t,h]);const ce=T.buildColorVars(a,{textColor:O,backgroundColor:R,dividerColor:B,textHoverColor:te,backgroundHoverColor:ue,dividerHoverColor:ie},ld,cd),he=o&&o!=="default"?`${a}-state-${o}`:"",ee=`${E==="Default"?`${a}-entry-hover-default`:E==="Blinds"?`${a}-entry-hover-blinds`:""} ${he}`.trim(),Z=(g==null?void 0:g[0])??!1,de=(g==null?void 0:g[1])??!1,re=p.useRef(e),pe=p.useRef(s);p.useEffect(()=>{if(!i||!n){re.current=e,pe.current=s;return}if(pe.current!==s){re.current=e,pe.current=s;return}const ge=re.current,xe=vd(e,ge,{designWidth:I});re.current=e,xe!==e&&i(xe)},[e,i,n,s,I]);const ve=p.useMemo(()=>Cd(e),[e.AColumnWidth,e.BColumnWidth,e.CColumnWidth,e.DColumnWidth,e.EColumnWidth]),Pe=p.useMemo(()=>xr(e,Zt),[e.AColumnPaddingLeft,e.BColumnPaddingLeft,e.CColumnPaddingLeft,e.DColumnPaddingLeft,e.EColumnPaddingLeft]),Ke=p.useMemo(()=>xr(e,Jt),[e.AColumnPaddingRight,e.BColumnPaddingRight,e.CColumnPaddingRight,e.DColumnPaddingRight,e.EColumnPaddingRight]),Ge=p.useMemo(()=>xr(e,Qt),[e.AColumnPaddingBottom,e.BColumnPaddingBottom,e.CColumnPaddingBottom,e.DColumnPaddingBottom,e.EColumnPaddingBottom]),$e=p.useMemo(()=>Array.isArray(V)&&V.length>0?V:[...Pt],[V]),Ae=p.useMemo(()=>Sd($e,u,ve,Pe,Ke,Ge),[$e,u,ve,Pe,Ke,Ge]),Me=jn(e),Ie=p.useMemo(()=>nt.slice(0,u).map(ge=>ve[ge]),[u,ve]),Ve=p.useMemo(()=>ro(u,Me,ve),[u,Me,ve]),ye=p.useMemo(()=>Kn(u,Me,ve),[u,Me,ve]),ke=p.useMemo(()=>Ae.map((ge,xe)=>ki(ye[xe]??0,ge.paddingLeft,ge.paddingRight)),[Ae,ye]),He=p.useMemo(()=>{const ge=h===0?1/0:h;return(t??[]).slice(0,ge).map((Se,Re)=>({id:Re,cells:Object.fromEntries(Pt.map(Xe=>[Xe,Se[Xe]??""])),image:Se.image,link:Se.link}))},[t,h]),Oe=oe?me??C:He.length,De=p.useMemo(()=>oe?He.slice(0,Oe):He,[He,oe,Oe]),Qe=oe&&Oe<He.length,Ct=De.length>1||Qe,lt=[Z?`${a}-divider-top`:"",de||Ct?`${a}-divider-bottom`:""].filter(Boolean).join(" "),dr=()=>{const ge=me??C;if(!y){H(He.length);return}H(Math.min(ge+y,He.length))},Ee=ge=>T.scalingValue(ge,n??!1),An=W?F??0:v??0,rn=S??0,on=f??0,ur=W?"rowPaddingTopB":"rowPaddingTop",be=Ae[0],Ye=Ae[Ae.length-1],ze=ke[0],Ne=ke[ke.length-1],St=be&&ze?Math.max(ze.paddingLeft,ln):0,oo=Ye&&Ne?Math.max(Ne.paddingRight,ln):0,Ni=Me,io=ge=>{const xe=ne.current;if(!xe)return{x:0,y:0};const Se=xe.getBoundingClientRect();return{x:ge.clientX-Se.left+No,y:ge.clientY-Se.top+No}},Hi=(ge,xe)=>{if(!Y)return;const Se=ge.image;if(!(Se!=null&&Se.url)){G(null);return}const{x:Re,y:Xe}=io(xe),ct=(L==null?void 0:L.min)??80,Te=(L==null?void 0:L.max)??320,Be=(Q==null?void 0:Q.rowId)===ge.id?Q.widthPx:xd(ct,Te);G({rowId:ge.id,url:Se.url,objectFit:Se.objectFit??"cover",widthPx:Be,x:Re,y:Xe})},Oi=ge=>{if(!Y||!Q)return;const{x:xe,y:Se}=io(ge);G(Re=>!Re||Re.x===xe&&Re.y===Se?Re:{...Re,x:xe,y:Se})},Bi=()=>{G(null)},ao=p.useMemo(()=>!W&&eo.some(ge=>{const xe=ge.charAt(0),Se=e[`${ge}VerticalAlign`];return Ii(Se,e,xe)}),[W,e,e.AColumnVerticalAlign,e.BColumnVerticalAlign,e.CColumnVerticalAlign,e.DColumnVerticalAlign,e.EColumnVerticalAlign]);return p.useLayoutEffect(()=>{var ct;const ge=ne.current;if(!ge)return;const xe=()=>{ge.querySelectorAll("[data-list-col]").forEach(Te=>{Te.style.transform="";const Be=Te.querySelector(`.${a}-list-col`);Be&&(Be.style.minHeight="",Be.style.height="");const ot=Te.querySelector(`.${a}-list-col-title`);ot&&(ot.style.transform="")})};if(W||!ao){xe();return}const Se=()=>{ge.querySelectorAll("[data-list-row]").forEach(Te=>{const Be=Array.from(Te.querySelectorAll("[data-list-col]"));Be.forEach(Le=>{Le.style.transform="";const Ze=Le.querySelector(`.${a}-list-col`);Ze&&(Ze.style.minHeight="",Ze.style.height="");const Ue=Le.querySelector(`.${a}-list-col-title`);Ue&&(Ue.style.transform="")}),rd(Te,Be,`${a}-list-col`),Te.offsetHeight;const ot=Te.getBoundingClientRect().top,wt=`${a}-baseline-probe`,Wt=new Map,an=Be.map(Le=>{const Ze=Le.querySelector(`.${a}-list-col-title`),Ue={el:Le,titleEl:Ze,letter:Le.getAttribute("data-col-letter")??"",kind:Le.getAttribute("data-valign")??"top",anchor:Le.getAttribute("data-valign-anchor")};return Wt.set(Ue.letter,Ue),Ue}),sn=new Map,Rn=(Le,Ze)=>{const Ue=sn.get(Le.letter);if(Ue!==void 0)return Ue;const so=Le.anchor?Wt.get(Le.anchor):void 0;if(Le.kind!=="baseline"||!so||Ze.has(Le.letter)){const co=br(Le,ot,`${a}-list-col`,wt);return sn.set(Le.letter,co),co}Ze.add(Le.letter);const Vi=Rn(so,Ze);Ze.delete(Le.letter);const Di=br(Le,ot,`${a}-list-col`,wt),zi=Vi-Di;od(Le.titleEl,zi);const lo=br(Le,ot,`${a}-list-col`,wt);return sn.set(Le.letter,lo),lo};an.forEach(Le=>Rn(Le,new Set))})};Se();const Re=new ResizeObserver(()=>Se());Re.observe(ge);let Xe=!1;return typeof document<"u"&&((ct=document.fonts)!=null&&ct.ready)&&document.fonts.ready.then(()=>{Xe||Se()}),()=>{Xe=!0,Re.disconnect(),xe()}},[ao,W,e,t,I,De,ye]),l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:Yc(a)}}),l.jsx("div",{style:ce,children:l.jsxs("div",{ref:ne,className:`${a}-wrapper ${ee}${lt?` ${lt}`:""}${W?` ${a}-type-b`:""}`.trim(),style:{width:T.scalingValue($??0,n)},onMouseMove:Y?Oi:void 0,onMouseLeave:Y?Bi:void 0,children:[l.jsxs("div",{style:{width:"100%"},children:[De.map((ge,xe)=>{var ct;const Se=(((ct=ge.link)==null?void 0:ct.length)??0)>0,Re=Se?"a":"div",Xe=qc(xe,De.length,Z,de,Qe,m??0,n??!1);return l.jsxs(Re,{className:`${a}-list-item${Se?` ${a}-list-item-has-link`:""}`,...Se?{href:ge.link,target:"_blank"}:{},style:Xe,onMouseEnter:Y?Te=>Hi(ge,Te):void 0,children:[(An>0||c)&&l.jsx("div",{...c?{"data-controls":ur,"data-controls-axis":"y","data-controls-min":"0"}:{},className:`${a}-row-padding-handle`,style:{height:Ee(An)}}),l.jsx("div",{className:`${a}-list-cols-row${W?"":` ${a}-list-cols-row-h`}`,...W?{}:{"data-list-row":""},style:W?void 0:{minHeight:Ee(on)},children:Ae.map((Te,Be)=>{const ot=Be===Ae.length-1,wt=ke[Be],Wt=Te.paddingBottom,an=Uc(ge.cells[Te.key]),sn=W&&an&&(Wt>0||c),Rn=W?{minHeight:Ee(on)}:ot?{}:{width:Ee(ye[Be])},Le=W?{paddingLeft:Ee(J),paddingRight:Ee(J)}:{paddingLeft:Ee(wt.paddingLeft),paddingRight:Ee(wt.paddingRight)},Ze=Te.textPrefix.charAt(0),Ue=W?{kind:"top"}:Qc(e[`${Te.textPrefix}VerticalAlign`],e,Ze);return l.jsxs("div",{...W?{}:{"data-list-col":"","data-col-letter":Ze,"data-valign":Ue.kind,...Ue.kind==="baseline"?{"data-valign-anchor":Ue.anchorLetter}:{}},children:[l.jsx("div",{className:`${a}-list-col${ot?` ${a}-list-col-last`:""}`,style:{...Le,...Rn},"data-test":Te.width,children:l.jsx("span",{className:Oo(e,Te.textPrefix,`${a}-list-col-title`,`${a}-text-tight-leading`),style:{...Ho(Zn(e,Te.textPrefix),n),...Bo(e,Te.textPrefix,a,n),...W?{}:td(Ue.kind)},children:ge.cells[Te.key]??null})}),sn&&l.jsx("div",{...c?{"data-controls":Te.paddingBottomKey,"data-controls-axis":"y","data-controls-min":"0"}:{},className:`${a}-row-padding-handle`,style:{height:Ee(Wt)}})]},Te.key)})}),!W&&(rn>0||c)&&l.jsx("div",{...c?{"data-controls":"rowPaddingBottom","data-controls-axis":"y","data-controls-min":"0"}:{},className:`${a}-row-padding-handle`,style:{height:Ee(rn)}})]},ge.id)}),Qe&&l.jsx("button",{type:"button",className:`${a}-cut-item`,style:{minHeight:Ee(x??0),...Gc(de,m??0,n??!1)},onClick:dr,children:l.jsx("div",{className:`${a}-list-cols-row`,style:W?{paddingLeft:Ee(J),paddingRight:Ee(J)}:{justifyContent:"center"},children:l.jsx("span",{className:Oo(e,vt,`${a}-cut-label`,`${a}-text-tight-leading`),style:{...Ho(Zn(e,vt),n),...Bo(e,vt,a,n)},children:P})})})]}),c&&!W&&be&&Ye&&l.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[l.jsx("div",{"data-controls":be.paddingLeftKey,"data-controls-axis":"x","data-controls-variant":"column-padding","data-controls-min":"0","data-controls-max-fraction":String(ye[0]-((ze==null?void 0:ze.paddingRight)??0)),"data-controls-static-handle":"",className:`${a}-padding-control-handle`,style:{position:"absolute",top:0,left:0,width:Ee(St),height:"100%",pointerEvents:"auto",zIndex:2}}),l.jsx("div",{"data-controls":Ye.paddingRightKey,"data-controls-axis":"x","data-controls-variant":"column-padding","data-controls-reverse":"","data-controls-min":"0","data-controls-max-fraction":String(ye[Ae.length-1]-((Ne==null?void 0:Ne.paddingLeft)??0)),"data-controls-static-handle":"",className:`${a}-padding-control-handle`,style:{position:"absolute",top:0,left:Ee(Ni-oo),width:Ee(oo),height:"100%",pointerEvents:"auto",zIndex:2}})]},"column-edge-padding-handles"),c&&!W&&Ae.slice(0,-1).map((ge,xe)=>{const Se=Ae[xe+1],Re=bd(xe,Ve,Ie,Me),Xe=Ve.slice(0,xe+1).reduce((Wt,an)=>Wt+an,0),ct=ke[xe],Te=ke[xe+1],Be=Math.max(ct.paddingRight,ln),ot=Math.max(Te.paddingLeft,ln),wt=Xe-Vo/2;return l.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[l.jsx("div",{"data-controls":ge.paddingRightKey,"data-controls-axis":"x","data-controls-variant":"column-padding","data-controls-reverse":"","data-controls-min":"0","data-controls-max-fraction":String(ye[xe]-ct.paddingLeft),"data-controls-static-handle":"",className:`${a}-padding-control-handle`,style:{position:"absolute",top:0,left:Ee(Xe-Be),width:Ee(Be),height:"100%",pointerEvents:"auto",zIndex:2}}),l.jsx("div",{"data-controls":ge.widthKey,"data-controls-axis":"x","data-controls-min":String(no),"data-controls-max-fraction":String(Re),"data-controls-variant":"column-width",className:`${a}-col-resize-handle`,style:{position:"absolute",top:"0px",left:Ee(wt),width:Ee(Vo),height:"calc(100%)",pointerEvents:"auto",zIndex:4}}),l.jsx("div",{"data-controls":Se.paddingLeftKey,"data-controls-axis":"x","data-controls-variant":"column-padding","data-controls-min":"0","data-controls-max-fraction":String(ye[xe+1]-Te.paddingRight),"data-controls-static-handle":"",className:`${a}-padding-control-handle`,style:{position:"absolute",top:0,left:Ee(Xe),width:Ee(ot),height:"100%",pointerEvents:"auto",zIndex:2}})]},`${ge.widthKey}-junction`)}),c&&W&&l.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[l.jsx("div",{"data-controls":"textPaddingLR","data-controls-paired":"","data-controls-axis":"x","data-controls-min":"0","data-controls-max-fraction":String(le),"data-controls-static-handle":"",className:`${a}-text-padding-lr-handle`,style:{position:"absolute",top:0,left:0,width:Ee(se),height:"100%",pointerEvents:"auto",zIndex:2}}),l.jsx("div",{"data-controls":"textPaddingLR","data-controls-paired":"","data-controls-axis":"x","data-controls-reverse":"","data-controls-min":"0","data-controls-max-fraction":String(le),"data-controls-static-handle":"",className:`${a}-text-padding-lr-handle`,style:{position:"absolute",top:0,left:Ee(Math.max(se,Me-se)),width:Ee(se),height:"100%",pointerEvents:"auto",zIndex:2}})]},"text-padding-lr-handles"),Y&&Q&&l.jsx("img",{className:`${a}-hover-image`,src:Q.url,alt:"",style:{width:zn(Q.widthPx),objectFit:Q.objectFit,left:Q.x,top:Q.y}})]})})]})}const $d=`import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\r
|
|
4666
|
-
import { CommonComponentProps } from '../props'
|
|
4667
|
-
import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index'
|
|
4668
|
-
import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss'
|
|
4669
|
-
|
|
4670
|
-
type ListFontSettings = { fontWeight: number; fontStyle: string }
|
|
4671
|
-
|
|
4672
|
-
type ListColumnPrefix = 'AColumn' | 'BColumn' | 'CColumn' | 'DColumn' | 'EColumn'
|
|
4673
|
-
|
|
4674
|
-
type ListColumnTextStyleOverrides = {
|
|
4675
|
-
AColumnVerticalAlign?: string
|
|
4676
|
-
AColumnTextFontFamily?: string
|
|
4677
|
-
AColumnTextFontSettings?: ListFontSettings
|
|
4678
|
-
AColumnTextFontSize?: number
|
|
4679
|
-
AColumnTextLineHeight?: number
|
|
4680
|
-
AColumnTextLetterSpacing?: number
|
|
4681
|
-
AColumnTextWordSpacing?: number
|
|
4682
|
-
AColumnTextTextAppearance?: TextStyles['textAppearance']
|
|
4683
|
-
BColumnVerticalAlign?: string
|
|
4684
|
-
BColumnTextFontFamily?: string
|
|
4685
|
-
BColumnTextFontSettings?: ListFontSettings
|
|
4686
|
-
BColumnTextFontSize?: number
|
|
4687
|
-
BColumnTextLineHeight?: number
|
|
4688
|
-
BColumnTextLetterSpacing?: number
|
|
4689
|
-
BColumnTextWordSpacing?: number
|
|
4690
|
-
BColumnTextTextAppearance?: TextStyles['textAppearance']
|
|
4691
|
-
CColumnVerticalAlign?: string
|
|
4692
|
-
CColumnTextFontFamily?: string
|
|
4693
|
-
CColumnTextFontSettings?: ListFontSettings
|
|
4694
|
-
CColumnTextFontSize?: number
|
|
4695
|
-
CColumnTextLineHeight?: number
|
|
4696
|
-
CColumnTextLetterSpacing?: number
|
|
4697
|
-
CColumnTextWordSpacing?: number
|
|
4698
|
-
CColumnTextTextAppearance?: TextStyles['textAppearance']
|
|
4699
|
-
DColumnVerticalAlign?: string
|
|
4700
|
-
DColumnTextFontFamily?: string
|
|
4701
|
-
DColumnTextFontSettings?: ListFontSettings
|
|
4702
|
-
DColumnTextFontSize?: number
|
|
4703
|
-
DColumnTextLineHeight?: number
|
|
4704
|
-
DColumnTextLetterSpacing?: number
|
|
4705
|
-
DColumnTextWordSpacing?: number
|
|
4706
|
-
DColumnTextTextAppearance?: TextStyles['textAppearance']
|
|
4707
|
-
EColumnVerticalAlign?: string
|
|
4708
|
-
EColumnTextFontFamily?: string
|
|
4709
|
-
EColumnTextFontSettings?: ListFontSettings
|
|
4710
|
-
EColumnTextFontSize?: number
|
|
4711
|
-
EColumnTextLineHeight?: number
|
|
4712
|
-
EColumnTextLetterSpacing?: number
|
|
4713
|
-
EColumnTextWordSpacing?: number
|
|
4714
|
-
EColumnTextTextAppearance?: TextStyles['textAppearance']
|
|
4715
|
-
cutLabelTextFontFamily?: string
|
|
4716
|
-
cutLabelTextFontSettings?: ListFontSettings
|
|
4717
|
-
cutLabelTextFontSize?: number
|
|
4718
|
-
cutLabelTextLineHeight?: number
|
|
4719
|
-
cutLabelTextLetterSpacing?: number
|
|
4720
|
-
cutLabelTextWordSpacing?: number
|
|
4721
|
-
cutLabelTextTextAppearance?: TextStyles['textAppearance']
|
|
4722
|
-
}
|
|
4723
|
-
|
|
4724
|
-
export type ListColumnVerticalAlignKey = \`\${ListColumnPrefix}VerticalAlign
|
|
4725
|
-
|
|
4726
|
-
type ListColumnVerticalAlignUpdates = {
|
|
4727
|
-
AColumnVerticalAlign?: string
|
|
4728
|
-
BColumnVerticalAlign?: string
|
|
4729
|
-
CColumnVerticalAlign?: string
|
|
4730
|
-
DColumnVerticalAlign?: string
|
|
4731
|
-
EColumnVerticalAlign?: string
|
|
4732
|
-
}
|
|
4733
|
-
|
|
4734
|
-
type ListColumnTextStyleSyncUpdates = {
|
|
4735
|
-
AColumnTextFontFamily?: string
|
|
4736
|
-
AColumnTextFontSettings?: ListFontSettings
|
|
4737
|
-
AColumnTextFontSize?: number
|
|
4738
|
-
AColumnTextLineHeight?: number
|
|
4739
|
-
AColumnTextLetterSpacing?: number
|
|
4740
|
-
AColumnTextWordSpacing?: number
|
|
4741
|
-
AColumnTextTextAppearance?: TextStyles['textAppearance']
|
|
4742
|
-
BColumnTextFontFamily?: string
|
|
4743
|
-
BColumnTextFontSettings?: ListFontSettings
|
|
4744
|
-
BColumnTextFontSize?: number
|
|
4745
|
-
BColumnTextLineHeight?: number
|
|
4746
|
-
BColumnTextLetterSpacing?: number
|
|
4747
|
-
BColumnTextWordSpacing?: number
|
|
4748
|
-
BColumnTextTextAppearance?: TextStyles['textAppearance']
|
|
4749
|
-
CColumnTextFontFamily?: string
|
|
4750
|
-
CColumnTextFontSettings?: ListFontSettings
|
|
4751
|
-
CColumnTextFontSize?: number
|
|
4752
|
-
CColumnTextLineHeight?: number
|
|
4753
|
-
CColumnTextLetterSpacing?: number
|
|
4754
|
-
CColumnTextWordSpacing?: number
|
|
4755
|
-
CColumnTextTextAppearance?: TextStyles['textAppearance']
|
|
4756
|
-
DColumnTextFontFamily?: string
|
|
4757
|
-
DColumnTextFontSettings?: ListFontSettings
|
|
4758
|
-
DColumnTextFontSize?: number
|
|
4759
|
-
DColumnTextLineHeight?: number
|
|
4760
|
-
DColumnTextLetterSpacing?: number
|
|
4761
|
-
DColumnTextWordSpacing?: number
|
|
4762
|
-
DColumnTextTextAppearance?: TextStyles['textAppearance']
|
|
4763
|
-
EColumnTextFontFamily?: string
|
|
4764
|
-
EColumnTextFontSettings?: ListFontSettings
|
|
4765
|
-
EColumnTextFontSize?: number
|
|
4766
|
-
EColumnTextLineHeight?: number
|
|
4767
|
-
EColumnTextLetterSpacing?: number
|
|
4768
|
-
EColumnTextWordSpacing?: number
|
|
4769
|
-
EColumnTextTextAppearance?: TextStyles['textAppearance']
|
|
4770
|
-
cutLabelTextFontFamily?: string
|
|
4771
|
-
cutLabelTextFontSettings?: ListFontSettings
|
|
4772
|
-
cutLabelTextFontSize?: number
|
|
4773
|
-
cutLabelTextLineHeight?: number
|
|
4774
|
-
cutLabelTextLetterSpacing?: number
|
|
4775
|
-
cutLabelTextWordSpacing?: number
|
|
4776
|
-
cutLabelTextTextAppearance?: TextStyles['textAppearance']
|
|
4777
|
-
}
|
|
4778
|
-
|
|
4779
|
-
export type ListSettings = {
|
|
4780
|
-
columns: number
|
|
4781
|
-
type: 'A' | 'B'
|
|
4782
|
-
wrapperWidth: number
|
|
4783
|
-
entriesCount: number
|
|
4784
|
-
cellMinHeight: number
|
|
4785
|
-
imageOnHover: 'On' | 'Off'
|
|
4786
|
-
imageSize?: { min: number; max: number }
|
|
4787
|
-
dividerWidth: number
|
|
4788
|
-
showVisibility: boolean[]
|
|
4789
|
-
cut: number
|
|
4790
|
-
showCut: number
|
|
4791
|
-
cutCellMinHeight: number
|
|
4792
|
-
cutLabel: string
|
|
4793
|
-
entryHoverEffect: 'None' | 'Default' | 'Blinds'
|
|
4794
|
-
rowPaddingTop: number
|
|
4795
|
-
rowPaddingBottom: number
|
|
4796
|
-
rowPaddingTopB: number
|
|
4797
|
-
AColumnWidth: number
|
|
4798
|
-
AColumnPaddingLeft: number
|
|
4799
|
-
AColumnPaddingRight: number
|
|
4800
|
-
AColumnPaddingBottom: number
|
|
4801
|
-
BColumnWidth: number
|
|
4802
|
-
BColumnPaddingLeft: number
|
|
4803
|
-
BColumnPaddingRight: number
|
|
4804
|
-
BColumnPaddingBottom: number
|
|
4805
|
-
CColumnWidth: number
|
|
4806
|
-
CColumnPaddingLeft: number
|
|
4807
|
-
CColumnPaddingRight: number
|
|
4808
|
-
CColumnPaddingBottom: number
|
|
4809
|
-
DColumnWidth: number
|
|
4810
|
-
DColumnPaddingLeft: number
|
|
4811
|
-
DColumnPaddingRight: number
|
|
4812
|
-
DColumnPaddingBottom: number
|
|
4813
|
-
EColumnWidth: number
|
|
4814
|
-
EColumnPaddingLeft: number
|
|
4815
|
-
EColumnPaddingRight: number
|
|
4816
|
-
EColumnPaddingBottom: number
|
|
4817
|
-
columnsOrder?: string[]
|
|
4818
|
-
textPaddingLR?: number
|
|
4819
|
-
textColor: string
|
|
4820
|
-
textFontFamily: string
|
|
4821
|
-
textFontSettings?: ListFontSettings
|
|
4822
|
-
textFontSize?: number
|
|
4823
|
-
textLineHeight?: number
|
|
4824
|
-
textLetterSpacing?: number
|
|
4825
|
-
textWordSpacing?: number
|
|
4826
|
-
textTextAppearance?: TextStyles['textAppearance']
|
|
4827
|
-
backgroundColor: string
|
|
4828
|
-
dividerColor: string
|
|
4829
|
-
textHoverColor: string
|
|
4830
|
-
backgroundHoverColor: string
|
|
4831
|
-
dividerHoverColor: string
|
|
4832
|
-
} & ListColumnTextStyleOverrides
|
|
4833
|
-
|
|
4834
|
-
type ListContentItem = {
|
|
4835
|
-
AColumn?: string
|
|
4836
|
-
BColumnWidth?: string
|
|
4837
|
-
CColumnWidth?: string
|
|
4838
|
-
DColumnWidth?: string
|
|
4839
|
-
EColumnWidth?: string
|
|
4840
|
-
image?: {
|
|
4841
|
-
objectFit?: 'cover' | 'contain'
|
|
4842
|
-
url: string
|
|
4843
|
-
name: string
|
|
4844
|
-
}
|
|
4845
|
-
link?: string
|
|
4846
|
-
}
|
|
4847
|
-
|
|
4848
|
-
type ListItemRow = {
|
|
4849
|
-
id: string | number
|
|
4850
|
-
cells: Record<string, React.ReactNode
|
|
4851
|
-
image?: ListContentItem['image']
|
|
4852
|
-
link?: string
|
|
4853
|
-
}
|
|
4854
|
-
|
|
4855
|
-
type HoverImageState = {
|
|
4856
|
-
rowId: string | number
|
|
4857
|
-
url: string
|
|
4858
|
-
objectFit: 'cover' | 'contain'
|
|
4859
|
-
widthPx: number
|
|
4860
|
-
x: number
|
|
4861
|
-
y: number
|
|
4862
|
-
}
|
|
4863
|
-
|
|
4864
|
-
type ListProps = {
|
|
4865
|
-
layoutId?: string
|
|
4866
|
-
settings: ListSettings
|
|
4867
|
-
content?: ListContentItem[]
|
|
4868
|
-
isEditor?: boolean
|
|
4869
|
-
isPreviewMode?: boolean
|
|
4870
|
-
activeEvent: string | undefined
|
|
4871
|
-
onUpdateSettings?: (settings: ListSettings) => void
|
|
4872
|
-
} & CommonComponentProps
|
|
4873
|
-
|
|
4874
|
-
function sv(px: number): string {
|
|
4875
|
-
return \`calc(var(--cntrl-article-width, 100vw) * \${px / 1440})
|
|
4876
|
-
}
|
|
4877
|
-
|
|
4878
|
-
function hasListColumnText(value: React.ReactNode): boolean {
|
|
4879
|
-
return String(value ?? '').trim().length > 0
|
|
4880
|
-
}
|
|
4881
|
-
|
|
4882
|
-
function getEntryDividerWidths(
|
|
4883
|
-
rowIdx: number
|
|
4884
|
-
rowCount: number
|
|
4885
|
-
showDividerTop: boolean
|
|
4886
|
-
showDividerBottom: boolean
|
|
4887
|
-
hasCutItem: boolean
|
|
4888
|
-
dividerWidth: number
|
|
4889
|
-
isEditor: boolean
|
|
4890
|
-
): { borderTopWidth: string; borderBottomWidth: string } {
|
|
4891
|
-
const scaledDividerWidth = scalingValue(dividerWidth, isEditor)
|
|
4892
|
-
const none = scalingValue(0, isEditor)
|
|
4893
|
-
|
|
4894
|
-
const isFirst = rowIdx === 0
|
|
4895
|
-
const isLastEntry = rowIdx === rowCount - 1 && !hasCutItem
|
|
4896
|
-
|
|
4897
|
-
const borderTopWidth = isFirst && showDividerTop ? scaledDividerWidth : none
|
|
4898
|
-
const borderBottomWidth = !isLastEntry || showDividerBottom ? scaledDividerWidth : none
|
|
4899
|
-
|
|
4900
|
-
return { borderTopWidth, borderBottomWidth }
|
|
4901
|
-
}
|
|
4902
|
-
|
|
4903
|
-
function getCutItemDividerWidths(
|
|
4904
|
-
showDividerBottom: boolean
|
|
4905
|
-
dividerWidth: number
|
|
4906
|
-
isEditor: boolean
|
|
4907
|
-
): { borderTopWidth: string; borderBottomWidth: string } {
|
|
4908
|
-
const scaledDividerWidth = scalingValue(dividerWidth, isEditor)
|
|
4909
|
-
const none = scalingValue(0, isEditor)
|
|
4910
|
-
|
|
4911
|
-
return {
|
|
4912
|
-
borderTopWidth: none
|
|
4913
|
-
borderBottomWidth: showDividerBottom ? scaledDividerWidth : none
|
|
4914
|
-
}
|
|
4915
|
-
}
|
|
4916
|
-
|
|
4917
|
-
const HOVER_IMAGE_CURSOR_OFFSET = 10
|
|
4918
|
-
|
|
4919
|
-
function getCSS(P: string): string {
|
|
4920
|
-
return
|
|
4921
|
-
.\${P}-wrapper {
|
|
4922
|
-
display: grid
|
|
4923
|
-
align-items: start
|
|
4924
|
-
min-height: \${sv(48)}
|
|
4925
|
-
position: relative
|
|
4926
|
-
overflow: visible
|
|
4927
|
-
box-sizing: border-box
|
|
4928
|
-
}
|
|
4929
|
-
|
|
4930
|
-
.\${P}-hover-image {
|
|
4931
|
-
position: absolute
|
|
4932
|
-
left: 0
|
|
4933
|
-
top: 0
|
|
4934
|
-
z-index: 10
|
|
4935
|
-
pointer-events: none
|
|
4936
|
-
display: block
|
|
4937
|
-
height: auto
|
|
4938
|
-
}
|
|
4939
|
-
|
|
4940
|
-
.\${P}-list-item {
|
|
4941
|
-
display: flex
|
|
4942
|
-
flex-direction: column
|
|
4943
|
-
align-items: stretch
|
|
4944
|
-
width: 100
|
|
4945
|
-
overflow: visible
|
|
4946
|
-
position: relative
|
|
4947
|
-
box-sizing: content-box
|
|
4948
|
-
user-select: none
|
|
4949
|
-
background: var(--\${P}-background-color)
|
|
4950
|
-
}
|
|
4951
|
-
|
|
4952
|
-
.\${P}-wrapper.\${P}-divider-top .\${P}-list-item {
|
|
4953
|
-
border-top-style: solid
|
|
4954
|
-
border-top-color: var(--\${P}-divider-color)
|
|
4955
|
-
}
|
|
4956
|
-
|
|
4957
|
-
.\${P}-wrapper.\${P}-divider-bottom .\${P}-list-item {
|
|
4958
|
-
border-bottom-style: solid
|
|
4959
|
-
border-bottom-color: var(--\${P}-divider-color)
|
|
4960
|
-
}
|
|
4961
|
-
|
|
4962
|
-
.\${P}-list-cols-row {
|
|
4963
|
-
display: flex
|
|
4964
|
-
align-items: start
|
|
4965
|
-
width: 100
|
|
4966
|
-
box-sizing: border-box
|
|
4967
|
-
}
|
|
4968
|
-
|
|
4969
|
-
.\${P}-list-cols-row-h {
|
|
4970
|
-
align-items: stretch
|
|
4971
|
-
}
|
|
4972
|
-
|
|
4973
|
-
.\${P}-list-cols-row-h [data-list-col] {
|
|
4974
|
-
display: grid
|
|
4975
|
-
grid-template-rows: minmax(0, 1fr)
|
|
4976
|
-
align-self: stretch
|
|
4977
|
-
min-height: min-content
|
|
4978
|
-
}
|
|
4979
|
-
|
|
4980
|
-
.\${P}-list-cols-row-h .\${P}-list-col {
|
|
4981
|
-
display: flex
|
|
4982
|
-
flex-direction: column
|
|
4983
|
-
align-items: flex-start
|
|
4984
|
-
justify-content: flex-start
|
|
4985
|
-
width: 100
|
|
4986
|
-
min-height: 0
|
|
4987
|
-
}
|
|
4988
|
-
|
|
4989
|
-
.\${P}-list-cols-row-h .\${P}-list-col-title {
|
|
4990
|
-
display: block
|
|
4991
|
-
flex: 0 0 auto
|
|
4992
|
-
align-self: stretch
|
|
4993
|
-
}
|
|
4994
|
-
|
|
4995
|
-
.\${P}-text-tight-leading {
|
|
4996
|
-
display: block
|
|
4997
|
-
flex-shrink: 0
|
|
4998
|
-
padding-top: var(--\${P}-title-leading-gap, 0)
|
|
4999
|
-
padding-bottom: var(--\${P}-title-leading-gap, 0)
|
|
5000
|
-
}
|
|
5001
|
-
|
|
5002
|
-
.\${P}-wrapper.\${P}-type-b .\${P}-list-cols-row {
|
|
5003
|
-
flex-direction: column
|
|
5004
|
-
align-items: stretch
|
|
5005
|
-
}
|
|
5006
|
-
|
|
5007
|
-
.\${P}-wrapper.\${P}-type-b .\${P}-list-col {
|
|
5008
|
-
width: 100
|
|
5009
|
-
min-width: 0
|
|
5010
|
-
flex-direction: column
|
|
5011
|
-
justify-content: flex-start
|
|
5012
|
-
align-items: flex-start
|
|
5013
|
-
min-height: min-content
|
|
5014
|
-
}
|
|
5015
|
-
|
|
5016
|
-
.\${P}-wrapper.\${P}-type-b .\${P}-list-col-title {
|
|
5017
|
-
display: block
|
|
5018
|
-
flex: 0 0 auto
|
|
5019
|
-
align-self: stretch
|
|
5020
|
-
text-align: center
|
|
5021
|
-
}
|
|
5022
|
-
|
|
5023
|
-
.\${P}-wrapper.\${P}-type-b .\${P}-cut-item .\${P}-list-cols-row {
|
|
5024
|
-
flex-direction: row
|
|
5025
|
-
align-items: center
|
|
5026
|
-
justify-content: center
|
|
5027
|
-
}
|
|
5028
|
-
|
|
5029
|
-
.\${P}-wrapper.\${P}-type-b .\${P}-cut-label {
|
|
5030
|
-
text-align: center
|
|
5031
|
-
width: 100
|
|
5032
|
-
box-sizing: border-box
|
|
5033
|
-
}
|
|
5034
|
-
|
|
5035
|
-
.\${P}-wrapper.\${P}-type-b .\${P}-list-col-last {
|
|
5036
|
-
flex: 0 0 auto
|
|
5037
|
-
min-width: 0
|
|
5038
|
-
}
|
|
5039
|
-
|
|
5040
|
-
a.\${P}-list-item {
|
|
5041
|
-
text-decoration: none
|
|
5042
|
-
color: inherit
|
|
5043
|
-
cursor: pointer
|
|
5044
|
-
}
|
|
5045
|
-
|
|
5046
|
-
.\${P}-list-col {
|
|
5047
|
-
flex-shrink: 0
|
|
5048
|
-
overflow: visible
|
|
5049
|
-
box-sizing: border-box
|
|
5050
|
-
min-width: \${sv(50)}
|
|
5051
|
-
position: relative
|
|
5052
|
-
display: flex
|
|
5053
|
-
align-items: flex-start
|
|
5054
|
-
}
|
|
5055
|
-
|
|
5056
|
-
.\${P}-list-col-last {
|
|
5057
|
-
flex: 1 1 auto
|
|
5058
|
-
min-width: \${sv(50)}
|
|
5059
|
-
}
|
|
5060
|
-
|
|
5061
|
-
.\${P}-list-col-title {
|
|
5062
|
-
color: var(--\${P}-text-color)
|
|
5063
|
-
white-space: pre-wrap
|
|
5064
|
-
overflow-wrap: anywhere
|
|
5065
|
-
word-break: break-word
|
|
5066
|
-
flex: 1
|
|
5067
|
-
min-width: 0
|
|
5068
|
-
width: 100
|
|
5069
|
-
box-sizing: border-box
|
|
5070
|
-
}
|
|
5071
|
-
|
|
5072
|
-
.\${P}-baseline-probe {
|
|
5073
|
-
display: inline-block
|
|
5074
|
-
width: 0
|
|
5075
|
-
height: 0
|
|
5076
|
-
overflow: hidden
|
|
5077
|
-
vertical-align: baseline
|
|
5078
|
-
}
|
|
5079
|
-
|
|
5080
|
-
.\${P}-col-resize-handle
|
|
5081
|
-
.\${P}-padding-control-handle {
|
|
5082
|
-
background: transparent
|
|
5083
|
-
}
|
|
5084
|
-
|
|
5085
|
-
.\${P}-row-padding-handle {
|
|
5086
|
-
position: relative
|
|
5087
|
-
z-index: 2
|
|
5088
|
-
width: 100
|
|
5089
|
-
flex-shrink: 0
|
|
5090
|
-
background: transparent
|
|
5091
|
-
}
|
|
5092
|
-
|
|
5093
|
-
.\${P}-row-padding-handle::before {
|
|
5094
|
-
content: ""
|
|
5095
|
-
position: absolute
|
|
5096
|
-
top: 0
|
|
5097
|
-
left: 0
|
|
5098
|
-
width: 100
|
|
5099
|
-
height: 100
|
|
5100
|
-
min-height: 20px
|
|
5101
|
-
pointer-events: auto
|
|
5102
|
-
z-index: 10
|
|
5103
|
-
}
|
|
5104
|
-
|
|
5105
|
-
.\${P}-col-resize-handle::after {
|
|
5106
|
-
content: ''
|
|
5107
|
-
position: absolute
|
|
5108
|
-
top: 0
|
|
5109
|
-
left: 50
|
|
5110
|
-
transform: translateX(-50%)
|
|
5111
|
-
width: 2px
|
|
5112
|
-
height: 100
|
|
5113
|
-
background: #FF5C02
|
|
5114
|
-
pointer-events: none
|
|
5115
|
-
}
|
|
5116
|
-
|
|
5117
|
-
.\${P}-wrapper.\${P}-type-b .\${P}-col-resize-handle::after {
|
|
5118
|
-
top: 50
|
|
5119
|
-
left: 0
|
|
5120
|
-
transform: translateY(-50%)
|
|
5121
|
-
width: 100
|
|
5122
|
-
height: 2px
|
|
5123
|
-
}
|
|
5124
|
-
|
|
5125
|
-
.\${P}-padding-control-handle::after {
|
|
5126
|
-
content: ''
|
|
5127
|
-
position: absolute
|
|
5128
|
-
top: 50
|
|
5129
|
-
left: 50
|
|
5130
|
-
transform: translate(-50%, -50%)
|
|
5131
|
-
width: 4px
|
|
5132
|
-
height: 12px
|
|
5133
|
-
background: #FF5C02
|
|
5134
|
-
border: 1px solid #FFFFFF
|
|
5135
|
-
border-radius: 5px
|
|
5136
|
-
pointer-events: none
|
|
5137
|
-
box-sizing: border-box
|
|
5138
|
-
}
|
|
5139
|
-
|
|
5140
|
-
.\${P}-wrapper.\${P}-type-b .\${P}-padding-control-handle::after {
|
|
5141
|
-
width: 12px
|
|
5142
|
-
height: 4px
|
|
5143
|
-
}
|
|
5144
|
-
|
|
5145
|
-
.\${P}-text-padding-lr-handle {
|
|
5146
|
-
background: transparent
|
|
5147
|
-
}
|
|
5148
|
-
|
|
5149
|
-
.\${P}-text-padding-lr-handle::after {
|
|
5150
|
-
content: ''
|
|
5151
|
-
position: absolute
|
|
5152
|
-
top: 50
|
|
5153
|
-
left: 50
|
|
5154
|
-
transform: translate(-50%, -50%)
|
|
5155
|
-
width: 4px
|
|
5156
|
-
height: 12px
|
|
5157
|
-
background: #FF5C02
|
|
5158
|
-
border: 1px solid #FFFFFF
|
|
5159
|
-
border-radius: 5px
|
|
5160
|
-
pointer-events: none
|
|
5161
|
-
box-sizing: border-box
|
|
5162
|
-
}
|
|
5163
|
-
|
|
5164
|
-
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-list-item-has-link
|
|
5165
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-item-has-link
|
|
5166
|
-
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-cut-item
|
|
5167
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-item {
|
|
5168
|
-
transition: background-color 250ms, border-color 250ms
|
|
5169
|
-
}
|
|
5170
|
-
|
|
5171
|
-
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-list-item-has-link .\${P}-list-col-title
|
|
5172
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-item-has-link .\${P}-list-col-title
|
|
5173
|
-
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-cut-label
|
|
5174
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-label {
|
|
5175
|
-
transition: color 250ms
|
|
5176
|
-
}
|
|
5177
|
-
|
|
5178
|
-
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-list-item-has-link:hover
|
|
5179
|
-
.\${P}-wrapper.\${P}-entry-hover-default.\${P}-state-hover .\${P}-list-item-has-link
|
|
5180
|
-
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-cut-item:hover
|
|
5181
|
-
.\${P}-wrapper.\${P}-entry-hover-default.\${P}-state-hover .\${P}-cut-item {
|
|
5182
|
-
background: var(--\${P}-background-hover-color)
|
|
5183
|
-
}
|
|
5184
|
-
|
|
5185
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default .\${P}-list-item-has-link:hover
|
|
5186
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default .\${P}-list-item:has(+ .\${P}-list-item-has-link:hover)
|
|
5187
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default .\${P}-list-item:has(+ .\${P}-cut-item:hover)
|
|
5188
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default.\${P}-state-hover .\${P}-list-item-has-link
|
|
5189
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default .\${P}-cut-item:hover
|
|
5190
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default.\${P}-state-hover .\${P}-cut-item
|
|
5191
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds .\${P}-list-item-has-link:hover
|
|
5192
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds .\${P}-list-item:has(+ .\${P}-list-item-has-link:hover)
|
|
5193
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds .\${P}-list-item:has(+ .\${P}-cut-item:hover)
|
|
5194
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-list-item-has-link
|
|
5195
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds .\${P}-cut-item:hover
|
|
5196
|
-
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-cut-item {
|
|
5197
|
-
border-bottom-color: var(--\${P}-divider-hover-color)
|
|
5198
|
-
}
|
|
5199
|
-
|
|
5200
|
-
.\${P}-wrapper.\${P}-divider-top:not(.\${P}-divider-bottom).\${P}-entry-hover-default .\${P}-list-item-has-link:hover:first-child
|
|
5201
|
-
.\${P}-wrapper.\${P}-divider-top:not(.\${P}-divider-bottom).\${P}-entry-hover-default.\${P}-state-hover .\${P}-list-item-has-link:first-child
|
|
5202
|
-
.\${P}-wrapper.\${P}-divider-top:not(.\${P}-divider-bottom).\${P}-entry-hover-blinds .\${P}-list-item-has-link:hover:first-child
|
|
5203
|
-
.\${P}-wrapper.\${P}-divider-top:not(.\${P}-divider-bottom).\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-list-item-has-link:first-child {
|
|
5204
|
-
border-top-color: var(--\${P}-divider-hover-color)
|
|
5205
|
-
}
|
|
5206
|
-
|
|
5207
|
-
.\${P}-wrapper.\${P}-divider-top.\${P}-divider-bottom.\${P}-entry-hover-default .\${P}-list-item-has-link:hover:first-child
|
|
5208
|
-
.\${P}-wrapper.\${P}-divider-top.\${P}-divider-bottom.\${P}-entry-hover-default.\${P}-state-hover .\${P}-list-item-has-link:first-child
|
|
5209
|
-
.\${P}-wrapper.\${P}-divider-top.\${P}-divider-bottom.\${P}-entry-hover-blinds .\${P}-list-item-has-link:hover:first-child
|
|
5210
|
-
.\${P}-wrapper.\${P}-divider-top.\${P}-divider-bottom.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-list-item-has-link:first-child {
|
|
5211
|
-
border-top-color: var(--\${P}-divider-hover-color)
|
|
5212
|
-
}
|
|
5213
|
-
|
|
5214
|
-
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-list-item-has-link:hover .\${P}-list-col-title
|
|
5215
|
-
.\${P}-wrapper.\${P}-entry-hover-default.\${P}-state-hover .\${P}-list-item-has-link .\${P}-list-col-title
|
|
5216
|
-
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-cut-item:hover .\${P}-cut-label
|
|
5217
|
-
.\${P}-wrapper.\${P}-entry-hover-default.\${P}-state-hover .\${P}-cut-item .\${P}-cut-label
|
|
5218
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-item-has-link:hover .\${P}-list-col-title
|
|
5219
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-list-item-has-link .\${P}-list-col-title
|
|
5220
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-item:hover .\${P}-cut-label
|
|
5221
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-cut-item .\${P}-cut-label {
|
|
5222
|
-
color: var(--\${P}-text-hover-color)
|
|
5223
|
-
}
|
|
5224
|
-
|
|
5225
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-item-has-link::before
|
|
5226
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-item::before {
|
|
5227
|
-
content: ''
|
|
5228
|
-
position: absolute
|
|
5229
|
-
inset: 0
|
|
5230
|
-
background: var(--\${P}-background-hover-color)
|
|
5231
|
-
transform: scaleY(0)
|
|
5232
|
-
transform-origin: center center
|
|
5233
|
-
transition: transform 250ms
|
|
5234
|
-
z-index: 0
|
|
5235
|
-
pointer-events: none
|
|
5236
|
-
}
|
|
5237
|
-
|
|
5238
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-col
|
|
5239
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-label {
|
|
5240
|
-
position: relative
|
|
5241
|
-
z-index: 1
|
|
5242
|
-
}
|
|
5243
|
-
|
|
5244
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-item-has-link:hover::before
|
|
5245
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-list-item-has-link::before
|
|
5246
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-item:hover::before
|
|
5247
|
-
.\${P}-wrapper.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-cut-item::before {
|
|
5248
|
-
transform: scaleY(1)
|
|
5249
|
-
}
|
|
5250
|
-
|
|
5251
|
-
.\${P}-cut-item {
|
|
5252
|
-
display: flex
|
|
5253
|
-
align-items: center
|
|
5254
|
-
justify-content: center
|
|
5255
|
-
width: 100
|
|
5256
|
-
overflow: visible
|
|
5257
|
-
position: relative
|
|
5258
|
-
z-index: 3
|
|
5259
|
-
box-sizing: border-box
|
|
5260
|
-
user-select: none
|
|
5261
|
-
background: var(--\${P}-background-color)
|
|
5262
|
-
cursor: pointer
|
|
5263
|
-
padding: 0
|
|
5264
|
-
border: none
|
|
5265
|
-
font: inherit
|
|
5266
|
-
text-align: inherit
|
|
5267
|
-
appearance: none
|
|
5268
|
-
-webkit-appearance: none
|
|
5269
|
-
}
|
|
5270
|
-
|
|
5271
|
-
.\${P}-cut-item .\${P}-list-cols-row {
|
|
5272
|
-
flex: 1
|
|
5273
|
-
min-height: 100
|
|
5274
|
-
align-items: center
|
|
5275
|
-
}
|
|
5276
|
-
|
|
5277
|
-
.\${P}-wrapper.\${P}-divider-bottom .\${P}-cut-item {
|
|
5278
|
-
border-bottom-style: solid
|
|
5279
|
-
border-bottom-color: var(--\${P}-divider-color)
|
|
5280
|
-
}
|
|
5281
|
-
|
|
5282
|
-
.\${P}-cut-label {
|
|
5283
|
-
display: block
|
|
5284
|
-
position: relative
|
|
5285
|
-
z-index: 1
|
|
5286
|
-
margin: 0
|
|
5287
|
-
color: var(--\${P}-text-color)
|
|
5288
|
-
white-space: pre-wrap
|
|
5289
|
-
overflow-wrap: anywhere
|
|
5290
|
-
word-break: break-word
|
|
5291
|
-
}
|
|
5292
|
-
|
|
5293
|
-
}
|
|
5294
|
-
|
|
5295
|
-
export const COLUMN_CONTENT_KEYS = [
|
|
5296
|
-
'AColumn'
|
|
5297
|
-
'BColumnWidth'
|
|
5298
|
-
'CColumnWidth'
|
|
5299
|
-
'DColumnWidth'
|
|
5300
|
-
'EColumnWidth'
|
|
5301
|
-
] as const
|
|
5302
|
-
|
|
5303
|
-
export const COLUMN_TEXT_PREFIXES = [
|
|
5304
|
-
'AColumn'
|
|
5305
|
-
'BColumn'
|
|
5306
|
-
'CColumn'
|
|
5307
|
-
'DColumn'
|
|
5308
|
-
'EColumn'
|
|
5309
|
-
] as const
|
|
5310
|
-
|
|
5311
|
-
export const CUT_LABEL_TEXT_PREFIX = 'cutLabel' as const
|
|
5312
|
-
|
|
5313
|
-
export const LIST_TEXT_STYLE_PREFIXES = [
|
|
5314
|
-
...COLUMN_TEXT_PREFIXES
|
|
5315
|
-
CUT_LABEL_TEXT_PREFIX
|
|
5316
|
-
] as const
|
|
5317
|
-
|
|
5318
|
-
export type ListTextStylePrefix = typeof LIST_TEXT_STYLE_PREFIXES[number]
|
|
5319
|
-
|
|
5320
|
-
export const LIST_COLUMN_LETTERS = ['A', 'B', 'C', 'D', 'E'] as const
|
|
5321
|
-
|
|
5322
|
-
export function getListColumnVerticalAlignSettingKey(columnLetter: string): string {
|
|
5323
|
-
return \`\${columnLetter}ColumnVerticalAlign
|
|
5324
|
-
}
|
|
5325
|
-
|
|
5326
|
-
export const COLUMN_VALIGN_BASIC_OPTIONS = ['Top', 'Center', 'Bottom'] as const
|
|
5327
|
-
|
|
5328
|
-
export function isBaselineAnchorColumnVerticalAlign(value: string | undefined): boolean {
|
|
5329
|
-
const raw = String(value ?? 'Top').trim()
|
|
5330
|
-
if (raw.toLowerCase().startsWith('baseline')) {
|
|
5331
|
-
return false
|
|
5332
|
-
}
|
|
5333
|
-
return raw === 'Top' || raw === 'Center' || raw === 'Bottom'
|
|
5334
|
-
}
|
|
5335
|
-
|
|
5336
|
-
export function parseBaselineAnchorLetter(value: string | undefined): string | null {
|
|
5337
|
-
const raw = String(value ?? '').trim()
|
|
5338
|
-
if (!raw.toLowerCase().startsWith('baseline')) {
|
|
5339
|
-
return null
|
|
5340
|
-
}
|
|
5341
|
-
const anchorLetter = raw.slice(-1).toUpperCase()
|
|
5342
|
-
return LIST_COLUMN_LETTERS.includes(anchorLetter as typeof LIST_COLUMN_LETTERS[number])
|
|
5343
|
-
? anchorLetter
|
|
5344
|
-
: null
|
|
5345
|
-
}
|
|
5346
|
-
|
|
5347
|
-
export function isValidColumnBaselineVAlign(
|
|
5348
|
-
value: string | undefined
|
|
5349
|
-
forColumnLetter: string
|
|
5350
|
-
settings: ListSettings
|
|
5351
|
-
): boolean {
|
|
5352
|
-
const anchorLetter = parseBaselineAnchorLetter(value)
|
|
5353
|
-
if (!anchorLetter) {
|
|
5354
|
-
return true
|
|
5355
|
-
}
|
|
5356
|
-
if (anchorLetter === forColumnLetter) {
|
|
5357
|
-
return false
|
|
5358
|
-
}
|
|
5359
|
-
return isBaselineAnchorColumnVerticalAlign(settings[getListColumnVerticalAlignSettingKey(anchorLetter) as ListColumnVerticalAlignKey])
|
|
5360
|
-
}
|
|
5361
|
-
|
|
5362
|
-
export function getColumnVerticalAlignOptionsForLetter(
|
|
5363
|
-
columnLetter: string
|
|
5364
|
-
settings: ListSettings
|
|
5365
|
-
): string[] {
|
|
5366
|
-
const baselineOptions = LIST_COLUMN_LETTERS
|
|
5367
|
-
.filter((letter) => letter !== columnLetter)
|
|
5368
|
-
.filter((letter) => isBaselineAnchorColumnVerticalAlign(settings[getListColumnVerticalAlignSettingKey(letter) as ListColumnVerticalAlignKey]))
|
|
5369
|
-
.map((letter) => \`Baseline \${letter}\`)
|
|
5370
|
-
|
|
5371
|
-
return [...COLUMN_VALIGN_BASIC_OPTIONS, ...baselineOptions]
|
|
5372
|
-
}
|
|
5373
|
-
|
|
5374
|
-
type ColumnVerticalAlign
|
|
5375
|
-
| { kind: 'top' | 'center' | 'bottom' }
|
|
5376
|
-
| { kind: 'baseline'; anchorLetter: string }
|
|
5377
|
-
|
|
5378
|
-
function parseColumnVerticalAlign(value: string | undefined): ColumnVerticalAlign {
|
|
5379
|
-
const raw = String(value ?? 'Top').trim()
|
|
5380
|
-
if (raw.toLowerCase().startsWith('baseline')) {
|
|
5381
|
-
const anchorLetter = raw.slice(-1).toUpperCase()
|
|
5382
|
-
if (LIST_COLUMN_LETTERS.includes(anchorLetter as typeof LIST_COLUMN_LETTERS[number])) {
|
|
5383
|
-
return { kind: 'baseline', anchorLetter }
|
|
5384
|
-
}
|
|
5385
|
-
return { kind: 'top' }
|
|
5386
|
-
}
|
|
5387
|
-
if (raw === 'Center') return { kind: 'center' }
|
|
5388
|
-
if (raw === 'Bottom') return { kind: 'bottom' }
|
|
5389
|
-
return { kind: 'top' }
|
|
5390
|
-
}
|
|
5391
|
-
|
|
5392
|
-
function resolveColumnVerticalAlign(
|
|
5393
|
-
value: string | undefined
|
|
5394
|
-
settings: ListSettings
|
|
5395
|
-
columnLetter: string
|
|
5396
|
-
): ColumnVerticalAlign {
|
|
5397
|
-
if (isActiveBaselineVAlign(value, settings, columnLetter)) {
|
|
5398
|
-
return parseColumnVerticalAlign(value)
|
|
5399
|
-
}
|
|
5400
|
-
|
|
5401
|
-
const parsed = parseColumnVerticalAlign(value)
|
|
5402
|
-
if (parsed.kind === 'baseline') {
|
|
5403
|
-
return { kind: 'top' }
|
|
5404
|
-
}
|
|
5405
|
-
|
|
5406
|
-
return parsed
|
|
5407
|
-
}
|
|
5408
|
-
|
|
5409
|
-
function isActiveBaselineVAlign(
|
|
5410
|
-
value: string | undefined
|
|
5411
|
-
settings: ListSettings
|
|
5412
|
-
forColumnLetter: string
|
|
5413
|
-
): boolean {
|
|
5414
|
-
if (!isValidColumnBaselineVAlign(value, forColumnLetter, settings)) {
|
|
5415
|
-
return false
|
|
5416
|
-
}
|
|
5417
|
-
return parseColumnVerticalAlign(value).kind === 'baseline'
|
|
5418
|
-
}
|
|
5419
|
-
|
|
5420
|
-
function getListColumnVerticalAlignSanitizeUpdates(
|
|
5421
|
-
settings: ListSettings
|
|
5422
|
-
): ListColumnVerticalAlignUpdates | null {
|
|
5423
|
-
if (settings.type === 'B') {
|
|
5424
|
-
return null
|
|
5425
|
-
}
|
|
5426
|
-
|
|
5427
|
-
const updates: ListColumnVerticalAlignUpdates = {}
|
|
5428
|
-
let hasUpdates = false
|
|
5429
|
-
|
|
5430
|
-
for (const letter of LIST_COLUMN_LETTERS) {
|
|
5431
|
-
const key = getListColumnVerticalAlignSettingKey(letter) as ListColumnVerticalAlignKey
|
|
5432
|
-
const value = settings[key]
|
|
5433
|
-
if (!isValidColumnBaselineVAlign(value, letter, settings)) {
|
|
5434
|
-
updates[key] = 'Top'
|
|
5435
|
-
hasUpdates = true
|
|
5436
|
-
}
|
|
5437
|
-
}
|
|
5438
|
-
|
|
5439
|
-
return hasUpdates ? updates : null
|
|
5440
|
-
}
|
|
5441
|
-
|
|
5442
|
-
function vAlignToTitleStyle(
|
|
5443
|
-
kind: ColumnVerticalAlign['kind']
|
|
5444
|
-
): React.CSSProperties {
|
|
5445
|
-
if (kind === 'center') {
|
|
5446
|
-
return { marginTop: 'auto', marginBottom: 'auto' }
|
|
5447
|
-
}
|
|
5448
|
-
if (kind === 'bottom') {
|
|
5449
|
-
return { marginTop: 'auto' }
|
|
5450
|
-
}
|
|
5451
|
-
return {}
|
|
5452
|
-
}
|
|
5453
|
-
|
|
5454
|
-
function getFirstLineBaselineOffsetInTitle(
|
|
5455
|
-
titleEl: HTMLElement
|
|
5456
|
-
probeClassName: string
|
|
5457
|
-
): number {
|
|
5458
|
-
const probe = document.createElement('i')
|
|
5459
|
-
probe.className = probeClassName
|
|
5460
|
-
probe.setAttribute('aria-hidden', 'true')
|
|
5461
|
-
titleEl.prepend(probe)
|
|
5462
|
-
|
|
5463
|
-
const { top: titleTop } = titleEl.getBoundingClientRect()
|
|
5464
|
-
const { bottom: probeBottom } = probe.getBoundingClientRect()
|
|
5465
|
-
const baselineOffset = probeBottom - titleTop
|
|
5466
|
-
probe.remove()
|
|
5467
|
-
|
|
5468
|
-
return baselineOffset
|
|
5469
|
-
}
|
|
5470
|
-
|
|
5471
|
-
function measureColumnFirstLineBaselineOffset(
|
|
5472
|
-
info: {
|
|
5473
|
-
titleEl: HTMLElement | null
|
|
5474
|
-
kind: string
|
|
5475
|
-
}
|
|
5476
|
-
rowTop: number
|
|
5477
|
-
listColClassName: string
|
|
5478
|
-
probeClassName: string
|
|
5479
|
-
): number {
|
|
5480
|
-
const titleEl = info.titleEl
|
|
5481
|
-
if (!titleEl) return 0
|
|
5482
|
-
|
|
5483
|
-
const listCol = titleEl.closest<HTMLElement>(\`.\${listColClassName}\`)
|
|
5484
|
-
if (!listCol) return 0
|
|
5485
|
-
|
|
5486
|
-
const baselineInTitle = getFirstLineBaselineOffsetInTitle(titleEl, probeClassName)
|
|
5487
|
-
|
|
5488
|
-
if (info.kind === 'baseline') {
|
|
5489
|
-
return titleEl.getBoundingClientRect().top - rowTop + baselineInTitle
|
|
5490
|
-
}
|
|
5491
|
-
|
|
5492
|
-
const listColRect = listCol.getBoundingClientRect()
|
|
5493
|
-
const titleHeight = titleEl.getBoundingClientRect().height
|
|
5494
|
-
let valignOffset = 0
|
|
5495
|
-
|
|
5496
|
-
if (info.kind === 'center') {
|
|
5497
|
-
valignOffset = (listColRect.height - titleHeight) / 2
|
|
5498
|
-
} else if (info.kind === 'bottom') {
|
|
5499
|
-
valignOffset = listColRect.height - titleHeight
|
|
5500
|
-
}
|
|
5501
|
-
|
|
5502
|
-
return (listColRect.top - rowTop) + valignOffset + baselineInTitle
|
|
5503
|
-
}
|
|
5504
|
-
|
|
5505
|
-
function syncRowListColHeights(
|
|
5506
|
-
rowEl: HTMLElement
|
|
5507
|
-
cols: HTMLElement[]
|
|
5508
|
-
listColClassName: string
|
|
5509
|
-
): number {
|
|
5510
|
-
const rowHeight = rowEl.getBoundingClientRect().height
|
|
5511
|
-
if (rowHeight <= 0) {
|
|
5512
|
-
return 0
|
|
5513
|
-
}
|
|
5514
|
-
|
|
5515
|
-
cols.forEach((colEl) => {
|
|
5516
|
-
const listCol = colEl.querySelector<HTMLElement>(\`.\${listColClassName}\`)
|
|
5517
|
-
if (listCol) {
|
|
5518
|
-
listCol.style.minHeight = \`\${rowHeight}px
|
|
5519
|
-
listCol.style.height = \`\${rowHeight}px
|
|
5520
|
-
}
|
|
5521
|
-
})
|
|
5522
|
-
|
|
5523
|
-
void rowEl.offsetHeight
|
|
5524
|
-
return rowHeight
|
|
5525
|
-
}
|
|
5526
|
-
|
|
5527
|
-
function applyBaselineTitleShift(titleEl: HTMLElement | null, shift: number): number {
|
|
5528
|
-
if (!titleEl || !shift) {
|
|
5529
|
-
if (titleEl) {
|
|
5530
|
-
titleEl.style.transform = ''
|
|
5531
|
-
}
|
|
5532
|
-
return 0
|
|
5533
|
-
}
|
|
5534
|
-
|
|
5535
|
-
titleEl.style.transform = \`translateY(\${shift}px)
|
|
5536
|
-
return shift
|
|
5537
|
-
}
|
|
5538
|
-
|
|
5539
|
-
const COLUMN_CONTENT_KEY_TO_TEXT_PREFIX: Record
|
|
5540
|
-
typeof COLUMN_CONTENT_KEYS[number]
|
|
5541
|
-
typeof COLUMN_TEXT_PREFIXES[number]
|
|
5542
|
-
> = {
|
|
5543
|
-
AColumn: 'AColumn'
|
|
5544
|
-
BColumnWidth: 'BColumn'
|
|
5545
|
-
CColumnWidth: 'CColumn'
|
|
5546
|
-
DColumnWidth: 'DColumn'
|
|
5547
|
-
EColumnWidth: 'EColumn'
|
|
5548
|
-
}
|
|
5549
|
-
|
|
5550
|
-
export const LIST_GLOBAL_TEXT_STYLE_KEYS = [
|
|
5551
|
-
'textFontFamily'
|
|
5552
|
-
'textFontSettings'
|
|
5553
|
-
'textFontSize'
|
|
5554
|
-
'textLineHeight'
|
|
5555
|
-
'textLetterSpacing'
|
|
5556
|
-
'textWordSpacing'
|
|
5557
|
-
'textTextAppearance'
|
|
5558
|
-
] as const
|
|
5559
|
-
|
|
5560
|
-
export type ListGlobalTextStyleKey = typeof LIST_GLOBAL_TEXT_STYLE_KEYS[number]
|
|
5561
|
-
|
|
5562
|
-
export function getListColumnTextSettingKey(
|
|
5563
|
-
prefix: ListTextStylePrefix
|
|
5564
|
-
globalKey: ListGlobalTextStyleKey
|
|
5565
|
-
): string {
|
|
5566
|
-
return \`\${prefix}\${globalKey.replace(/^text/, 'Text')}
|
|
5567
|
-
}
|
|
5568
|
-
|
|
5569
|
-
type ListTextStyleFields = {
|
|
5570
|
-
textFontFamily?: string
|
|
5571
|
-
textFontSettings?: { fontWeight: number; fontStyle: string }
|
|
5572
|
-
textFontSize?: number
|
|
5573
|
-
textLineHeight?: number
|
|
5574
|
-
textLetterSpacing?: number
|
|
5575
|
-
textWordSpacing?: number
|
|
5576
|
-
textTextAppearance?: TextStyles['textAppearance']
|
|
5577
|
-
textColor?: string
|
|
5578
|
-
}
|
|
5579
|
-
|
|
5580
|
-
type ResolvedListTextFields = {
|
|
5581
|
-
textFontFamily: string
|
|
5582
|
-
textFontSettings: { fontWeight: number; fontStyle: string }
|
|
5583
|
-
textFontSize?: number
|
|
5584
|
-
textLineHeight?: number
|
|
5585
|
-
textLetterSpacing: number
|
|
5586
|
-
textWordSpacing: number
|
|
5587
|
-
textTextAppearance?: TextStyles['textAppearance']
|
|
5588
|
-
textColor?: string
|
|
5589
|
-
}
|
|
5590
|
-
|
|
5591
|
-
function resolveListGlobalTextFields(
|
|
5592
|
-
settings: ListTextStyleFields
|
|
5593
|
-
): ResolvedListTextFields {
|
|
5594
|
-
return {
|
|
5595
|
-
textFontFamily: settings.textFontFamily ?? 'Arial'
|
|
5596
|
-
textFontSettings: settings.textFontSettings ?? {
|
|
5597
|
-
fontWeight: 400
|
|
5598
|
-
fontStyle: 'normal'
|
|
5599
|
-
}
|
|
5600
|
-
textFontSize: settings.textFontSize
|
|
5601
|
-
textLineHeight: settings.textLineHeight
|
|
5602
|
-
textLetterSpacing: settings.textLetterSpacing ?? 0
|
|
5603
|
-
textWordSpacing: settings.textWordSpacing ?? 0
|
|
5604
|
-
textTextAppearance: settings.textTextAppearance
|
|
5605
|
-
textColor: settings.textColor
|
|
5606
|
-
}
|
|
5607
|
-
}
|
|
5608
|
-
|
|
5609
|
-
function resolveListColumnTextFields(
|
|
5610
|
-
settings: ListSettings
|
|
5611
|
-
textPrefix: ListTextStylePrefix
|
|
5612
|
-
): ResolvedListTextFields {
|
|
5613
|
-
const read = <K extends ListGlobalTextStyleKey>(globalKey: K) => {
|
|
5614
|
-
const columnKey = getListColumnTextSettingKey(textPrefix, globalKey)
|
|
5615
|
-
const columnValue = settings[columnKey as keyof ListSettings]
|
|
5616
|
-
if (columnValue !== undefined) {
|
|
5617
|
-
return columnValue as ListTextStyleFields[K]
|
|
5618
|
-
}
|
|
5619
|
-
return settings[globalKey]
|
|
5620
|
-
}
|
|
5621
|
-
|
|
5622
|
-
return {
|
|
5623
|
-
textFontFamily: (read('textFontFamily') as string | undefined) ?? 'Arial'
|
|
5624
|
-
textFontSettings: (read('textFontSettings') as ListTextStyleFields['textFontSettings']) ?? {
|
|
5625
|
-
fontWeight: 400
|
|
5626
|
-
fontStyle: 'normal'
|
|
5627
|
-
}
|
|
5628
|
-
textFontSize: read('textFontSize') as number | undefined
|
|
5629
|
-
textLineHeight: read('textLineHeight') as number | undefined
|
|
5630
|
-
textLetterSpacing: (read('textLetterSpacing') as number | undefined) ?? 0
|
|
5631
|
-
textWordSpacing: (read('textWordSpacing') as number | undefined) ?? 0
|
|
5632
|
-
textTextAppearance: read('textTextAppearance') as ListTextStyleFields['textTextAppearance']
|
|
5633
|
-
textColor: settings.textColor
|
|
5634
|
-
}
|
|
5635
|
-
}
|
|
5636
|
-
|
|
5637
|
-
function listColumnTextFieldsToCss(
|
|
5638
|
-
fields: ResolvedListTextFields
|
|
5639
|
-
isEditor?: boolean
|
|
5640
|
-
): React.CSSProperties {
|
|
5641
|
-
const resolvedTextStyle: TextStyles = {
|
|
5642
|
-
fontSettings: {
|
|
5643
|
-
fontFamily: fields.textFontFamily
|
|
5644
|
-
fontWeight: fields.textFontSettings?.fontWeight ?? 400
|
|
5645
|
-
fontStyle: fields.textFontSettings?.fontStyle ?? 'normal'
|
|
5646
|
-
}
|
|
5647
|
-
fontSize: fields.textFontSize ?? 0.01
|
|
5648
|
-
lineHeight: fields.textLineHeight
|
|
5649
|
-
letterSpacing: fields.textLetterSpacing
|
|
5650
|
-
wordSpacing: fields.textWordSpacing
|
|
5651
|
-
textAppearance: fields.textTextAppearance
|
|
5652
|
-
color: fields.textColor ?? '#767676'
|
|
5653
|
-
}
|
|
5654
|
-
|
|
5655
|
-
return omitTextColors(textStylesToCss(resolvedTextStyle, isEditor))
|
|
5656
|
-
}
|
|
5657
|
-
|
|
5658
|
-
function getListColumnTitleClassName(
|
|
5659
|
-
settings: ListSettings
|
|
5660
|
-
prefix: ListTextStylePrefix
|
|
5661
|
-
baseClassName: string
|
|
5662
|
-
tightLeadingClassName: string
|
|
5663
|
-
): string {
|
|
5664
|
-
const fields = resolveListColumnTextFields(settings, prefix)
|
|
5665
|
-
const fontSize = fields.textFontSize ?? 0.01
|
|
5666
|
-
const lineHeight = fields.textLineHeight
|
|
5667
|
-
const needsTightLeading = lineHeight !== undefined && lineHeight < fontSize
|
|
5668
|
-
|
|
5669
|
-
return needsTightLeading
|
|
5670
|
-
? \`\${baseClassName} \${tightLeadingClassName}
|
|
5671
|
-
: baseClassName
|
|
5672
|
-
}
|
|
5673
|
-
|
|
5674
|
-
function getListColumnTitleVars(
|
|
5675
|
-
settings: ListSettings
|
|
5676
|
-
prefix: ListTextStylePrefix
|
|
5677
|
-
titleVarPrefix: string
|
|
5678
|
-
isEditor?: boolean
|
|
5679
|
-
): React.CSSProperties {
|
|
5680
|
-
const fields = resolveListColumnTextFields(settings, prefix)
|
|
5681
|
-
const fontSize = fields.textFontSize ?? 0.01
|
|
5682
|
-
const lineHeight = fields.textLineHeight
|
|
5683
|
-
|
|
5684
|
-
if (lineHeight === undefined || lineHeight >= fontSize) {
|
|
5685
|
-
return {}
|
|
5686
|
-
}
|
|
5687
|
-
|
|
5688
|
-
return {
|
|
5689
|
-
[\`--\${titleVarPrefix}-title-leading-gap\`]: scalingValue((fontSize - lineHeight) / 2, isEditor)
|
|
5690
|
-
} as React.CSSProperties
|
|
5691
|
-
}
|
|
5692
|
-
|
|
5693
|
-
function getListGlobalTextSyncUpdates(
|
|
5694
|
-
nextSettings: ListSettings
|
|
5695
|
-
prevSettings: ListSettings
|
|
5696
|
-
): ListColumnTextStyleSyncUpdates | null {
|
|
5697
|
-
const updates: ListColumnTextStyleSyncUpdates = {}
|
|
5698
|
-
let hasChanges = false
|
|
5699
|
-
|
|
5700
|
-
for (const globalKey of LIST_GLOBAL_TEXT_STYLE_KEYS) {
|
|
5701
|
-
if (nextSettings[globalKey] === prevSettings[globalKey]) {
|
|
5702
|
-
continue
|
|
5703
|
-
}
|
|
5704
|
-
if (nextSettings[globalKey] === undefined) {
|
|
5705
|
-
continue
|
|
5706
|
-
}
|
|
5707
|
-
|
|
5708
|
-
hasChanges = true
|
|
5709
|
-
for (const prefix of LIST_TEXT_STYLE_PREFIXES) {
|
|
5710
|
-
Object.assign(updates, {
|
|
5711
|
-
[getListColumnTextSettingKey(prefix, globalKey)]: nextSettings[globalKey]
|
|
5712
|
-
})
|
|
5713
|
-
}
|
|
5714
|
-
}
|
|
5715
|
-
|
|
5716
|
-
return hasChanges ? updates : null
|
|
5717
|
-
}
|
|
5718
|
-
|
|
5719
|
-
const COLUMN_WIDTH_KEYS = [
|
|
5720
|
-
'AColumnWidth'
|
|
5721
|
-
'BColumnWidth'
|
|
5722
|
-
'CColumnWidth'
|
|
5723
|
-
'DColumnWidth'
|
|
5724
|
-
'EColumnWidth'
|
|
5725
|
-
] as const
|
|
5726
|
-
|
|
5727
|
-
const COLUMN_PADDING_LEFT_KEYS = [
|
|
5728
|
-
'AColumnPaddingLeft'
|
|
5729
|
-
'BColumnPaddingLeft'
|
|
5730
|
-
'CColumnPaddingLeft'
|
|
5731
|
-
'DColumnPaddingLeft'
|
|
5732
|
-
'EColumnPaddingLeft'
|
|
5733
|
-
] as const
|
|
5734
|
-
|
|
5735
|
-
const COLUMN_PADDING_RIGHT_KEYS = [
|
|
5736
|
-
'AColumnPaddingRight'
|
|
5737
|
-
'BColumnPaddingRight'
|
|
5738
|
-
'CColumnPaddingRight'
|
|
5739
|
-
'DColumnPaddingRight'
|
|
5740
|
-
'EColumnPaddingRight'
|
|
5741
|
-
] as const
|
|
5742
|
-
|
|
5743
|
-
const COLUMN_PADDING_BOTTOM_KEYS = [
|
|
5744
|
-
'AColumnPaddingBottom'
|
|
5745
|
-
'BColumnPaddingBottom'
|
|
5746
|
-
'CColumnPaddingBottom'
|
|
5747
|
-
'DColumnPaddingBottom'
|
|
5748
|
-
'EColumnPaddingBottom'
|
|
5749
|
-
] as const
|
|
5750
|
-
|
|
5751
|
-
type ColumnWidthKey = typeof COLUMN_WIDTH_KEYS[number]
|
|
5752
|
-
type ColumnPaddingLeftKey = typeof COLUMN_PADDING_LEFT_KEYS[number]
|
|
5753
|
-
type ColumnPaddingRightKey = typeof COLUMN_PADDING_RIGHT_KEYS[number]
|
|
5754
|
-
type ColumnPaddingBottomKey = typeof COLUMN_PADDING_BOTTOM_KEYS[number]
|
|
5755
|
-
|
|
5756
|
-
type ListColumnPaddingUpdates = {
|
|
5757
|
-
AColumnPaddingLeft?: number
|
|
5758
|
-
AColumnPaddingRight?: number
|
|
5759
|
-
BColumnPaddingLeft?: number
|
|
5760
|
-
BColumnPaddingRight?: number
|
|
5761
|
-
CColumnPaddingLeft?: number
|
|
5762
|
-
CColumnPaddingRight?: number
|
|
5763
|
-
DColumnPaddingLeft?: number
|
|
5764
|
-
DColumnPaddingRight?: number
|
|
5765
|
-
EColumnPaddingLeft?: number
|
|
5766
|
-
EColumnPaddingRight?: number
|
|
5767
|
-
}
|
|
5768
|
-
|
|
5769
|
-
type ListColumnWidthUpdates = {
|
|
5770
|
-
AColumnWidth?: number
|
|
5771
|
-
BColumnWidth?: number
|
|
5772
|
-
CColumnWidth?: number
|
|
5773
|
-
DColumnWidth?: number
|
|
5774
|
-
EColumnWidth?: number
|
|
5775
|
-
}
|
|
5776
|
-
|
|
5777
|
-
type ListItemColumn = {
|
|
5778
|
-
key: string
|
|
5779
|
-
textPrefix: typeof COLUMN_TEXT_PREFIXES[number]
|
|
5780
|
-
widthKey: ColumnWidthKey
|
|
5781
|
-
paddingLeftKey: ColumnPaddingLeftKey
|
|
5782
|
-
paddingRightKey: ColumnPaddingRightKey
|
|
5783
|
-
paddingBottomKey: ColumnPaddingBottomKey
|
|
5784
|
-
width: number
|
|
5785
|
-
paddingLeft: number
|
|
5786
|
-
paddingRight: number
|
|
5787
|
-
paddingBottom: number
|
|
5788
|
-
}
|
|
5789
|
-
|
|
5790
|
-
type ColorKeys
|
|
5791
|
-
| 'textColor'
|
|
5792
|
-
| 'backgroundColor'
|
|
5793
|
-
| 'dividerColor'
|
|
5794
|
-
| 'textHoverColor'
|
|
5795
|
-
| 'backgroundHoverColor'
|
|
5796
|
-
| 'dividerHoverColor'
|
|
5797
|
-
|
|
5798
|
-
const COLOR_VAR_MAP: Record<ColorKeys, string> = {
|
|
5799
|
-
textColor: 'text-color'
|
|
5800
|
-
backgroundColor: 'background-color'
|
|
5801
|
-
dividerColor: 'divider-color'
|
|
5802
|
-
textHoverColor: 'text-hover-color'
|
|
5803
|
-
backgroundHoverColor: 'background-hover-color'
|
|
5804
|
-
dividerHoverColor: 'divider-hover-color'
|
|
5805
|
-
}
|
|
5806
|
-
|
|
5807
|
-
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const
|
|
5808
|
-
|
|
5809
|
-
const COL_RESIZE_HANDLE_WIDTH = 0.004
|
|
5810
|
-
const COL_PADDING_HANDLE_WIDTH = 0.004
|
|
5811
|
-
const MIN_COLUMN_WIDTH_PX = 50
|
|
5812
|
-
const ARTICLE_DESIGN_WIDTH = 1440
|
|
5813
|
-
const MIN_COLUMN_WIDTH = MIN_COLUMN_WIDTH_PX / ARTICLE_DESIGN_WIDTH
|
|
5814
|
-
|
|
5815
|
-
export function getListMinColumnWidth(designWidthPx?: number): number {
|
|
5816
|
-
const designWidth = typeof designWidthPx === 'number' && designWidthPx > 0
|
|
5817
|
-
? designWidthPx
|
|
5818
|
-
: ARTICLE_DESIGN_WIDTH
|
|
5819
|
-
|
|
5820
|
-
return MIN_COLUMN_WIDTH_PX / designWidth
|
|
5821
|
-
}
|
|
5822
|
-
|
|
5823
|
-
function getEditorDesignWidth(element: HTMLElement | null | undefined): number {
|
|
5824
|
-
let el = element ?? null
|
|
5825
|
-
|
|
5826
|
-
while (el) {
|
|
5827
|
-
const inline = el.style.getPropertyValue('--cntrl-article-width').trim()
|
|
5828
|
-
if (inline) {
|
|
5829
|
-
const px = parseFloat(inline)
|
|
5830
|
-
if (Number.isFinite(px) && px > 0) {
|
|
5831
|
-
return px
|
|
5832
|
-
}
|
|
5833
|
-
}
|
|
5834
|
-
|
|
5835
|
-
const computed = getComputedStyle(el).getPropertyValue('--cntrl-article-width').trim()
|
|
5836
|
-
if (computed) {
|
|
5837
|
-
const px = parseFloat(computed)
|
|
5838
|
-
if (Number.isFinite(px) && px > 0) {
|
|
5839
|
-
return px
|
|
5840
|
-
}
|
|
5841
|
-
}
|
|
5842
|
-
|
|
5843
|
-
el = el.parentElement
|
|
5844
|
-
}
|
|
5845
|
-
|
|
5846
|
-
return ARTICLE_DESIGN_WIDTH
|
|
5847
|
-
}
|
|
5848
|
-
|
|
5849
|
-
const DEFAULT_COLUMN_WIDTHS: Record<ColumnWidthKey, number> = {
|
|
5850
|
-
AColumnWidth: 0.02
|
|
5851
|
-
BColumnWidth: 0.02
|
|
5852
|
-
CColumnWidth: 0.02
|
|
5853
|
-
DColumnWidth: 0.02
|
|
5854
|
-
EColumnWidth: 0.02
|
|
5855
|
-
}
|
|
5856
|
-
|
|
5857
|
-
export function getListEffectiveContentWidth(
|
|
5858
|
-
settings: ListSettings
|
|
5859
|
-
): number {
|
|
5860
|
-
const wrapperWidth = typeof settings.wrapperWidth === 'number' ? settings.wrapperWidth : 1
|
|
5861
|
-
|
|
5862
|
-
return Math.max(0, wrapperWidth)
|
|
5863
|
-
}
|
|
5864
|
-
|
|
5865
|
-
export function getEqualListColumnWidthUpdates(
|
|
5866
|
-
columns: number
|
|
5867
|
-
contentWidth: number = 1
|
|
5868
|
-
): Record<ColumnWidthKey, number> {
|
|
5869
|
-
const equalColumnWidth = contentWidth / columns
|
|
5870
|
-
return Object.fromEntries(
|
|
5871
|
-
COLUMN_WIDTH_KEYS.map((key) => [key, equalColumnWidth])
|
|
5872
|
-
) as Record<ColumnWidthKey, number
|
|
5873
|
-
}
|
|
5874
|
-
|
|
5875
|
-
function getResetListColumnPaddingUpdates(): Record
|
|
5876
|
-
ColumnPaddingLeftKey | ColumnPaddingRightKey
|
|
5877
|
-
number
|
|
5878
|
-
> {
|
|
5879
|
-
return Object.fromEntries([
|
|
5880
|
-
...COLUMN_PADDING_LEFT_KEYS.map((key) => [key, 0])
|
|
5881
|
-
...COLUMN_PADDING_RIGHT_KEYS.map((key) => [key, 0])
|
|
5882
|
-
]) as Record<ColumnPaddingLeftKey | ColumnPaddingRightKey, number
|
|
5883
|
-
}
|
|
5884
|
-
|
|
5885
|
-
function getResetListColumnPaddingBottomUpdates(): Record<ColumnPaddingBottomKey, number> {
|
|
5886
|
-
return Object.fromEntries(
|
|
5887
|
-
COLUMN_PADDING_BOTTOM_KEYS.map((key) => [key, 0])
|
|
5888
|
-
) as Record<ColumnPaddingBottomKey, number
|
|
5889
|
-
}
|
|
5890
|
-
|
|
5891
|
-
function getStoredColumnWidths(
|
|
5892
|
-
settings: ListSettings
|
|
5893
|
-
): Record<ColumnWidthKey, number> {
|
|
5894
|
-
return Object.fromEntries(
|
|
5895
|
-
COLUMN_WIDTH_KEYS.map((key) => [
|
|
5896
|
-
key
|
|
5897
|
-
typeof settings[key] === 'number'
|
|
5898
|
-
? settings[key] as number
|
|
5899
|
-
: DEFAULT_COLUMN_WIDTHS[key]
|
|
5900
|
-
])
|
|
5901
|
-
) as Record<ColumnWidthKey, number
|
|
5902
|
-
}
|
|
5903
|
-
|
|
5904
|
-
export function resolveListColumnPadding(
|
|
5905
|
-
columnWidth: number
|
|
5906
|
-
paddingLeft: number
|
|
5907
|
-
paddingRight: number
|
|
5908
|
-
): { paddingLeft: number; paddingRight: number } {
|
|
5909
|
-
const maxTotalPadding = columnWidth - MIN_COLUMN_WIDTH
|
|
5910
|
-
const totalPadding = paddingLeft + paddingRight
|
|
5911
|
-
|
|
5912
|
-
if (totalPadding <= 0 || totalPadding <= maxTotalPadding) {
|
|
5913
|
-
return { paddingLeft, paddingRight }
|
|
5914
|
-
}
|
|
5915
|
-
|
|
5916
|
-
if (maxTotalPadding <= 0) {
|
|
5917
|
-
return { paddingLeft: 0, paddingRight: 0 }
|
|
5918
|
-
}
|
|
5919
|
-
|
|
5920
|
-
const scale = maxTotalPadding / totalPadding
|
|
5921
|
-
|
|
5922
|
-
return {
|
|
5923
|
-
paddingLeft: paddingLeft * scale
|
|
5924
|
-
paddingRight: paddingRight * scale
|
|
5925
|
-
}
|
|
5926
|
-
}
|
|
5927
|
-
|
|
5928
|
-
export function getEffectiveListColumnWidths(
|
|
5929
|
-
columns: number
|
|
5930
|
-
wrapperWidth: number
|
|
5931
|
-
storedWidths: Record<ColumnWidthKey, number
|
|
5932
|
-
): number[] {
|
|
5933
|
-
const resolvedWidths = resolveListColumnWidths(columns, wrapperWidth, storedWidths)
|
|
5934
|
-
|
|
5935
|
-
if (columns <= 0) {
|
|
5936
|
-
return []
|
|
5937
|
-
}
|
|
5938
|
-
|
|
5939
|
-
const sumFixed = resolvedWidths.slice(0, columns - 1).reduce((sum, width) => sum + width, 0)
|
|
5940
|
-
|
|
5941
|
-
return [
|
|
5942
|
-
...resolvedWidths.slice(0, columns - 1)
|
|
5943
|
-
Math.max(0, wrapperWidth - sumFixed)
|
|
5944
|
-
]
|
|
5945
|
-
}
|
|
5946
|
-
|
|
5947
|
-
function getListColumnPaddingUpdates(
|
|
5948
|
-
columns: number
|
|
5949
|
-
effectiveWidths: number[]
|
|
5950
|
-
settings: ListSettings
|
|
5951
|
-
): ListColumnPaddingUpdates {
|
|
5952
|
-
const updates: ListColumnPaddingUpdates = {}
|
|
5953
|
-
|
|
5954
|
-
for (let index = 0; index < columns; index += 1) {
|
|
5955
|
-
const paddingLeftKey = COLUMN_PADDING_LEFT_KEYS[index]
|
|
5956
|
-
const paddingRightKey = COLUMN_PADDING_RIGHT_KEYS[index]
|
|
5957
|
-
const storedPaddingLeft = typeof settings[paddingLeftKey] === 'number'
|
|
5958
|
-
? settings[paddingLeftKey] as number
|
|
5959
|
-
: 0
|
|
5960
|
-
const storedPaddingRight = typeof settings[paddingRightKey] === 'number'
|
|
5961
|
-
? settings[paddingRightKey] as number
|
|
5962
|
-
: 0
|
|
5963
|
-
const resolvedPadding = resolveListColumnPadding(
|
|
5964
|
-
effectiveWidths[index] ?? 0
|
|
5965
|
-
storedPaddingLeft
|
|
5966
|
-
storedPaddingRight
|
|
5967
|
-
)
|
|
5968
|
-
|
|
5969
|
-
if (resolvedPadding.paddingLeft !== storedPaddingLeft) {
|
|
5970
|
-
updates[paddingLeftKey] = resolvedPadding.paddingLeft
|
|
5971
|
-
}
|
|
5972
|
-
|
|
5973
|
-
if (resolvedPadding.paddingRight !== storedPaddingRight) {
|
|
5974
|
-
updates[paddingRightKey] = resolvedPadding.paddingRight
|
|
5975
|
-
}
|
|
5976
|
-
}
|
|
5977
|
-
|
|
5978
|
-
return updates
|
|
5979
|
-
}
|
|
5980
|
-
|
|
5981
|
-
export function resolveListColumnWidths(
|
|
5982
|
-
columns: number
|
|
5983
|
-
wrapperWidth: number
|
|
5984
|
-
storedWidths: Record<ColumnWidthKey, number
|
|
5985
|
-
): number[] {
|
|
5986
|
-
if (columns <= 0) {
|
|
5987
|
-
return []
|
|
5988
|
-
}
|
|
5989
|
-
|
|
5990
|
-
const widths = COLUMN_WIDTH_KEYS.slice(0, columns).map(
|
|
5991
|
-
(key) => storedWidths[key]
|
|
5992
|
-
)
|
|
5993
|
-
|
|
5994
|
-
if (columns === 1) {
|
|
5995
|
-
return widths
|
|
5996
|
-
}
|
|
5997
|
-
|
|
5998
|
-
const fixedWidths = widths.slice(0, columns - 1)
|
|
5999
|
-
const fixedSum = fixedWidths.reduce((sum, width) => sum + width, 0)
|
|
6000
|
-
const minTotalWidth = fixedSum + MIN_COLUMN_WIDTH
|
|
6001
|
-
|
|
6002
|
-
if (wrapperWidth >= minTotalWidth) {
|
|
6003
|
-
return widths
|
|
6004
|
-
}
|
|
6005
|
-
|
|
6006
|
-
const resolvedFixedWidths = [...fixedWidths]
|
|
6007
|
-
let overflow = minTotalWidth - wrapperWidth
|
|
6008
|
-
|
|
6009
|
-
for (let index = resolvedFixedWidths.length - 1; index >= 0 && overflow > 0; index -= 1) {
|
|
6010
|
-
const shrinkable = resolvedFixedWidths[index] - MIN_COLUMN_WIDTH
|
|
6011
|
-
if (shrinkable <= 0) {
|
|
6012
|
-
continue
|
|
6013
|
-
}
|
|
6014
|
-
|
|
6015
|
-
const shrinkAmount = Math.min(overflow, shrinkable)
|
|
6016
|
-
resolvedFixedWidths[index] -= shrinkAmount
|
|
6017
|
-
overflow -= shrinkAmount
|
|
6018
|
-
}
|
|
6019
|
-
|
|
6020
|
-
return [...resolvedFixedWidths, widths[columns - 1]]
|
|
6021
|
-
}
|
|
6022
|
-
|
|
6023
|
-
function getListColumnWidthUpdatesForWrapperWidth(
|
|
6024
|
-
columns: number
|
|
6025
|
-
wrapperWidth: number
|
|
6026
|
-
storedWidths: Record<ColumnWidthKey, number
|
|
6027
|
-
): ListColumnWidthUpdates {
|
|
6028
|
-
if (columns <= 1) {
|
|
6029
|
-
return {}
|
|
6030
|
-
}
|
|
6031
|
-
|
|
6032
|
-
const resolvedWidths = resolveListColumnWidths(columns, wrapperWidth, storedWidths)
|
|
6033
|
-
const updates: ListColumnWidthUpdates = {}
|
|
6034
|
-
|
|
6035
|
-
for (let index = 0; index < columns - 1; index += 1) {
|
|
6036
|
-
const key = COLUMN_WIDTH_KEYS[index]
|
|
6037
|
-
if (resolvedWidths[index] !== storedWidths[key]) {
|
|
6038
|
-
updates[key] = resolvedWidths[index]
|
|
6039
|
-
}
|
|
6040
|
-
}
|
|
6041
|
-
|
|
6042
|
-
return updates
|
|
6043
|
-
}
|
|
6044
|
-
|
|
6045
|
-
function getColumnsOrder(settings: ListSettings): string[] {
|
|
6046
|
-
if (Array.isArray(settings.columnsOrder) && settings.columnsOrder.length > 0) {
|
|
6047
|
-
return settings.columnsOrder as string[]
|
|
6048
|
-
}
|
|
6049
|
-
|
|
6050
|
-
return [...COLUMN_CONTENT_KEYS]
|
|
6051
|
-
}
|
|
6052
|
-
|
|
6053
|
-
function areStringArraysEqual(left: string[], right: string[]): boolean {
|
|
6054
|
-
if (left.length !== right.length) {
|
|
6055
|
-
return false
|
|
6056
|
-
}
|
|
6057
|
-
|
|
6058
|
-
return left.every((value, index) => value === right[index])
|
|
6059
|
-
}
|
|
6060
|
-
|
|
6061
|
-
function getColumnLayoutUpdatesForOrderChange(
|
|
6062
|
-
nextOrder: string[]
|
|
6063
|
-
prevOrder: string[]
|
|
6064
|
-
prevSettings: ListSettings
|
|
6065
|
-
columns: number
|
|
6066
|
-
): Record<string, number> {
|
|
6067
|
-
const count = Math.min(columns, nextOrder.length, COLUMN_WIDTH_KEYS.length)
|
|
6068
|
-
const updates: Record<string, number> = {}
|
|
6069
|
-
|
|
6070
|
-
for (let index = 0; index < count; index += 1) {
|
|
6071
|
-
const contentKey = nextOrder[index]
|
|
6072
|
-
const prevSlotIndex = prevOrder.indexOf(contentKey)
|
|
6073
|
-
|
|
6074
|
-
if (prevSlotIndex === -1) {
|
|
6075
|
-
continue
|
|
6076
|
-
}
|
|
6077
|
-
|
|
6078
|
-
const prevWidthKey = COLUMN_WIDTH_KEYS[prevSlotIndex]
|
|
6079
|
-
const prevPaddingLeftKey = COLUMN_PADDING_LEFT_KEYS[prevSlotIndex]
|
|
6080
|
-
const prevPaddingRightKey = COLUMN_PADDING_RIGHT_KEYS[prevSlotIndex]
|
|
6081
|
-
const prevPaddingBottomKey = COLUMN_PADDING_BOTTOM_KEYS[prevSlotIndex]
|
|
6082
|
-
const widthKey = COLUMN_WIDTH_KEYS[index]
|
|
6083
|
-
const paddingLeftKey = COLUMN_PADDING_LEFT_KEYS[index]
|
|
6084
|
-
const paddingRightKey = COLUMN_PADDING_RIGHT_KEYS[index]
|
|
6085
|
-
const paddingBottomKey = COLUMN_PADDING_BOTTOM_KEYS[index]
|
|
6086
|
-
|
|
6087
|
-
const prevWidth = prevSettings[prevWidthKey]
|
|
6088
|
-
const prevPaddingLeft = prevSettings[prevPaddingLeftKey]
|
|
6089
|
-
const prevPaddingRight = prevSettings[prevPaddingRightKey]
|
|
6090
|
-
const prevPaddingBottom = prevSettings[prevPaddingBottomKey]
|
|
6091
|
-
|
|
6092
|
-
if (typeof prevWidth === 'number') {
|
|
6093
|
-
updates[widthKey] = prevWidth
|
|
6094
|
-
}
|
|
6095
|
-
|
|
6096
|
-
if (typeof prevPaddingLeft === 'number') {
|
|
6097
|
-
updates[paddingLeftKey] = prevPaddingLeft
|
|
6098
|
-
}
|
|
6099
|
-
|
|
6100
|
-
if (typeof prevPaddingRight === 'number') {
|
|
6101
|
-
updates[paddingRightKey] = prevPaddingRight
|
|
6102
|
-
}
|
|
6103
|
-
|
|
6104
|
-
if (typeof prevPaddingBottom === 'number') {
|
|
6105
|
-
updates[paddingBottomKey] = prevPaddingBottom
|
|
6106
|
-
}
|
|
6107
|
-
}
|
|
6108
|
-
|
|
6109
|
-
return updates
|
|
6110
|
-
}
|
|
6111
|
-
|
|
6112
|
-
export function applyListSettingsChange(
|
|
6113
|
-
nextSettings: ListSettings
|
|
6114
|
-
prevSettings: ListSettings
|
|
6115
|
-
options?: { designWidth?: number }
|
|
6116
|
-
): ListSettings {
|
|
6117
|
-
const textSyncUpdates = getListGlobalTextSyncUpdates(nextSettings, prevSettings)
|
|
6118
|
-
if (textSyncUpdates) {
|
|
6119
|
-
nextSettings = { ...nextSettings, ...textSyncUpdates }
|
|
6120
|
-
}
|
|
6121
|
-
|
|
6122
|
-
const valignSanitizeUpdates = getListColumnVerticalAlignSanitizeUpdates(nextSettings)
|
|
6123
|
-
if (valignSanitizeUpdates) {
|
|
6124
|
-
nextSettings = { ...nextSettings, ...valignSanitizeUpdates }
|
|
6125
|
-
}
|
|
6126
|
-
|
|
6127
|
-
const minColumnWidth = getListMinColumnWidth(options?.designWidth)
|
|
6128
|
-
const nextColumns = nextSettings.columns
|
|
6129
|
-
const prevColumns = prevSettings.columns
|
|
6130
|
-
const nextContentWidth = getListEffectiveContentWidth(nextSettings)
|
|
6131
|
-
const prevContentWidth = getListEffectiveContentWidth(prevSettings)
|
|
6132
|
-
const isVerticalLayout = nextSettings.type === 'B'
|
|
6133
|
-
|| (nextSettings.type === undefined && prevSettings.type === 'B')
|
|
6134
|
-
const columns
|
|
6135
|
-
typeof nextColumns === 'number'
|
|
6136
|
-
? nextColumns
|
|
6137
|
-
: typeof prevColumns === 'number'
|
|
6138
|
-
? prevColumns
|
|
6139
|
-
: COLUMN_CONTENT_KEYS.length
|
|
6140
|
-
|
|
6141
|
-
const withColumnPaddingUpdates = (
|
|
6142
|
-
settings: ListSettings
|
|
6143
|
-
): ListSettings => {
|
|
6144
|
-
if (isVerticalLayout) {
|
|
6145
|
-
return settings
|
|
6146
|
-
}
|
|
6147
|
-
|
|
6148
|
-
const storedWidths = getStoredColumnWidths({ ...prevSettings, ...settings })
|
|
6149
|
-
const contentWidth = getListEffectiveContentWidth(settings)
|
|
6150
|
-
const effectiveWidths = getEffectiveListColumnWidths(columns, contentWidth, storedWidths)
|
|
6151
|
-
const paddingUpdates = getListColumnPaddingUpdates(columns, effectiveWidths, {
|
|
6152
|
-
...prevSettings
|
|
6153
|
-
...settings
|
|
6154
|
-
})
|
|
6155
|
-
|
|
6156
|
-
if (Object.keys(paddingUpdates).length === 0) {
|
|
6157
|
-
return settings
|
|
6158
|
-
}
|
|
6159
|
-
|
|
6160
|
-
return {
|
|
6161
|
-
...settings
|
|
6162
|
-
...paddingUpdates
|
|
6163
|
-
}
|
|
6164
|
-
}
|
|
6165
|
-
|
|
6166
|
-
if (typeof nextColumns === 'number' && nextColumns !== prevColumns) {
|
|
6167
|
-
const updates: ListSettings = {
|
|
6168
|
-
...nextSettings
|
|
6169
|
-
...getEqualListColumnWidthUpdates(nextColumns, nextContentWidth)
|
|
6170
|
-
...getResetListColumnPaddingUpdates()
|
|
6171
|
-
}
|
|
6172
|
-
|
|
6173
|
-
if (isVerticalLayout) {
|
|
6174
|
-
for (const key of COLUMN_PADDING_BOTTOM_KEYS) {
|
|
6175
|
-
if (typeof prevSettings[key] === 'number') {
|
|
6176
|
-
updates[key] = prevSettings[key]
|
|
6177
|
-
}
|
|
6178
|
-
}
|
|
6179
|
-
} else {
|
|
6180
|
-
Object.assign(updates, getResetListColumnPaddingBottomUpdates())
|
|
6181
|
-
}
|
|
6182
|
-
|
|
6183
|
-
return updates
|
|
6184
|
-
}
|
|
6185
|
-
|
|
6186
|
-
const nextOrder = getColumnsOrder(nextSettings)
|
|
6187
|
-
const prevOrder = getColumnsOrder(prevSettings)
|
|
6188
|
-
|
|
6189
|
-
if (!areStringArraysEqual(nextOrder, prevOrder)) {
|
|
6190
|
-
return withColumnPaddingUpdates({
|
|
6191
|
-
...nextSettings
|
|
6192
|
-
...getColumnLayoutUpdatesForOrderChange(nextOrder, prevOrder, prevSettings, columns)
|
|
6193
|
-
})
|
|
6194
|
-
}
|
|
6195
|
-
|
|
6196
|
-
if (nextContentWidth < prevContentWidth) {
|
|
6197
|
-
if (typeof columns === 'number' && !isVerticalLayout) {
|
|
6198
|
-
const storedWidths = getStoredColumnWidths({ ...prevSettings, ...nextSettings })
|
|
6199
|
-
|
|
6200
|
-
return withColumnPaddingUpdates({
|
|
6201
|
-
...nextSettings
|
|
6202
|
-
...getListColumnWidthUpdatesForWrapperWidth(columns, nextContentWidth, storedWidths)
|
|
6203
|
-
})
|
|
6204
|
-
}
|
|
6205
|
-
}
|
|
6206
|
-
|
|
6207
|
-
if (isVerticalLayout) {
|
|
6208
|
-
const storedTextPaddingLR = typeof nextSettings.textPaddingLR === 'number'
|
|
6209
|
-
? nextSettings.textPaddingLR as number
|
|
6210
|
-
: 0
|
|
6211
|
-
const maxAllowedPadding = Math.max(0, (nextContentWidth - minColumnWidth) / 2)
|
|
6212
|
-
|
|
6213
|
-
if (storedTextPaddingLR > maxAllowedPadding) {
|
|
6214
|
-
return { ...nextSettings, textPaddingLR: maxAllowedPadding }
|
|
6215
|
-
}
|
|
6216
|
-
|
|
6217
|
-
return nextSettings
|
|
6218
|
-
}
|
|
6219
|
-
|
|
6220
|
-
const storedWidths = getStoredColumnWidths({ ...prevSettings, ...nextSettings })
|
|
6221
|
-
const prevEffectiveWidths = getEffectiveListColumnWidths(
|
|
6222
|
-
columns
|
|
6223
|
-
prevContentWidth
|
|
6224
|
-
getStoredColumnWidths(prevSettings)
|
|
6225
|
-
)
|
|
6226
|
-
const nextEffectiveWidths = getEffectiveListColumnWidths(
|
|
6227
|
-
columns
|
|
6228
|
-
nextContentWidth
|
|
6229
|
-
storedWidths
|
|
6230
|
-
)
|
|
6231
|
-
const columnWidthDecreased = nextEffectiveWidths.some(
|
|
6232
|
-
(width, index) => width < (prevEffectiveWidths[index] ?? width)
|
|
6233
|
-
)
|
|
6234
|
-
const columnWidthSettingChanged = COLUMN_WIDTH_KEYS.some((key) => {
|
|
6235
|
-
const nextWidth = nextSettings[key]
|
|
6236
|
-
const prevWidth = prevSettings[key]
|
|
6237
|
-
|
|
6238
|
-
return typeof nextWidth === 'number'
|
|
6239
|
-
&& typeof prevWidth === 'number'
|
|
6240
|
-
&& nextWidth !== prevWidth
|
|
6241
|
-
})
|
|
6242
|
-
|
|
6243
|
-
if (columnWidthDecreased || columnWidthSettingChanged) {
|
|
6244
|
-
return withColumnPaddingUpdates(nextSettings)
|
|
6245
|
-
}
|
|
6246
|
-
|
|
6247
|
-
return nextSettings
|
|
6248
|
-
}
|
|
6249
|
-
|
|
6250
|
-
function getColumnMaxWidth(
|
|
6251
|
-
columnIndex: number
|
|
6252
|
-
resolvedWidths: number[]
|
|
6253
|
-
storedWidths: number[]
|
|
6254
|
-
wrapperWidth: number
|
|
6255
|
-
): number {
|
|
6256
|
-
const leftWidth = resolvedWidths
|
|
6257
|
-
.slice(0, columnIndex)
|
|
6258
|
-
.reduce((sum, width) => sum + width, 0)
|
|
6259
|
-
const rightPreferredWidth = storedWidths
|
|
6260
|
-
.slice(columnIndex + 1, resolvedWidths.length - 1)
|
|
6261
|
-
.reduce((sum, width) => sum + width, 0)
|
|
6262
|
-
|
|
6263
|
-
return Math.max(
|
|
6264
|
-
MIN_COLUMN_WIDTH
|
|
6265
|
-
wrapperWidth - leftWidth - rightPreferredWidth - MIN_COLUMN_WIDTH
|
|
6266
|
-
)
|
|
6267
|
-
}
|
|
6268
|
-
|
|
6269
|
-
function randomBetween(min: number, max: number): number {
|
|
6270
|
-
return Math.random() * (max - min) + min
|
|
6271
|
-
}
|
|
6272
|
-
|
|
6273
|
-
function getColumnWidthsFromSettings(
|
|
6274
|
-
settings: ListSettings
|
|
6275
|
-
): Record<ColumnWidthKey, number> {
|
|
6276
|
-
return Object.fromEntries(
|
|
6277
|
-
COLUMN_WIDTH_KEYS.map((key) => [
|
|
6278
|
-
key
|
|
6279
|
-
typeof settings[key] === 'number' ? settings[key] as number : DEFAULT_COLUMN_WIDTHS[key]
|
|
6280
|
-
])
|
|
6281
|
-
) as Record<ColumnWidthKey, number
|
|
6282
|
-
}
|
|
6283
|
-
|
|
6284
|
-
function getNumericSettingValues<K extends ColumnPaddingLeftKey | ColumnPaddingRightKey | ColumnPaddingBottomKey>(
|
|
6285
|
-
settings: ListSettings
|
|
6286
|
-
keys: readonly K[]
|
|
6287
|
-
fallback = 0
|
|
6288
|
-
): Record<K, number> {
|
|
6289
|
-
return Object.fromEntries(
|
|
6290
|
-
keys.map((key) => [
|
|
6291
|
-
key
|
|
6292
|
-
typeof settings[key] === 'number' ? settings[key] as number : fallback
|
|
6293
|
-
])
|
|
6294
|
-
) as Record<K, number
|
|
6295
|
-
}
|
|
6296
|
-
|
|
6297
|
-
function buildListColumns(
|
|
6298
|
-
columnContentOrder: readonly typeof COLUMN_CONTENT_KEYS[number][]
|
|
6299
|
-
columns: number
|
|
6300
|
-
columnWidthByKey: Record<ColumnWidthKey, number
|
|
6301
|
-
columnPaddingLeftByKey: Record<ColumnPaddingLeftKey, number
|
|
6302
|
-
columnPaddingRightByKey: Record<ColumnPaddingRightKey, number
|
|
6303
|
-
columnPaddingBottomByKey: Record<ColumnPaddingBottomKey, number
|
|
6304
|
-
): ListItemColumn[] {
|
|
6305
|
-
return columnContentOrder.slice(0, columns).map((key, index) => {
|
|
6306
|
-
const paddingLeftKey = COLUMN_PADDING_LEFT_KEYS[index]
|
|
6307
|
-
const paddingRightKey = COLUMN_PADDING_RIGHT_KEYS[index]
|
|
6308
|
-
const paddingBottomKey = COLUMN_PADDING_BOTTOM_KEYS[index]
|
|
6309
|
-
|
|
6310
|
-
return {
|
|
6311
|
-
key
|
|
6312
|
-
textPrefix: COLUMN_CONTENT_KEY_TO_TEXT_PREFIX[key]
|
|
6313
|
-
widthKey: COLUMN_WIDTH_KEYS[index]
|
|
6314
|
-
width: columnWidthByKey[COLUMN_WIDTH_KEYS[index]]
|
|
6315
|
-
paddingLeftKey
|
|
6316
|
-
paddingRightKey
|
|
6317
|
-
paddingBottomKey
|
|
6318
|
-
paddingLeft: columnPaddingLeftByKey[paddingLeftKey]
|
|
6319
|
-
paddingRight: columnPaddingRightByKey[paddingRightKey]
|
|
6320
|
-
paddingBottom: columnPaddingBottomByKey[paddingBottomKey]
|
|
6321
|
-
}
|
|
6322
|
-
})
|
|
6323
|
-
}
|
|
6324
|
-
|
|
6325
|
-
export function List({ settings, content, isEditor, isPreviewMode, activeEvent, layoutId, onUpdateSettings }: ListProps) {
|
|
6326
|
-
const { prefix: P } = useScopedStyles()
|
|
6327
|
-
const showControls = Boolean(isEditor && isPreviewMode)
|
|
6328
|
-
const {
|
|
6329
|
-
columns
|
|
6330
|
-
type
|
|
6331
|
-
wrapperWidth
|
|
6332
|
-
entriesCount
|
|
6333
|
-
cellMinHeight
|
|
6334
|
-
dividerWidth
|
|
6335
|
-
showVisibility
|
|
6336
|
-
cut
|
|
6337
|
-
showCut
|
|
6338
|
-
cutCellMinHeight
|
|
6339
|
-
cutLabel
|
|
6340
|
-
imageSize
|
|
6341
|
-
imageOnHover
|
|
6342
|
-
entryHoverEffect
|
|
6343
|
-
rowPaddingTop
|
|
6344
|
-
rowPaddingBottom
|
|
6345
|
-
rowPaddingTopB
|
|
6346
|
-
columnsOrder
|
|
6347
|
-
textPaddingLR
|
|
6348
|
-
textColor
|
|
6349
|
-
textFontFamily
|
|
6350
|
-
textFontSettings
|
|
6351
|
-
textFontSize
|
|
6352
|
-
textLineHeight
|
|
6353
|
-
textLetterSpacing
|
|
6354
|
-
textWordSpacing
|
|
6355
|
-
textTextAppearance
|
|
6356
|
-
backgroundColor
|
|
6357
|
-
dividerColor
|
|
6358
|
-
textHoverColor
|
|
6359
|
-
backgroundHoverColor
|
|
6360
|
-
dividerHoverColor
|
|
6361
|
-
} = settings
|
|
6362
|
-
|
|
6363
|
-
const [visibleRowCount, setVisibleRowCount] = useState<number | undefined>(undefined)
|
|
6364
|
-
const [hoverImage, setHoverImage] = useState<HoverImageState | null>(null)
|
|
6365
|
-
const showHoverImage = imageOnHover === 'On'
|
|
6366
|
-
const cutEnabled = (cut ?? 0) > 0
|
|
6367
|
-
const isVerticalLayout = type === 'B'
|
|
6368
|
-
const containerRef = useRef<HTMLDivElement>(null)
|
|
6369
|
-
const [designWidth, setDesignWidth] = useState(ARTICLE_DESIGN_WIDTH)
|
|
6370
|
-
const minColumnWidth = getListMinColumnWidth(designWidth)
|
|
6371
|
-
|
|
6372
|
-
const storedTextPaddingLRMax = Math.max(0, ((wrapperWidth ?? 0) - minColumnWidth) / 2)
|
|
6373
|
-
const effectiveTextPaddingLR = Math.min(textPaddingLR ?? 0, storedTextPaddingLRMax)
|
|
6374
|
-
const textPaddingLRHandleWidth = Math.max(effectiveTextPaddingLR, COL_PADDING_HANDLE_WIDTH)
|
|
6375
|
-
const textPaddingLRMaxFraction = ((wrapperWidth ?? 0) + minColumnWidth) / 2
|
|
6376
|
-
|
|
6377
|
-
useLayoutEffect(() => {
|
|
6378
|
-
if (!isEditor) {
|
|
6379
|
-
setDesignWidth(ARTICLE_DESIGN_WIDTH)
|
|
6380
|
-
return
|
|
6381
|
-
}
|
|
6382
|
-
|
|
6383
|
-
const syncDesignWidth = () => {
|
|
6384
|
-
setDesignWidth(getEditorDesignWidth(containerRef.current))
|
|
6385
|
-
}
|
|
6386
|
-
|
|
6387
|
-
syncDesignWidth()
|
|
6388
|
-
|
|
6389
|
-
const observed = containerRef.current
|
|
6390
|
-
if (!observed) {
|
|
6391
|
-
return
|
|
6392
|
-
}
|
|
6393
|
-
|
|
6394
|
-
const observer = new ResizeObserver(syncDesignWidth)
|
|
6395
|
-
observer.observe(observed)
|
|
6396
|
-
|
|
6397
|
-
let pageEl: HTMLElement | null = observed
|
|
6398
|
-
while (pageEl && !pageEl.style.getPropertyValue('--cntrl-article-width')) {
|
|
6399
|
-
pageEl = pageEl.parentElement
|
|
6400
|
-
}
|
|
6401
|
-
if (pageEl) {
|
|
6402
|
-
observer.observe(pageEl)
|
|
6403
|
-
}
|
|
6404
|
-
|
|
6405
|
-
return () => observer.disconnect()
|
|
6406
|
-
}, [isEditor, layoutId])
|
|
6407
|
-
|
|
6408
|
-
useEffect(() => {
|
|
6409
|
-
setVisibleRowCount(undefined)
|
|
6410
|
-
}, [cut, showCut, content, entriesCount])
|
|
6411
|
-
|
|
6412
|
-
const colorVars = buildColorVars(P, {
|
|
6413
|
-
textColor
|
|
6414
|
-
backgroundColor
|
|
6415
|
-
dividerColor
|
|
6416
|
-
textHoverColor
|
|
6417
|
-
backgroundHoverColor
|
|
6418
|
-
dividerHoverColor
|
|
6419
|
-
}, COLOR_VAR_MAP, STATE_KEYS)
|
|
6420
|
-
|
|
6421
|
-
const stateClass = activeEvent && activeEvent !== 'default' ? \`\${P}-state-\${activeEvent}\` : ''
|
|
6422
|
-
const entryHoverClass
|
|
6423
|
-
entryHoverEffect === 'Default'
|
|
6424
|
-
? \`\${P}-entry-hover-default
|
|
6425
|
-
: entryHoverEffect === 'Blinds'
|
|
6426
|
-
? \`\${P}-entry-hover-blinds
|
|
6427
|
-
: ''
|
|
6428
|
-
const wrapperStateClasses = \`\${entryHoverClass} \${stateClass}\`.trim()
|
|
6429
|
-
const showDividerTop = showVisibility?.[0] ?? false
|
|
6430
|
-
const showDividerBottom = showVisibility?.[1] ?? false
|
|
6431
|
-
|
|
6432
|
-
const prevSettingsRef = useRef(settings)
|
|
6433
|
-
const prevLayoutIdRef = useRef(layoutId)
|
|
6434
|
-
|
|
6435
|
-
useEffect(() => {
|
|
6436
|
-
if (!onUpdateSettings || !isEditor) {
|
|
6437
|
-
prevSettingsRef.current = settings
|
|
6438
|
-
prevLayoutIdRef.current = layoutId
|
|
6439
|
-
return
|
|
6440
|
-
}
|
|
6441
|
-
|
|
6442
|
-
if (prevLayoutIdRef.current !== layoutId) {
|
|
6443
|
-
prevSettingsRef.current = settings
|
|
6444
|
-
prevLayoutIdRef.current = layoutId
|
|
6445
|
-
return
|
|
6446
|
-
}
|
|
6447
|
-
|
|
6448
|
-
const prevSettings = prevSettingsRef.current
|
|
6449
|
-
const updatedSettings = applyListSettingsChange(
|
|
6450
|
-
settings
|
|
6451
|
-
prevSettings
|
|
6452
|
-
{ designWidth }
|
|
6453
|
-
)
|
|
6454
|
-
|
|
6455
|
-
prevSettingsRef.current = settings
|
|
6456
|
-
|
|
6457
|
-
if (updatedSettings === settings) {
|
|
6458
|
-
return
|
|
6459
|
-
}
|
|
6460
|
-
|
|
6461
|
-
onUpdateSettings(updatedSettings)
|
|
6462
|
-
}, [settings, onUpdateSettings, isEditor, layoutId, designWidth])
|
|
6463
|
-
|
|
6464
|
-
const columnWidthByKey = useMemo(
|
|
6465
|
-
() => getColumnWidthsFromSettings(settings)
|
|
6466
|
-
[
|
|
6467
|
-
settings.AColumnWidth
|
|
6468
|
-
settings.BColumnWidth
|
|
6469
|
-
settings.CColumnWidth
|
|
6470
|
-
settings.DColumnWidth
|
|
6471
|
-
settings.EColumnWidth
|
|
6472
|
-
]
|
|
6473
|
-
)
|
|
6474
|
-
|
|
6475
|
-
const columnPaddingLeftByKey = useMemo(
|
|
6476
|
-
() => getNumericSettingValues(settings, COLUMN_PADDING_LEFT_KEYS)
|
|
6477
|
-
[
|
|
6478
|
-
settings.AColumnPaddingLeft
|
|
6479
|
-
settings.BColumnPaddingLeft
|
|
6480
|
-
settings.CColumnPaddingLeft
|
|
6481
|
-
settings.DColumnPaddingLeft
|
|
6482
|
-
settings.EColumnPaddingLeft
|
|
6483
|
-
]
|
|
6484
|
-
)
|
|
6485
|
-
|
|
6486
|
-
const columnPaddingRightByKey = useMemo(
|
|
6487
|
-
() => getNumericSettingValues(settings, COLUMN_PADDING_RIGHT_KEYS)
|
|
6488
|
-
[
|
|
6489
|
-
settings.AColumnPaddingRight
|
|
6490
|
-
settings.BColumnPaddingRight
|
|
6491
|
-
settings.CColumnPaddingRight
|
|
6492
|
-
settings.DColumnPaddingRight
|
|
6493
|
-
settings.EColumnPaddingRight
|
|
6494
|
-
]
|
|
6495
|
-
)
|
|
6496
|
-
|
|
6497
|
-
const columnPaddingBottomByKey = useMemo(
|
|
6498
|
-
() => getNumericSettingValues(settings, COLUMN_PADDING_BOTTOM_KEYS)
|
|
6499
|
-
[
|
|
6500
|
-
settings.AColumnPaddingBottom
|
|
6501
|
-
settings.BColumnPaddingBottom
|
|
6502
|
-
settings.CColumnPaddingBottom
|
|
6503
|
-
settings.DColumnPaddingBottom
|
|
6504
|
-
settings.EColumnPaddingBottom
|
|
6505
|
-
]
|
|
6506
|
-
)
|
|
6507
|
-
|
|
6508
|
-
const columnContentOrder = useMemo((): typeof COLUMN_CONTENT_KEYS[number][] => {
|
|
6509
|
-
if (Array.isArray(columnsOrder) && columnsOrder.length > 0) {
|
|
6510
|
-
return columnsOrder as typeof COLUMN_CONTENT_KEYS[number][]
|
|
6511
|
-
}
|
|
6512
|
-
return [...COLUMN_CONTENT_KEYS]
|
|
6513
|
-
}, [columnsOrder])
|
|
6514
|
-
|
|
6515
|
-
const listColumns = useMemo(
|
|
6516
|
-
() => buildListColumns(
|
|
6517
|
-
columnContentOrder
|
|
6518
|
-
columns
|
|
6519
|
-
columnWidthByKey
|
|
6520
|
-
columnPaddingLeftByKey
|
|
6521
|
-
columnPaddingRightByKey
|
|
6522
|
-
columnPaddingBottomByKey
|
|
6523
|
-
)
|
|
6524
|
-
[columnContentOrder, columns, columnWidthByKey, columnPaddingLeftByKey, columnPaddingRightByKey, columnPaddingBottomByKey]
|
|
6525
|
-
)
|
|
6526
|
-
|
|
6527
|
-
const resolvedContentWidth = getListEffectiveContentWidth(settings)
|
|
6528
|
-
|
|
6529
|
-
const storedColumnWidths = useMemo(
|
|
6530
|
-
() => COLUMN_WIDTH_KEYS.slice(0, columns).map((key) => columnWidthByKey[key])
|
|
6531
|
-
[columns, columnWidthByKey]
|
|
6532
|
-
)
|
|
6533
|
-
|
|
6534
|
-
const resolvedColumnWidths = useMemo(
|
|
6535
|
-
() => resolveListColumnWidths(columns, resolvedContentWidth, columnWidthByKey)
|
|
6536
|
-
[columns, resolvedContentWidth, columnWidthByKey]
|
|
6537
|
-
)
|
|
6538
|
-
|
|
6539
|
-
const effectiveColumnWidths = useMemo(
|
|
6540
|
-
() => getEffectiveListColumnWidths(columns, resolvedContentWidth, columnWidthByKey)
|
|
6541
|
-
[columns, resolvedContentWidth, columnWidthByKey]
|
|
6542
|
-
)
|
|
6543
|
-
|
|
6544
|
-
const effectiveColumnPaddings = useMemo(
|
|
6545
|
-
()
|
|
6546
|
-
listColumns.map((col, index)
|
|
6547
|
-
resolveListColumnPadding(
|
|
6548
|
-
effectiveColumnWidths[index] ?? 0
|
|
6549
|
-
col.paddingLeft
|
|
6550
|
-
col.paddingRight
|
|
6551
|
-
))
|
|
6552
|
-
[listColumns, effectiveColumnWidths]
|
|
6553
|
-
)
|
|
6554
|
-
|
|
6555
|
-
const allRows: ListItemRow[] = useMemo(() => {
|
|
6556
|
-
const resEntriesCount = entriesCount === 0 ? Infinity : entriesCount
|
|
6557
|
-
const items = (content ?? []).slice(0, resEntriesCount)
|
|
6558
|
-
|
|
6559
|
-
return items.map((item, index) => ({
|
|
6560
|
-
id: index
|
|
6561
|
-
cells: Object.fromEntries(
|
|
6562
|
-
COLUMN_CONTENT_KEYS.map((key) => [key, item[key] ?? ''])
|
|
6563
|
-
)
|
|
6564
|
-
image: item.image
|
|
6565
|
-
link: item.link
|
|
6566
|
-
}))
|
|
6567
|
-
}, [content, entriesCount])
|
|
6568
|
-
|
|
6569
|
-
const effectiveVisibleCount = cutEnabled
|
|
6570
|
-
? (visibleRowCount ?? cut)
|
|
6571
|
-
: allRows.length
|
|
6572
|
-
|
|
6573
|
-
const visibleRows = useMemo(() => {
|
|
6574
|
-
if (cutEnabled) {
|
|
6575
|
-
return allRows.slice(0, effectiveVisibleCount)
|
|
6576
|
-
}
|
|
6577
|
-
return allRows
|
|
6578
|
-
}, [allRows, cutEnabled, effectiveVisibleCount])
|
|
6579
|
-
|
|
6580
|
-
const showCutLabel = cutEnabled && effectiveVisibleCount < allRows.length
|
|
6581
|
-
|
|
6582
|
-
const hasBetweenItemDividers = visibleRows.length > 1 || showCutLabel
|
|
6583
|
-
const dividerClassNames = [
|
|
6584
|
-
showDividerTop ? \`\${P}-divider-top\` : ''
|
|
6585
|
-
showDividerBottom || hasBetweenItemDividers ? \`\${P}-divider-bottom\` : ''
|
|
6586
|
-
].filter(Boolean).join(' ')
|
|
6587
|
-
|
|
6588
|
-
const handleShowMore = () => {
|
|
6589
|
-
const currentVisible = visibleRowCount ?? cut
|
|
6590
|
-
if (!showCut) {
|
|
6591
|
-
setVisibleRowCount(allRows.length)
|
|
6592
|
-
return
|
|
6593
|
-
}
|
|
6594
|
-
setVisibleRowCount(Math.min(currentVisible + showCut, allRows.length))
|
|
6595
|
-
}
|
|
6596
|
-
|
|
6597
|
-
const scaled = (v: number) => scalingValue(v, isEditor ?? false)
|
|
6598
|
-
const resolvedRowPaddingTop = isVerticalLayout
|
|
6599
|
-
? (rowPaddingTopB ?? 0)
|
|
6600
|
-
: (rowPaddingTop ?? 0)
|
|
6601
|
-
const resolvedRowPaddingBottom = rowPaddingBottom ?? 0
|
|
6602
|
-
const resolvedCellMinHeight = cellMinHeight ?? 0
|
|
6603
|
-
const rowPaddingTopControlKey = isVerticalLayout ? 'rowPaddingTopB' : 'rowPaddingTop'
|
|
6604
|
-
const firstColumn = listColumns[0]
|
|
6605
|
-
const lastColumn = listColumns[listColumns.length - 1]
|
|
6606
|
-
const firstColumnEffectivePadding = effectiveColumnPaddings[0]
|
|
6607
|
-
const lastColumnEffectivePadding = effectiveColumnPaddings[effectiveColumnPaddings.length - 1]
|
|
6608
|
-
const firstColumnPaddingLeftWidth = firstColumn && firstColumnEffectivePadding
|
|
6609
|
-
? Math.max(firstColumnEffectivePadding.paddingLeft, COL_PADDING_HANDLE_WIDTH)
|
|
6610
|
-
: 0
|
|
6611
|
-
const lastColumnPaddingRightWidth = lastColumn && lastColumnEffectivePadding
|
|
6612
|
-
? Math.max(lastColumnEffectivePadding.paddingRight, COL_PADDING_HANDLE_WIDTH)
|
|
6613
|
-
: 0
|
|
6614
|
-
const columnsRightEdge = resolvedContentWidth
|
|
6615
|
-
|
|
6616
|
-
const getHoverImagePosition = (event: React.MouseEvent) => {
|
|
6617
|
-
const container = containerRef.current
|
|
6618
|
-
if (!container) {
|
|
6619
|
-
return { x: 0, y: 0 }
|
|
6620
|
-
}
|
|
6621
|
-
|
|
6622
|
-
const rect = container.getBoundingClientRect()
|
|
6623
|
-
return {
|
|
6624
|
-
x: event.clientX - rect.left + HOVER_IMAGE_CURSOR_OFFSET
|
|
6625
|
-
y: event.clientY - rect.top + HOVER_IMAGE_CURSOR_OFFSET
|
|
6626
|
-
}
|
|
6627
|
-
}
|
|
6628
|
-
|
|
6629
|
-
const handleRowMouseEnter = (row: ListItemRow, event: React.MouseEvent) => {
|
|
6630
|
-
if (!showHoverImage) return
|
|
6631
|
-
|
|
6632
|
-
const image = row.image
|
|
6633
|
-
if (!image?.url) {
|
|
6634
|
-
setHoverImage(null)
|
|
6635
|
-
return
|
|
6636
|
-
}
|
|
6637
|
-
|
|
6638
|
-
const { x, y } = getHoverImagePosition(event)
|
|
6639
|
-
const minWidth = imageSize?.min ?? 80
|
|
6640
|
-
const maxWidth = imageSize?.max ?? 320
|
|
6641
|
-
const widthPx = hoverImage?.rowId === row.id
|
|
6642
|
-
? hoverImage.widthPx
|
|
6643
|
-
: randomBetween(minWidth, maxWidth)
|
|
6644
|
-
|
|
6645
|
-
setHoverImage({
|
|
6646
|
-
rowId: row.id
|
|
6647
|
-
url: image.url
|
|
6648
|
-
objectFit: image.objectFit ?? 'cover'
|
|
6649
|
-
widthPx
|
|
6650
|
-
x
|
|
6651
|
-
y
|
|
6652
|
-
})
|
|
6653
|
-
}
|
|
6654
|
-
|
|
6655
|
-
const handleWrapperMouseMove = (event: React.MouseEvent) => {
|
|
6656
|
-
if (!showHoverImage || !hoverImage) return
|
|
6657
|
-
|
|
6658
|
-
const { x, y } = getHoverImagePosition(event)
|
|
6659
|
-
setHoverImage((prev) => {
|
|
6660
|
-
if (!prev) return prev
|
|
6661
|
-
if (prev.x === x && prev.y === y) return prev
|
|
6662
|
-
return { ...prev, x, y }
|
|
6663
|
-
})
|
|
6664
|
-
}
|
|
6665
|
-
|
|
6666
|
-
const handleWrapperMouseLeave = () => {
|
|
6667
|
-
setHoverImage(null)
|
|
6668
|
-
}
|
|
6669
|
-
|
|
6670
|
-
const hasBaselineColumn = useMemo(
|
|
6671
|
-
()
|
|
6672
|
-
!isVerticalLayout
|
|
6673
|
-
COLUMN_TEXT_PREFIXES.some((prefix) => {
|
|
6674
|
-
const columnLetter = prefix.charAt(0)
|
|
6675
|
-
const valign = settings[\`\${prefix}VerticalAlign\` as ListColumnVerticalAlignKey]
|
|
6676
|
-
return isActiveBaselineVAlign(valign, settings, columnLetter)
|
|
6677
|
-
})
|
|
6678
|
-
[
|
|
6679
|
-
isVerticalLayout
|
|
6680
|
-
settings
|
|
6681
|
-
settings.AColumnVerticalAlign
|
|
6682
|
-
settings.BColumnVerticalAlign
|
|
6683
|
-
settings.CColumnVerticalAlign
|
|
6684
|
-
settings.DColumnVerticalAlign
|
|
6685
|
-
settings.EColumnVerticalAlign
|
|
6686
|
-
]
|
|
6687
|
-
)
|
|
6688
|
-
|
|
6689
|
-
useLayoutEffect(() => {
|
|
6690
|
-
const container = containerRef.current
|
|
6691
|
-
if (!container) return
|
|
6692
|
-
|
|
6693
|
-
const clearBaselineStyles = () => {
|
|
6694
|
-
container.querySelectorAll<HTMLElement>('[data-list-col]').forEach((el) => {
|
|
6695
|
-
el.style.transform = ''
|
|
6696
|
-
const listCol = el.querySelector<HTMLElement>(\`.\${P}-list-col\`)
|
|
6697
|
-
if (listCol) {
|
|
6698
|
-
listCol.style.minHeight = ''
|
|
6699
|
-
listCol.style.height = ''
|
|
6700
|
-
}
|
|
6701
|
-
const title = el.querySelector<HTMLElement>(\`.\${P}-list-col-title\`)
|
|
6702
|
-
if (title) {
|
|
6703
|
-
title.style.transform = ''
|
|
6704
|
-
}
|
|
6705
|
-
})
|
|
6706
|
-
}
|
|
6707
|
-
|
|
6708
|
-
if (isVerticalLayout || !hasBaselineColumn) {
|
|
6709
|
-
clearBaselineStyles()
|
|
6710
|
-
return
|
|
6711
|
-
}
|
|
6712
|
-
|
|
6713
|
-
const applyBaselines = () => {
|
|
6714
|
-
container.querySelectorAll<HTMLElement>('[data-list-row]').forEach((rowEl) => {
|
|
6715
|
-
const cols = Array.from(rowEl.querySelectorAll<HTMLElement>('[data-list-col]'))
|
|
6716
|
-
cols.forEach((el) => {
|
|
6717
|
-
el.style.transform = ''
|
|
6718
|
-
const listCol = el.querySelector<HTMLElement>(\`.\${P}-list-col\`)
|
|
6719
|
-
if (listCol) {
|
|
6720
|
-
listCol.style.minHeight = ''
|
|
6721
|
-
listCol.style.height = ''
|
|
6722
|
-
}
|
|
6723
|
-
const title = el.querySelector<HTMLElement>(\`.\${P}-list-col-title\`)
|
|
6724
|
-
if (title) {
|
|
6725
|
-
title.style.transform = ''
|
|
6726
|
-
}
|
|
6727
|
-
})
|
|
6728
|
-
|
|
6729
|
-
syncRowListColHeights(rowEl, cols, \`\${P}-list-col\`)
|
|
6730
|
-
void rowEl.offsetHeight
|
|
6731
|
-
const rowTop = rowEl.getBoundingClientRect().top
|
|
6732
|
-
|
|
6733
|
-
type ColInfo = {
|
|
6734
|
-
el: HTMLElement
|
|
6735
|
-
titleEl: HTMLElement | null
|
|
6736
|
-
letter: string
|
|
6737
|
-
kind: string
|
|
6738
|
-
anchor: string | null
|
|
6739
|
-
}
|
|
6740
|
-
|
|
6741
|
-
const probeClassName = \`\${P}-baseline-probe
|
|
6742
|
-
const byLetter = new Map<string, ColInfo>()
|
|
6743
|
-
const infos: ColInfo[] = cols.map((el) => {
|
|
6744
|
-
const titleEl = el.querySelector<HTMLElement>(\`.\${P}-list-col-title\`)
|
|
6745
|
-
const info: ColInfo = {
|
|
6746
|
-
el
|
|
6747
|
-
titleEl
|
|
6748
|
-
letter: el.getAttribute('data-col-letter') ?? ''
|
|
6749
|
-
kind: el.getAttribute('data-valign') ?? 'top'
|
|
6750
|
-
anchor: el.getAttribute('data-valign-anchor')
|
|
6751
|
-
}
|
|
6752
|
-
byLetter.set(info.letter, info)
|
|
6753
|
-
return info
|
|
6754
|
-
})
|
|
6755
|
-
|
|
6756
|
-
const finalBaseline = new Map<string, number>()
|
|
6757
|
-
const resolve = (info: ColInfo, stack: Set<string>): number => {
|
|
6758
|
-
const cached = finalBaseline.get(info.letter)
|
|
6759
|
-
if (cached !== undefined) return cached
|
|
6760
|
-
|
|
6761
|
-
const anchor = info.anchor ? byLetter.get(info.anchor) : undefined
|
|
6762
|
-
if (info.kind !== 'baseline' || !anchor || stack.has(info.letter)) {
|
|
6763
|
-
const baseline = measureColumnFirstLineBaselineOffset(
|
|
6764
|
-
info
|
|
6765
|
-
rowTop
|
|
6766
|
-
\`\${P}-list-col
|
|
6767
|
-
probeClassName
|
|
6768
|
-
)
|
|
6769
|
-
finalBaseline.set(info.letter, baseline)
|
|
6770
|
-
return baseline
|
|
6771
|
-
}
|
|
6772
|
-
|
|
6773
|
-
stack.add(info.letter)
|
|
6774
|
-
const anchorBaseline = resolve(anchor, stack)
|
|
6775
|
-
stack.delete(info.letter)
|
|
6776
|
-
|
|
6777
|
-
const followerNatural = measureColumnFirstLineBaselineOffset(
|
|
6778
|
-
info
|
|
6779
|
-
rowTop
|
|
6780
|
-
\`\${P}-list-col
|
|
6781
|
-
probeClassName
|
|
6782
|
-
)
|
|
6783
|
-
const shift = anchorBaseline - followerNatural
|
|
6784
|
-
applyBaselineTitleShift(info.titleEl, shift)
|
|
6785
|
-
|
|
6786
|
-
const result = measureColumnFirstLineBaselineOffset(
|
|
6787
|
-
info
|
|
6788
|
-
rowTop
|
|
6789
|
-
\`\${P}-list-col
|
|
6790
|
-
probeClassName
|
|
6791
|
-
)
|
|
6792
|
-
finalBaseline.set(info.letter, result)
|
|
6793
|
-
return result
|
|
6794
|
-
}
|
|
6795
|
-
|
|
6796
|
-
infos.forEach((info) => resolve(info, new Set<string>()))
|
|
6797
|
-
})
|
|
6798
|
-
}
|
|
6799
|
-
|
|
6800
|
-
applyBaselines()
|
|
6801
|
-
|
|
6802
|
-
const observer = new ResizeObserver(() => applyBaselines())
|
|
6803
|
-
observer.observe(container)
|
|
6804
|
-
|
|
6805
|
-
let cancelled = false
|
|
6806
|
-
if (typeof document !== 'undefined' && document.fonts?.ready) {
|
|
6807
|
-
document.fonts.ready.then(() => {
|
|
6808
|
-
if (!cancelled) applyBaselines()
|
|
6809
|
-
})
|
|
6810
|
-
}
|
|
6811
|
-
|
|
6812
|
-
return () => {
|
|
6813
|
-
cancelled = true
|
|
6814
|
-
observer.disconnect()
|
|
6815
|
-
clearBaselineStyles()
|
|
6816
|
-
}
|
|
6817
|
-
}, [
|
|
6818
|
-
hasBaselineColumn
|
|
6819
|
-
isVerticalLayout
|
|
6820
|
-
settings
|
|
6821
|
-
content
|
|
6822
|
-
designWidth
|
|
6823
|
-
visibleRows
|
|
6824
|
-
effectiveColumnWidths
|
|
6825
|
-
])
|
|
6826
|
-
|
|
6827
|
-
return (
|
|
6828
|
-
|
|
6829
|
-
<style dangerouslySetInnerHTML={{ __html: getCSS(P) }}
|
|
6830
|
-
<div style={colorVars}
|
|
6831
|
-
<div
|
|
6832
|
-
ref={containerRef}
|
|
6833
|
-
className={\`\${P}-wrapper \${wrapperStateClasses}\${dividerClassNames ? \` \${dividerClassNames}\` : ''}\${isVerticalLayout ? \` \${P}-type-b\` : ''}\`.trim()}
|
|
6834
|
-
style={{
|
|
6835
|
-
width: scalingValue(wrapperWidth ?? 0, isEditor)
|
|
6836
|
-
}}
|
|
6837
|
-
onMouseMove={showHoverImage ? handleWrapperMouseMove : undefined}
|
|
6838
|
-
onMouseLeave={showHoverImage ? handleWrapperMouseLeave : undefined}
|
|
6839
|
-
|
|
6840
|
-
<div style={{ width: '100%' }}
|
|
6841
|
-
{visibleRows.map((row, rowIdx) => {
|
|
6842
|
-
const hasLink = (row.link?.length ?? 0) > 0
|
|
6843
|
-
const RowElement = hasLink ? 'a' : 'div'
|
|
6844
|
-
const rowStyle = getEntryDividerWidths(
|
|
6845
|
-
rowIdx
|
|
6846
|
-
visibleRows.length
|
|
6847
|
-
showDividerTop
|
|
6848
|
-
showDividerBottom
|
|
6849
|
-
showCutLabel
|
|
6850
|
-
dividerWidth ?? 0
|
|
6851
|
-
isEditor ?? false
|
|
6852
|
-
)
|
|
6853
|
-
|
|
6854
|
-
return (
|
|
6855
|
-
<RowElement
|
|
6856
|
-
key={row.id}
|
|
6857
|
-
className={\`\${P}-list-item\${hasLink ? \` \${P}-list-item-has-link\` : ''}\`}
|
|
6858
|
-
{...(hasLink ? { href: row.link, target: '_blank' } : {})}
|
|
6859
|
-
style={rowStyle}
|
|
6860
|
-
onMouseEnter={showHoverImage ? (event) => handleRowMouseEnter(row, event) : undefined}
|
|
6861
|
-
|
|
6862
|
-
{(resolvedRowPaddingTop > 0 || showControls) && (
|
|
6863
|
-
<div
|
|
6864
|
-
{...(showControls ? {
|
|
6865
|
-
'data-controls': rowPaddingTopControlKey
|
|
6866
|
-
'data-controls-axis': 'y'
|
|
6867
|
-
'data-controls-min': '0'
|
|
6868
|
-
} : {})}
|
|
6869
|
-
className={\`\${P}-row-padding-handle\`}
|
|
6870
|
-
style={{ height: scaled(resolvedRowPaddingTop) }}
|
|
6871
|
-
|
|
6872
|
-
)}
|
|
6873
|
-
<div
|
|
6874
|
-
className={\`\${P}-list-cols-row\${isVerticalLayout ? '' : \` \${P}-list-cols-row-h\`}\`}
|
|
6875
|
-
{...(isVerticalLayout ? {} : { 'data-list-row': '' })}
|
|
6876
|
-
style={isVerticalLayout ? undefined : { minHeight: scaled(resolvedCellMinHeight) }}
|
|
6877
|
-
|
|
6878
|
-
{listColumns.map((col, colIndex) => {
|
|
6879
|
-
const isLastColumn = colIndex === listColumns.length - 1
|
|
6880
|
-
const effectivePadding = effectiveColumnPaddings[colIndex]
|
|
6881
|
-
const columnPaddingBottom = col.paddingBottom
|
|
6882
|
-
const hasColumnText = hasListColumnText(row.cells[col.key])
|
|
6883
|
-
const showColumnPaddingBottom = isVerticalLayout
|
|
6884
|
-
&& hasColumnText
|
|
6885
|
-
&& (columnPaddingBottom > 0 || showControls)
|
|
6886
|
-
const columnSizeStyle = isVerticalLayout
|
|
6887
|
-
? { minHeight: scaled(resolvedCellMinHeight) }
|
|
6888
|
-
: (isLastColumn ? {} : { width: scaled(effectiveColumnWidths[colIndex]) })
|
|
6889
|
-
const columnPaddingStyle = isVerticalLayout
|
|
6890
|
-
? {
|
|
6891
|
-
paddingLeft: scaled(effectiveTextPaddingLR)
|
|
6892
|
-
paddingRight: scaled(effectiveTextPaddingLR)
|
|
6893
|
-
}
|
|
6894
|
-
: {
|
|
6895
|
-
paddingLeft: scaled(effectivePadding.paddingLeft)
|
|
6896
|
-
paddingRight: scaled(effectivePadding.paddingRight)
|
|
6897
|
-
}
|
|
6898
|
-
const columnLetter = col.textPrefix.charAt(0)
|
|
6899
|
-
const vAlign = isVerticalLayout
|
|
6900
|
-
? { kind: 'top' as const }
|
|
6901
|
-
: resolveColumnVerticalAlign(
|
|
6902
|
-
settings[\`\${col.textPrefix}VerticalAlign\` as ListColumnVerticalAlignKey]
|
|
6903
|
-
settings
|
|
6904
|
-
columnLetter
|
|
6905
|
-
)
|
|
6906
|
-
|
|
6907
|
-
return (
|
|
6908
|
-
<div
|
|
6909
|
-
key={col.key}
|
|
6910
|
-
{...(isVerticalLayout
|
|
6911
|
-
? {}
|
|
6912
|
-
: {
|
|
6913
|
-
'data-list-col': ''
|
|
6914
|
-
'data-col-letter': columnLetter
|
|
6915
|
-
'data-valign': vAlign.kind
|
|
6916
|
-
...(vAlign.kind === 'baseline'
|
|
6917
|
-
? { 'data-valign-anchor': vAlign.anchorLetter }
|
|
6918
|
-
: {})
|
|
6919
|
-
})}
|
|
6920
|
-
|
|
6921
|
-
<div
|
|
6922
|
-
className={\`\${P}-list-col\${isLastColumn ? \` \${P}-list-col-last\` : ''}\`}
|
|
6923
|
-
style={{
|
|
6924
|
-
...columnPaddingStyle
|
|
6925
|
-
...columnSizeStyle
|
|
6926
|
-
}}
|
|
6927
|
-
data-test={col.width}
|
|
6928
|
-
|
|
6929
|
-
<span
|
|
6930
|
-
className={getListColumnTitleClassName(
|
|
6931
|
-
settings
|
|
6932
|
-
col.textPrefix
|
|
6933
|
-
\`\${P}-list-col-title
|
|
6934
|
-
\`\${P}-text-tight-leading
|
|
6935
|
-
)}
|
|
6936
|
-
style={{
|
|
6937
|
-
...listColumnTextFieldsToCss(resolveListColumnTextFields(settings, col.textPrefix), isEditor)
|
|
6938
|
-
...getListColumnTitleVars(settings, col.textPrefix, P, isEditor)
|
|
6939
|
-
...(!isVerticalLayout ? vAlignToTitleStyle(vAlign.kind) : {})
|
|
6940
|
-
}}
|
|
6941
|
-
|
|
6942
|
-
{row.cells[col.key] ?? null}
|
|
6943
|
-
</span
|
|
6944
|
-
</div
|
|
6945
|
-
{showColumnPaddingBottom && (
|
|
6946
|
-
<div
|
|
6947
|
-
{...(showControls ? {
|
|
6948
|
-
'data-controls': col.paddingBottomKey
|
|
6949
|
-
'data-controls-axis': 'y'
|
|
6950
|
-
'data-controls-min': '0'
|
|
6951
|
-
} : {})}
|
|
6952
|
-
className={\`\${P}-row-padding-handle\`}
|
|
6953
|
-
style={{ height: scaled(columnPaddingBottom) }}
|
|
6954
|
-
|
|
6955
|
-
)}
|
|
6956
|
-
</div
|
|
6957
|
-
)
|
|
6958
|
-
})}
|
|
6959
|
-
</div
|
|
6960
|
-
{!isVerticalLayout && (resolvedRowPaddingBottom > 0 || showControls) && (
|
|
6961
|
-
<div
|
|
6962
|
-
{...(showControls ? {
|
|
6963
|
-
'data-controls': 'rowPaddingBottom'
|
|
6964
|
-
'data-controls-axis': 'y'
|
|
6965
|
-
'data-controls-min': '0'
|
|
6966
|
-
} : {})}
|
|
6967
|
-
className={\`\${P}-row-padding-handle\`}
|
|
6968
|
-
style={{ height: scaled(resolvedRowPaddingBottom) }}
|
|
6969
|
-
|
|
6970
|
-
)}
|
|
6971
|
-
</RowElement
|
|
6972
|
-
)
|
|
6973
|
-
})}
|
|
6974
|
-
{showCutLabel && (
|
|
6975
|
-
<button
|
|
6976
|
-
type="button"
|
|
6977
|
-
className={\`\${P}-cut-item\`}
|
|
6978
|
-
style={{
|
|
6979
|
-
minHeight: scaled(cutCellMinHeight ?? 0)
|
|
6980
|
-
...getCutItemDividerWidths(
|
|
6981
|
-
showDividerBottom
|
|
6982
|
-
dividerWidth ?? 0
|
|
6983
|
-
isEditor ?? false
|
|
6984
|
-
)
|
|
6985
|
-
}}
|
|
6986
|
-
onClick={handleShowMore}
|
|
6987
|
-
|
|
6988
|
-
<div
|
|
6989
|
-
className={\`\${P}-list-cols-row\`}
|
|
6990
|
-
style={
|
|
6991
|
-
isVerticalLayout
|
|
6992
|
-
? {
|
|
6993
|
-
paddingLeft: scaled(effectiveTextPaddingLR)
|
|
6994
|
-
paddingRight: scaled(effectiveTextPaddingLR)
|
|
6995
|
-
}
|
|
6996
|
-
: { justifyContent: 'center' }
|
|
6997
|
-
}
|
|
6998
|
-
|
|
6999
|
-
<span
|
|
7000
|
-
className={getListColumnTitleClassName(
|
|
7001
|
-
settings
|
|
7002
|
-
CUT_LABEL_TEXT_PREFIX
|
|
7003
|
-
\`\${P}-cut-label
|
|
7004
|
-
\`\${P}-text-tight-leading
|
|
7005
|
-
)}
|
|
7006
|
-
style={{
|
|
7007
|
-
...listColumnTextFieldsToCss(resolveListColumnTextFields(settings, CUT_LABEL_TEXT_PREFIX), isEditor)
|
|
7008
|
-
...getListColumnTitleVars(settings, CUT_LABEL_TEXT_PREFIX, P, isEditor)
|
|
7009
|
-
}}
|
|
7010
|
-
|
|
7011
|
-
{cutLabel}
|
|
7012
|
-
</span
|
|
7013
|
-
</div
|
|
7014
|
-
</button
|
|
7015
|
-
)}
|
|
7016
|
-
</div
|
|
7017
|
-
{showControls && !isVerticalLayout && firstColumn && lastColumn && (
|
|
7018
|
-
<div key="column-edge-padding-handles" style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}
|
|
7019
|
-
<div
|
|
7020
|
-
data-controls={firstColumn.paddingLeftKey}
|
|
7021
|
-
data-controls-axis="x"
|
|
7022
|
-
data-controls-variant="column-padding"
|
|
7023
|
-
data-controls-min="0"
|
|
7024
|
-
data-controls-max-fraction={String(
|
|
7025
|
-
effectiveColumnWidths[0] - (firstColumnEffectivePadding?.paddingRight ?? 0)
|
|
7026
|
-
)}
|
|
7027
|
-
data-controls-static-handle=""
|
|
7028
|
-
className={\`\${P}-padding-control-handle\`}
|
|
7029
|
-
style={{
|
|
7030
|
-
position: 'absolute'
|
|
7031
|
-
top: 0
|
|
7032
|
-
left: 0
|
|
7033
|
-
width: scaled(firstColumnPaddingLeftWidth)
|
|
7034
|
-
height: '100%'
|
|
7035
|
-
pointerEvents: 'auto'
|
|
7036
|
-
zIndex: 2
|
|
7037
|
-
}}
|
|
7038
|
-
|
|
7039
|
-
<div
|
|
7040
|
-
data-controls={lastColumn.paddingRightKey}
|
|
7041
|
-
data-controls-axis="x"
|
|
7042
|
-
data-controls-variant="column-padding"
|
|
7043
|
-
data-controls-reverse=""
|
|
7044
|
-
data-controls-min="0"
|
|
7045
|
-
data-controls-max-fraction={String(
|
|
7046
|
-
effectiveColumnWidths[listColumns.length - 1]
|
|
7047
|
-
- (lastColumnEffectivePadding?.paddingLeft ?? 0)
|
|
7048
|
-
)}
|
|
7049
|
-
data-controls-static-handle=""
|
|
7050
|
-
className={\`\${P}-padding-control-handle\`}
|
|
7051
|
-
style={{
|
|
7052
|
-
position: 'absolute'
|
|
7053
|
-
top: 0
|
|
7054
|
-
left: scaled(columnsRightEdge - lastColumnPaddingRightWidth)
|
|
7055
|
-
width: scaled(lastColumnPaddingRightWidth)
|
|
7056
|
-
height: '100%'
|
|
7057
|
-
pointerEvents: 'auto'
|
|
7058
|
-
zIndex: 2
|
|
7059
|
-
}}
|
|
7060
|
-
|
|
7061
|
-
</div
|
|
7062
|
-
)}
|
|
7063
|
-
{showControls && !isVerticalLayout && listColumns.slice(0, -1).map((col, colIndex) => {
|
|
7064
|
-
const nextCol = listColumns[colIndex + 1]
|
|
7065
|
-
const maxColumnWidth = getColumnMaxWidth(
|
|
7066
|
-
colIndex
|
|
7067
|
-
resolvedColumnWidths
|
|
7068
|
-
storedColumnWidths
|
|
7069
|
-
resolvedContentWidth
|
|
7070
|
-
)
|
|
7071
|
-
const boundaryOffset = resolvedColumnWidths.slice(0, colIndex + 1).reduce((sum, width) => sum + width, 0)
|
|
7072
|
-
const colEffectivePadding = effectiveColumnPaddings[colIndex]
|
|
7073
|
-
const nextColEffectivePadding = effectiveColumnPaddings[colIndex + 1]
|
|
7074
|
-
const paddingRightWidth = Math.max(
|
|
7075
|
-
colEffectivePadding.paddingRight
|
|
7076
|
-
COL_PADDING_HANDLE_WIDTH
|
|
7077
|
-
)
|
|
7078
|
-
const paddingLeftWidth = Math.max(
|
|
7079
|
-
nextColEffectivePadding.paddingLeft
|
|
7080
|
-
COL_PADDING_HANDLE_WIDTH
|
|
7081
|
-
)
|
|
7082
|
-
const columnWidthHandleOffset = boundaryOffset - COL_RESIZE_HANDLE_WIDTH / 2
|
|
7083
|
-
|
|
7084
|
-
return (
|
|
7085
|
-
<div key={\`\${col.widthKey}-junction\`} style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}
|
|
7086
|
-
<div
|
|
7087
|
-
data-controls={col.paddingRightKey}
|
|
7088
|
-
data-controls-axis="x"
|
|
7089
|
-
data-controls-variant="column-padding"
|
|
7090
|
-
data-controls-reverse=""
|
|
7091
|
-
data-controls-min="0"
|
|
7092
|
-
data-controls-max-fraction={String(
|
|
7093
|
-
effectiveColumnWidths[colIndex] - colEffectivePadding.paddingLeft
|
|
7094
|
-
)}
|
|
7095
|
-
data-controls-static-handle=""
|
|
7096
|
-
className={\`\${P}-padding-control-handle\`}
|
|
7097
|
-
style={{
|
|
7098
|
-
position: 'absolute'
|
|
7099
|
-
top: 0
|
|
7100
|
-
left: scaled(boundaryOffset - paddingRightWidth)
|
|
7101
|
-
width: scaled(paddingRightWidth)
|
|
7102
|
-
height: '100%'
|
|
7103
|
-
pointerEvents: 'auto'
|
|
7104
|
-
zIndex: 2
|
|
7105
|
-
}}
|
|
7106
|
-
|
|
7107
|
-
<div
|
|
7108
|
-
data-controls={col.widthKey}
|
|
7109
|
-
data-controls-axis="x"
|
|
7110
|
-
data-controls-min={String(MIN_COLUMN_WIDTH_PX)}
|
|
7111
|
-
data-controls-max-fraction={String(maxColumnWidth)}
|
|
7112
|
-
data-controls-variant="column-width"
|
|
7113
|
-
className={\`\${P}-col-resize-handle\`}
|
|
7114
|
-
style={{
|
|
7115
|
-
position: 'absolute'
|
|
7116
|
-
top: '0px'
|
|
7117
|
-
left: scaled(columnWidthHandleOffset)
|
|
7118
|
-
width: scaled(COL_RESIZE_HANDLE_WIDTH)
|
|
7119
|
-
height: 'calc(100%)'
|
|
7120
|
-
pointerEvents: 'auto'
|
|
7121
|
-
zIndex: 4
|
|
7122
|
-
}}
|
|
7123
|
-
|
|
7124
|
-
<div
|
|
7125
|
-
data-controls={nextCol.paddingLeftKey}
|
|
7126
|
-
data-controls-axis="x"
|
|
7127
|
-
data-controls-variant="column-padding"
|
|
7128
|
-
data-controls-min="0"
|
|
7129
|
-
data-controls-max-fraction={String(
|
|
7130
|
-
effectiveColumnWidths[colIndex + 1] - nextColEffectivePadding.paddingRight
|
|
7131
|
-
)}
|
|
7132
|
-
data-controls-static-handle=""
|
|
7133
|
-
className={\`\${P}-padding-control-handle\`}
|
|
7134
|
-
style={{
|
|
7135
|
-
position: 'absolute'
|
|
7136
|
-
top: 0
|
|
7137
|
-
left: scaled(boundaryOffset)
|
|
7138
|
-
width: scaled(paddingLeftWidth)
|
|
7139
|
-
height: '100%'
|
|
7140
|
-
pointerEvents: 'auto'
|
|
7141
|
-
zIndex: 2
|
|
7142
|
-
}}
|
|
7143
|
-
|
|
7144
|
-
</div
|
|
7145
|
-
)
|
|
7146
|
-
})}
|
|
7147
|
-
{showControls && isVerticalLayout && (
|
|
7148
|
-
<div key="text-padding-lr-handles" style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}
|
|
7149
|
-
<div
|
|
7150
|
-
data-controls="textPaddingLR"
|
|
7151
|
-
data-controls-paired=""
|
|
7152
|
-
data-controls-axis="x"
|
|
7153
|
-
data-controls-min="0"
|
|
7154
|
-
data-controls-max-fraction={String(textPaddingLRMaxFraction)}
|
|
7155
|
-
data-controls-static-handle=""
|
|
7156
|
-
className={\`\${P}-text-padding-lr-handle\`}
|
|
7157
|
-
style={{
|
|
7158
|
-
position: 'absolute'
|
|
7159
|
-
top: 0
|
|
7160
|
-
left: 0
|
|
7161
|
-
width: scaled(textPaddingLRHandleWidth)
|
|
7162
|
-
height: '100%'
|
|
7163
|
-
pointerEvents: 'auto'
|
|
7164
|
-
zIndex: 2
|
|
7165
|
-
}}
|
|
7166
|
-
|
|
7167
|
-
<div
|
|
7168
|
-
data-controls="textPaddingLR"
|
|
7169
|
-
data-controls-paired=""
|
|
7170
|
-
data-controls-axis="x"
|
|
7171
|
-
data-controls-reverse=""
|
|
7172
|
-
data-controls-min="0"
|
|
7173
|
-
data-controls-max-fraction={String(textPaddingLRMaxFraction)}
|
|
7174
|
-
data-controls-static-handle=""
|
|
7175
|
-
className={\`\${P}-text-padding-lr-handle\`}
|
|
7176
|
-
style={{
|
|
7177
|
-
position: 'absolute'
|
|
7178
|
-
top: 0
|
|
7179
|
-
left: scaled(Math.max(textPaddingLRHandleWidth, resolvedContentWidth - textPaddingLRHandleWidth))
|
|
7180
|
-
width: scaled(textPaddingLRHandleWidth)
|
|
7181
|
-
height: '100%'
|
|
7182
|
-
pointerEvents: 'auto'
|
|
7183
|
-
zIndex: 2
|
|
7184
|
-
}}
|
|
7185
|
-
|
|
7186
|
-
</div
|
|
7187
|
-
)}
|
|
7188
|
-
{showHoverImage && hoverImage && (
|
|
7189
|
-
<img
|
|
7190
|
-
className={\`\${P}-hover-image\`}
|
|
7191
|
-
src={hoverImage.url}
|
|
7192
|
-
alt=""
|
|
7193
|
-
style={{
|
|
7194
|
-
width: sv(hoverImage.widthPx)
|
|
7195
|
-
objectFit: hoverImage.objectFit
|
|
7196
|
-
left: hoverImage.x
|
|
7197
|
-
top: hoverImage.y
|
|
7198
|
-
}}
|
|
7199
|
-
|
|
7200
|
-
)}
|
|
7201
|
-
</div
|
|
7202
|
-
</div
|
|
7203
|
-
|
|
7204
|
-
)
|
|
7205
|
-
}
|
|
4665
|
+
`}const Pt=["AColumn","BColumnWidth","CColumnWidth","DColumnWidth","EColumnWidth"],eo=["AColumn","BColumn","CColumn","DColumn","EColumn"],vt="cutLabel",Pn=[...eo,vt],to=["A","B","C","D","E"];function Ai(e){return`${e}ColumnVerticalAlign`}const Xc=["Top","Center","Bottom"];function Zc(e){const t=String(e??"Top").trim();return t.toLowerCase().startsWith("baseline")?!1:t==="Top"||t==="Center"||t==="Bottom"}function Jc(e){const t=String(e??"").trim();if(!t.toLowerCase().startsWith("baseline"))return null;const n=t.slice(-1).toUpperCase();return to.includes(n)?n:null}function Ri(e,t,n){const r=Jc(e);return r?r===t?!1:Zc(n[Ai(r)]):!0}function Rr(e){const t=String(e??"Top").trim();if(t.toLowerCase().startsWith("baseline")){const n=t.slice(-1).toUpperCase();return to.includes(n)?{kind:"baseline",anchorLetter:n}:{kind:"top"}}return t==="Center"?{kind:"center"}:t==="Bottom"?{kind:"bottom"}:{kind:"top"}}function Qc(e,t,n){if(Ii(e,t,n))return Rr(e);const r=Rr(e);return r.kind==="baseline"?{kind:"top"}:r}function Ii(e,t,n){return Ri(e,n,t)?Rr(e).kind==="baseline":!1}function ed(e){if(e.type==="B")return null;const t={};let n=!1;for(const r of to){const o=Ai(r),s=e[o];Ri(s,r,e)||(t[o]="Top",n=!0)}return n?t:null}function td(e){return e==="center"?{marginTop:"auto",marginBottom:"auto"}:e==="bottom"?{marginTop:"auto"}:{}}function nd(e,t){const n=document.createElement("i");n.className=t,n.setAttribute("aria-hidden","true"),e.prepend(n);const{top:r}=e.getBoundingClientRect(),{bottom:o}=n.getBoundingClientRect(),s=o-r;return n.remove(),s}function br(e,t,n,r){const o=e.titleEl;if(!o)return 0;const s=o.closest(`.${n}`);if(!s)return 0;const i=nd(o,r);if(e.kind==="baseline")return o.getBoundingClientRect().top-t+i;const a=s.getBoundingClientRect(),c=o.getBoundingClientRect().height;let u=0;return e.kind==="center"?u=(a.height-c)/2:e.kind==="bottom"&&(u=a.height-c),a.top-t+u+i}function rd(e,t,n){const r=e.getBoundingClientRect().height;return r<=0?0:(t.forEach(o=>{const s=o.querySelector(`.${n}`);s&&(s.style.minHeight=`${r}px`,s.style.height=`${r}px`)}),e.offsetHeight,r)}function od(e,t){return!e||!t?(e&&(e.style.transform=""),0):(e.style.transform=`translateY(${t}px)`,t)}const id={AColumn:"AColumn",BColumnWidth:"BColumn",CColumnWidth:"CColumn",DColumnWidth:"DColumn",EColumnWidth:"EColumn"},ad=["textFontFamily","textFontSettings","textFontSize","textLineHeight","textLetterSpacing","textWordSpacing","textTextAppearance"];function we(e,t){return`${e}${t.replace(/^text/,"Text")}`}function Zn(e,t){const n=r=>{const o=we(t,r),s=e[o];return s!==void 0?s:e[r]};return{textFontFamily:n("textFontFamily")??"Arial",textFontSettings:n("textFontSettings")??{fontWeight:400,fontStyle:"normal"},textFontSize:n("textFontSize"),textLineHeight:n("textLineHeight"),textLetterSpacing:n("textLetterSpacing")??0,textWordSpacing:n("textWordSpacing")??0,textTextAppearance:n("textTextAppearance"),textColor:e.textColor}}function Ho(e,t){var r,o;const n={fontSettings:{fontFamily:e.textFontFamily,fontWeight:((r=e.textFontSettings)==null?void 0:r.fontWeight)??400,fontStyle:((o=e.textFontSettings)==null?void 0:o.fontStyle)??"normal"},fontSize:e.textFontSize??.01,lineHeight:e.textLineHeight,letterSpacing:e.textLetterSpacing,wordSpacing:e.textWordSpacing,textAppearance:e.textTextAppearance,color:e.textColor??"#767676"};return yt(Je(n,t))}function Oo(e,t,n,r){const o=Zn(e,t),s=o.textFontSize??.01,i=o.textLineHeight;return i!==void 0&&i<s?`${n} ${r}`:n}function Bo(e,t,n,r){const o=Zn(e,t),s=o.textFontSize??.01,i=o.textLineHeight;return i===void 0||i>=s?{}:{[`--${n}-title-leading-gap`]:T.scalingValue((s-i)/2,r)}}function sd(e,t){const n={};let r=!1;for(const o of ad)if(e[o]!==t[o]&&e[o]!==void 0){r=!0;for(const s of Pn)Object.assign(n,{[we(s,o)]:e[o]})}return r?n:null}const nt=["AColumnWidth","BColumnWidth","CColumnWidth","DColumnWidth","EColumnWidth"],Zt=["AColumnPaddingLeft","BColumnPaddingLeft","CColumnPaddingLeft","DColumnPaddingLeft","EColumnPaddingLeft"],Jt=["AColumnPaddingRight","BColumnPaddingRight","CColumnPaddingRight","DColumnPaddingRight","EColumnPaddingRight"],Qt=["AColumnPaddingBottom","BColumnPaddingBottom","CColumnPaddingBottom","DColumnPaddingBottom","EColumnPaddingBottom"],ld={textColor:"text-color",backgroundColor:"background-color",dividerColor:"divider-color",textHoverColor:"text-hover-color",backgroundHoverColor:"background-hover-color",dividerHoverColor:"divider-hover-color"},cd=["hover","focus","filled","success","error"],Vo=.004,ln=.004,no=50,bn=1440,xn=no/bn;function Wi(e){const t=typeof e=="number"&&e>0?e:bn;return no/t}function dd(e){let t=e??null;for(;t;){const n=t.style.getPropertyValue("--cntrl-article-width").trim();if(n){const o=parseFloat(n);if(Number.isFinite(o)&&o>0)return o}const r=getComputedStyle(t).getPropertyValue("--cntrl-article-width").trim();if(r){const o=parseFloat(r);if(Number.isFinite(o)&&o>0)return o}t=t.parentElement}return bn}const Fi={AColumnWidth:.02,BColumnWidth:.02,CColumnWidth:.02,DColumnWidth:.02,EColumnWidth:.02};function jn(e){const t=typeof e.wrapperWidth=="number"?e.wrapperWidth:1;return Math.max(0,t)}function ud(e,t=1){const n=t/e;return Object.fromEntries(nt.map(r=>[r,n]))}function pd(){return Object.fromEntries([...Zt.map(e=>[e,0]),...Jt.map(e=>[e,0])])}function md(){return Object.fromEntries(Qt.map(e=>[e,0]))}function Nn(e){return Object.fromEntries(nt.map(t=>[t,typeof e[t]=="number"?e[t]:Fi[t]]))}function ki(e,t,n){const r=e-xn,o=t+n;if(o<=0||o<=r)return{paddingLeft:t,paddingRight:n};if(r<=0)return{paddingLeft:0,paddingRight:0};const s=r/o;return{paddingLeft:t*s,paddingRight:n*s}}function Kn(e,t,n){const r=ro(e,t,n);if(e<=0)return[];const o=r.slice(0,e-1).reduce((s,i)=>s+i,0);return[...r.slice(0,e-1),Math.max(0,t-o)]}function gd(e,t,n){const r={};for(let o=0;o<e;o+=1){const s=Zt[o],i=Jt[o],a=typeof n[s]=="number"?n[s]:0,c=typeof n[i]=="number"?n[i]:0,u=ki(t[o]??0,a,c);u.paddingLeft!==a&&(r[s]=u.paddingLeft),u.paddingRight!==c&&(r[i]=u.paddingRight)}return r}function ro(e,t,n){if(e<=0)return[];const r=nt.slice(0,e).map(u=>n[u]);if(e===1)return r;const o=r.slice(0,e-1),i=o.reduce((u,d)=>u+d,0)+xn;if(t>=i)return r;const a=[...o];let c=i-t;for(let u=a.length-1;u>=0&&c>0;u-=1){const d=a[u]-xn;if(d<=0)continue;const $=Math.min(c,d);a[u]-=$,c-=$}return[...a,r[e-1]]}function hd(e,t,n){if(e<=1)return{};const r=ro(e,t,n),o={};for(let s=0;s<e-1;s+=1){const i=nt[s];r[s]!==n[i]&&(o[i]=r[s])}return o}function Do(e){return Array.isArray(e.columnsOrder)&&e.columnsOrder.length>0?e.columnsOrder:[...Pt]}function fd(e,t){return e.length!==t.length?!1:e.every((n,r)=>n===t[r])}function yd(e,t,n,r){const o=Math.min(r,e.length,nt.length),s={};for(let i=0;i<o;i+=1){const a=e[i],c=t.indexOf(a);if(c===-1)continue;const u=nt[c],d=Zt[c],$=Jt[c],h=Qt[c],f=nt[i],m=Zt[i],g=Jt[i],C=Qt[i],y=n[u],x=n[d],P=n[$],L=n[h];typeof y=="number"&&(s[f]=y),typeof x=="number"&&(s[m]=x),typeof P=="number"&&(s[g]=P),typeof L=="number"&&(s[C]=L)}return s}function vd(e,t,n){const r=sd(e,t);r&&(e={...e,...r});const o=ed(e);o&&(e={...e,...o});const s=Wi(n==null?void 0:n.designWidth),i=e.columns,a=t.columns,c=jn(e),u=jn(t),d=e.type==="B"||e.type===void 0&&t.type==="B",$=typeof i=="number"?i:typeof a=="number"?a:Pt.length,h=L=>{if(d)return L;const _=Nn({...t,...L}),E=jn(L),v=Kn($,E,_),S=gd($,v,{...t,...L});return Object.keys(S).length===0?L:{...L,...S}};if(typeof i=="number"&&i!==a){const L={...e,...ud(i,c),...pd()};if(d)for(const _ of Qt)typeof t[_]=="number"&&(L[_]=t[_]);else Object.assign(L,md());return L}const f=Do(e),m=Do(t);if(!fd(f,m))return h({...e,...yd(f,m,t,$)});if(c<u&&typeof $=="number"&&!d){const L=Nn({...t,...e});return h({...e,...hd($,c,L)})}if(d){const L=typeof e.textPaddingLR=="number"?e.textPaddingLR:0,_=Math.max(0,(c-s)/2);return L>_?{...e,textPaddingLR:_}:e}const g=Nn({...t,...e}),C=Kn($,u,Nn(t)),x=Kn($,c,g).some((L,_)=>L<(C[_]??L)),P=nt.some(L=>{const _=e[L],E=t[L];return typeof _=="number"&&typeof E=="number"&&_!==E});return x||P?h(e):e}function bd(e,t,n,r){const o=t.slice(0,e).reduce((i,a)=>i+a,0),s=n.slice(e+1,t.length-1).reduce((i,a)=>i+a,0);return Math.max(xn,r-o-s-xn)}function xd(e,t){return Math.random()*(t-e)+e}function Cd(e){return Object.fromEntries(nt.map(t=>[t,typeof e[t]=="number"?e[t]:Fi[t]]))}function xr(e,t,n=0){return Object.fromEntries(t.map(r=>[r,typeof e[r]=="number"?e[r]:n]))}function Sd(e,t,n,r,o,s){return e.slice(0,t).map((i,a)=>{const c=Zt[a],u=Jt[a],d=Qt[a];return{key:i,textPrefix:id[i],widthKey:nt[a],width:n[nt[a]],paddingLeftKey:c,paddingRightKey:u,paddingBottomKey:d,paddingLeft:r[c],paddingRight:o[u],paddingBottom:s[d]}})}function wd({settings:e,content:t,isEditor:n,isPreviewMode:r,activeEvent:o,layoutId:s,onUpdateSettings:i}){const{prefix:a}=T.useScopedStyles(),c=!!(n&&r),{columns:u,type:d,wrapperWidth:$,entriesCount:h,cellMinHeight:f,dividerWidth:m,showVisibility:g,cut:C,showCut:y,cutCellMinHeight:x,cutLabel:P,imageSize:L,imageOnHover:_,entryHoverEffect:E,rowPaddingTop:v,rowPaddingBottom:S,rowPaddingTopB:F,columnsOrder:V,textPaddingLR:A,textColor:O,textFontFamily:D,textFontSettings:j,textFontSize:U,textLineHeight:w,textLetterSpacing:N,textWordSpacing:k,textTextAppearance:M,backgroundColor:R,dividerColor:B,textHoverColor:te,backgroundHoverColor:ue,dividerHoverColor:ie}=e,[me,H]=p.useState(void 0),[Q,G]=p.useState(null),Y=_==="On"&&(!n||r),oe=(C??0)>0,W=d==="B",ne=p.useRef(null),[I,b]=p.useState(bn),z=Wi(I),q=Math.max(0,(($??0)-z)/2),J=Math.min(A??0,q),se=Math.max(J,ln),le=(($??0)+z)/2;p.useLayoutEffect(()=>{if(!n){b(bn);return}const ge=()=>{b(dd(ne.current))};ge();const xe=ne.current;if(!xe)return;const Se=new ResizeObserver(ge);Se.observe(xe);let Re=xe;for(;Re&&!Re.style.getPropertyValue("--cntrl-article-width");)Re=Re.parentElement;return Re&&Se.observe(Re),()=>Se.disconnect()},[n,s]),p.useEffect(()=>{H(void 0)},[C,y,t,h]);const ce=T.buildColorVars(a,{textColor:O,backgroundColor:R,dividerColor:B,textHoverColor:te,backgroundHoverColor:ue,dividerHoverColor:ie},ld,cd),he=o&&o!=="default"?`${a}-state-${o}`:"",ee=`${E==="Default"?`${a}-entry-hover-default`:E==="Blinds"?`${a}-entry-hover-blinds`:""} ${he}`.trim(),Z=(g==null?void 0:g[0])??!1,de=(g==null?void 0:g[1])??!1,re=p.useRef(e),pe=p.useRef(s);p.useEffect(()=>{if(!i||!n){re.current=e,pe.current=s;return}if(pe.current!==s){re.current=e,pe.current=s;return}const ge=re.current,xe=vd(e,ge,{designWidth:I});re.current=e,xe!==e&&i(xe)},[e,i,n,s,I]);const ve=p.useMemo(()=>Cd(e),[e.AColumnWidth,e.BColumnWidth,e.CColumnWidth,e.DColumnWidth,e.EColumnWidth]),Pe=p.useMemo(()=>xr(e,Zt),[e.AColumnPaddingLeft,e.BColumnPaddingLeft,e.CColumnPaddingLeft,e.DColumnPaddingLeft,e.EColumnPaddingLeft]),Ke=p.useMemo(()=>xr(e,Jt),[e.AColumnPaddingRight,e.BColumnPaddingRight,e.CColumnPaddingRight,e.DColumnPaddingRight,e.EColumnPaddingRight]),Ge=p.useMemo(()=>xr(e,Qt),[e.AColumnPaddingBottom,e.BColumnPaddingBottom,e.CColumnPaddingBottom,e.DColumnPaddingBottom,e.EColumnPaddingBottom]),$e=p.useMemo(()=>Array.isArray(V)&&V.length>0?V:[...Pt],[V]),Ae=p.useMemo(()=>Sd($e,u,ve,Pe,Ke,Ge),[$e,u,ve,Pe,Ke,Ge]),Me=jn(e),Ie=p.useMemo(()=>nt.slice(0,u).map(ge=>ve[ge]),[u,ve]),Ve=p.useMemo(()=>ro(u,Me,ve),[u,Me,ve]),ye=p.useMemo(()=>Kn(u,Me,ve),[u,Me,ve]),ke=p.useMemo(()=>Ae.map((ge,xe)=>ki(ye[xe]??0,ge.paddingLeft,ge.paddingRight)),[Ae,ye]),He=p.useMemo(()=>{const ge=h===0?1/0:h;return(t??[]).slice(0,ge).map((Se,Re)=>({id:Re,cells:Object.fromEntries(Pt.map(Xe=>[Xe,Se[Xe]??""])),image:Se.image,link:Se.link}))},[t,h]),Oe=oe?me??C:He.length,De=p.useMemo(()=>oe?He.slice(0,Oe):He,[He,oe,Oe]),Qe=oe&&Oe<He.length,Ct=De.length>1||Qe,lt=[Z?`${a}-divider-top`:"",de||Ct?`${a}-divider-bottom`:""].filter(Boolean).join(" "),dr=()=>{const ge=me??C;if(!y){H(He.length);return}H(Math.min(ge+y,He.length))},Ee=ge=>T.scalingValue(ge,n??!1),An=W?F??0:v??0,rn=S??0,on=f??0,ur=W?"rowPaddingTopB":"rowPaddingTop",be=Ae[0],Ye=Ae[Ae.length-1],ze=ke[0],Ne=ke[ke.length-1],St=be&&ze?Math.max(ze.paddingLeft,ln):0,oo=Ye&&Ne?Math.max(Ne.paddingRight,ln):0,Ni=Me,io=ge=>{const xe=ne.current;if(!xe)return{x:0,y:0};const Se=xe.getBoundingClientRect();return{x:ge.clientX-Se.left+No,y:ge.clientY-Se.top+No}},Hi=(ge,xe)=>{if(!Y)return;const Se=ge.image;if(!(Se!=null&&Se.url)){G(null);return}const{x:Re,y:Xe}=io(xe),ct=(L==null?void 0:L.min)??80,Te=(L==null?void 0:L.max)??320,Be=(Q==null?void 0:Q.rowId)===ge.id?Q.widthPx:xd(ct,Te);G({rowId:ge.id,url:Se.url,objectFit:Se.objectFit??"cover",widthPx:Be,x:Re,y:Xe})},Oi=ge=>{if(!Y||!Q)return;const{x:xe,y:Se}=io(ge);G(Re=>!Re||Re.x===xe&&Re.y===Se?Re:{...Re,x:xe,y:Se})},Bi=()=>{G(null)},ao=p.useMemo(()=>!W&&eo.some(ge=>{const xe=ge.charAt(0),Se=e[`${ge}VerticalAlign`];return Ii(Se,e,xe)}),[W,e,e.AColumnVerticalAlign,e.BColumnVerticalAlign,e.CColumnVerticalAlign,e.DColumnVerticalAlign,e.EColumnVerticalAlign]);return p.useLayoutEffect(()=>{var ct;const ge=ne.current;if(!ge)return;const xe=()=>{ge.querySelectorAll("[data-list-col]").forEach(Te=>{Te.style.transform="";const Be=Te.querySelector(`.${a}-list-col`);Be&&(Be.style.minHeight="",Be.style.height="");const ot=Te.querySelector(`.${a}-list-col-title`);ot&&(ot.style.transform="")})};if(W||!ao){xe();return}const Se=()=>{ge.querySelectorAll("[data-list-row]").forEach(Te=>{const Be=Array.from(Te.querySelectorAll("[data-list-col]"));Be.forEach(Le=>{Le.style.transform="";const Ze=Le.querySelector(`.${a}-list-col`);Ze&&(Ze.style.minHeight="",Ze.style.height="");const Ue=Le.querySelector(`.${a}-list-col-title`);Ue&&(Ue.style.transform="")}),rd(Te,Be,`${a}-list-col`),Te.offsetHeight;const ot=Te.getBoundingClientRect().top,wt=`${a}-baseline-probe`,Wt=new Map,an=Be.map(Le=>{const Ze=Le.querySelector(`.${a}-list-col-title`),Ue={el:Le,titleEl:Ze,letter:Le.getAttribute("data-col-letter")??"",kind:Le.getAttribute("data-valign")??"top",anchor:Le.getAttribute("data-valign-anchor")};return Wt.set(Ue.letter,Ue),Ue}),sn=new Map,Rn=(Le,Ze)=>{const Ue=sn.get(Le.letter);if(Ue!==void 0)return Ue;const so=Le.anchor?Wt.get(Le.anchor):void 0;if(Le.kind!=="baseline"||!so||Ze.has(Le.letter)){const co=br(Le,ot,`${a}-list-col`,wt);return sn.set(Le.letter,co),co}Ze.add(Le.letter);const Vi=Rn(so,Ze);Ze.delete(Le.letter);const Di=br(Le,ot,`${a}-list-col`,wt),zi=Vi-Di;od(Le.titleEl,zi);const lo=br(Le,ot,`${a}-list-col`,wt);return sn.set(Le.letter,lo),lo};an.forEach(Le=>Rn(Le,new Set))})};Se();const Re=new ResizeObserver(()=>Se());Re.observe(ge);let Xe=!1;return typeof document<"u"&&((ct=document.fonts)!=null&&ct.ready)&&document.fonts.ready.then(()=>{Xe||Se()}),()=>{Xe=!0,Re.disconnect(),xe()}},[ao,W,e,t,I,De,ye]),l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:Yc(a)}}),l.jsx("div",{style:ce,children:l.jsxs("div",{ref:ne,className:`${a}-wrapper ${ee}${lt?` ${lt}`:""}${W?` ${a}-type-b`:""}`.trim(),style:{width:T.scalingValue($??0,n)},onMouseMove:Y?Oi:void 0,onMouseLeave:Y?Bi:void 0,children:[l.jsxs("div",{style:{width:"100%"},children:[De.map((ge,xe)=>{var ct;const Se=(((ct=ge.link)==null?void 0:ct.length)??0)>0,Re=Se?"a":"div",Xe=qc(xe,De.length,Z,de,Qe,m??0,n??!1);return l.jsxs(Re,{className:`${a}-list-item${Se?` ${a}-list-item-has-link`:""}`,...Se?{href:ge.link,target:"_blank"}:{},style:Xe,onMouseEnter:Y?Te=>Hi(ge,Te):void 0,children:[(An>0||c)&&l.jsx("div",{...c?{"data-controls":ur,"data-controls-axis":"y","data-controls-min":"0"}:{},className:`${a}-row-padding-handle`,style:{height:Ee(An)}}),l.jsx("div",{className:`${a}-list-cols-row${W?"":` ${a}-list-cols-row-h`}`,...W?{}:{"data-list-row":""},style:W?void 0:{minHeight:Ee(on)},children:Ae.map((Te,Be)=>{const ot=Be===Ae.length-1,wt=ke[Be],Wt=Te.paddingBottom,an=Uc(ge.cells[Te.key]),sn=W&&an&&(Wt>0||c),Rn=W?{minHeight:Ee(on)}:ot?{}:{width:Ee(ye[Be])},Le=W?{paddingLeft:Ee(J),paddingRight:Ee(J)}:{paddingLeft:Ee(wt.paddingLeft),paddingRight:Ee(wt.paddingRight)},Ze=Te.textPrefix.charAt(0),Ue=W?{kind:"top"}:Qc(e[`${Te.textPrefix}VerticalAlign`],e,Ze);return l.jsxs("div",{...W?{}:{"data-list-col":"","data-col-letter":Ze,"data-valign":Ue.kind,...Ue.kind==="baseline"?{"data-valign-anchor":Ue.anchorLetter}:{}},children:[l.jsx("div",{className:`${a}-list-col${ot?` ${a}-list-col-last`:""}`,style:{...Le,...Rn},"data-test":Te.width,children:l.jsx("span",{className:Oo(e,Te.textPrefix,`${a}-list-col-title`,`${a}-text-tight-leading`),style:{...Ho(Zn(e,Te.textPrefix),n),...Bo(e,Te.textPrefix,a,n),...W?{}:td(Ue.kind)},children:ge.cells[Te.key]??null})}),sn&&l.jsx("div",{...c?{"data-controls":Te.paddingBottomKey,"data-controls-axis":"y","data-controls-min":"0"}:{},className:`${a}-row-padding-handle`,style:{height:Ee(Wt)}})]},Te.key)})}),!W&&(rn>0||c)&&l.jsx("div",{...c?{"data-controls":"rowPaddingBottom","data-controls-axis":"y","data-controls-min":"0"}:{},className:`${a}-row-padding-handle`,style:{height:Ee(rn)}})]},ge.id)}),Qe&&l.jsx("button",{type:"button",className:`${a}-cut-item`,style:{minHeight:Ee(x??0),...Gc(de,m??0,n??!1)},onClick:dr,children:l.jsx("div",{className:`${a}-list-cols-row`,style:W?{paddingLeft:Ee(J),paddingRight:Ee(J)}:{justifyContent:"center"},children:l.jsx("span",{className:Oo(e,vt,`${a}-cut-label`,`${a}-text-tight-leading`),style:{...Ho(Zn(e,vt),n),...Bo(e,vt,a,n)},children:P})})})]}),c&&!W&&be&&Ye&&l.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[l.jsx("div",{"data-controls":be.paddingLeftKey,"data-controls-axis":"x","data-controls-variant":"column-padding","data-controls-min":"0","data-controls-max-fraction":String(ye[0]-((ze==null?void 0:ze.paddingRight)??0)),"data-controls-static-handle":"",className:`${a}-padding-control-handle`,style:{position:"absolute",top:0,left:0,width:Ee(St),height:"100%",pointerEvents:"auto",zIndex:2}}),l.jsx("div",{"data-controls":Ye.paddingRightKey,"data-controls-axis":"x","data-controls-variant":"column-padding","data-controls-reverse":"","data-controls-min":"0","data-controls-max-fraction":String(ye[Ae.length-1]-((Ne==null?void 0:Ne.paddingLeft)??0)),"data-controls-static-handle":"",className:`${a}-padding-control-handle`,style:{position:"absolute",top:0,left:Ee(Ni-oo),width:Ee(oo),height:"100%",pointerEvents:"auto",zIndex:2}})]},"column-edge-padding-handles"),c&&!W&&Ae.slice(0,-1).map((ge,xe)=>{const Se=Ae[xe+1],Re=bd(xe,Ve,Ie,Me),Xe=Ve.slice(0,xe+1).reduce((Wt,an)=>Wt+an,0),ct=ke[xe],Te=ke[xe+1],Be=Math.max(ct.paddingRight,ln),ot=Math.max(Te.paddingLeft,ln),wt=Xe-Vo/2;return l.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[l.jsx("div",{"data-controls":ge.paddingRightKey,"data-controls-axis":"x","data-controls-variant":"column-padding","data-controls-reverse":"","data-controls-min":"0","data-controls-max-fraction":String(ye[xe]-ct.paddingLeft),"data-controls-static-handle":"",className:`${a}-padding-control-handle`,style:{position:"absolute",top:0,left:Ee(Xe-Be),width:Ee(Be),height:"100%",pointerEvents:"auto",zIndex:2}}),l.jsx("div",{"data-controls":ge.widthKey,"data-controls-axis":"x","data-controls-min":String(no),"data-controls-max-fraction":String(Re),"data-controls-variant":"column-width",className:`${a}-col-resize-handle`,style:{position:"absolute",top:"0px",left:Ee(wt),width:Ee(Vo),height:"calc(100%)",pointerEvents:"auto",zIndex:4}}),l.jsx("div",{"data-controls":Se.paddingLeftKey,"data-controls-axis":"x","data-controls-variant":"column-padding","data-controls-min":"0","data-controls-max-fraction":String(ye[xe+1]-Te.paddingRight),"data-controls-static-handle":"",className:`${a}-padding-control-handle`,style:{position:"absolute",top:0,left:Ee(Xe),width:Ee(ot),height:"100%",pointerEvents:"auto",zIndex:2}})]},`${ge.widthKey}-junction`)}),c&&W&&l.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[l.jsx("div",{"data-controls":"textPaddingLR","data-controls-paired":"","data-controls-axis":"x","data-controls-min":"0","data-controls-max-fraction":String(le),"data-controls-static-handle":"",className:`${a}-text-padding-lr-handle`,style:{position:"absolute",top:0,left:0,width:Ee(se),height:"100%",pointerEvents:"auto",zIndex:2}}),l.jsx("div",{"data-controls":"textPaddingLR","data-controls-paired":"","data-controls-axis":"x","data-controls-reverse":"","data-controls-min":"0","data-controls-max-fraction":String(le),"data-controls-static-handle":"",className:`${a}-text-padding-lr-handle`,style:{position:"absolute",top:0,left:Ee(Math.max(se,Me-se)),width:Ee(se),height:"100%",pointerEvents:"auto",zIndex:2}})]},"text-padding-lr-handles"),Y&&Q&&l.jsx("img",{className:`${a}-hover-image`,src:Q.url,alt:"",style:{width:zn(Q.widthPx),objectFit:Q.objectFit,left:Q.x,top:Q.y}})]})})]})}const $d=`import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
4666
|
+
import { CommonComponentProps } from '../props';
|
|
4667
|
+
import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index';
|
|
4668
|
+
import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss';
|
|
4669
|
+
|
|
4670
|
+
type ListFontSettings = { fontWeight: number; fontStyle: string };
|
|
4671
|
+
|
|
4672
|
+
type ListColumnPrefix = 'AColumn' | 'BColumn' | 'CColumn' | 'DColumn' | 'EColumn';
|
|
4673
|
+
|
|
4674
|
+
type ListColumnTextStyleOverrides = {
|
|
4675
|
+
AColumnVerticalAlign?: string;
|
|
4676
|
+
AColumnTextFontFamily?: string;
|
|
4677
|
+
AColumnTextFontSettings?: ListFontSettings;
|
|
4678
|
+
AColumnTextFontSize?: number;
|
|
4679
|
+
AColumnTextLineHeight?: number;
|
|
4680
|
+
AColumnTextLetterSpacing?: number;
|
|
4681
|
+
AColumnTextWordSpacing?: number;
|
|
4682
|
+
AColumnTextTextAppearance?: TextStyles['textAppearance'];
|
|
4683
|
+
BColumnVerticalAlign?: string;
|
|
4684
|
+
BColumnTextFontFamily?: string;
|
|
4685
|
+
BColumnTextFontSettings?: ListFontSettings;
|
|
4686
|
+
BColumnTextFontSize?: number;
|
|
4687
|
+
BColumnTextLineHeight?: number;
|
|
4688
|
+
BColumnTextLetterSpacing?: number;
|
|
4689
|
+
BColumnTextWordSpacing?: number;
|
|
4690
|
+
BColumnTextTextAppearance?: TextStyles['textAppearance'];
|
|
4691
|
+
CColumnVerticalAlign?: string;
|
|
4692
|
+
CColumnTextFontFamily?: string;
|
|
4693
|
+
CColumnTextFontSettings?: ListFontSettings;
|
|
4694
|
+
CColumnTextFontSize?: number;
|
|
4695
|
+
CColumnTextLineHeight?: number;
|
|
4696
|
+
CColumnTextLetterSpacing?: number;
|
|
4697
|
+
CColumnTextWordSpacing?: number;
|
|
4698
|
+
CColumnTextTextAppearance?: TextStyles['textAppearance'];
|
|
4699
|
+
DColumnVerticalAlign?: string;
|
|
4700
|
+
DColumnTextFontFamily?: string;
|
|
4701
|
+
DColumnTextFontSettings?: ListFontSettings;
|
|
4702
|
+
DColumnTextFontSize?: number;
|
|
4703
|
+
DColumnTextLineHeight?: number;
|
|
4704
|
+
DColumnTextLetterSpacing?: number;
|
|
4705
|
+
DColumnTextWordSpacing?: number;
|
|
4706
|
+
DColumnTextTextAppearance?: TextStyles['textAppearance'];
|
|
4707
|
+
EColumnVerticalAlign?: string;
|
|
4708
|
+
EColumnTextFontFamily?: string;
|
|
4709
|
+
EColumnTextFontSettings?: ListFontSettings;
|
|
4710
|
+
EColumnTextFontSize?: number;
|
|
4711
|
+
EColumnTextLineHeight?: number;
|
|
4712
|
+
EColumnTextLetterSpacing?: number;
|
|
4713
|
+
EColumnTextWordSpacing?: number;
|
|
4714
|
+
EColumnTextTextAppearance?: TextStyles['textAppearance'];
|
|
4715
|
+
cutLabelTextFontFamily?: string;
|
|
4716
|
+
cutLabelTextFontSettings?: ListFontSettings;
|
|
4717
|
+
cutLabelTextFontSize?: number;
|
|
4718
|
+
cutLabelTextLineHeight?: number;
|
|
4719
|
+
cutLabelTextLetterSpacing?: number;
|
|
4720
|
+
cutLabelTextWordSpacing?: number;
|
|
4721
|
+
cutLabelTextTextAppearance?: TextStyles['textAppearance'];
|
|
4722
|
+
};
|
|
4723
|
+
|
|
4724
|
+
export type ListColumnVerticalAlignKey = \`\${ListColumnPrefix}VerticalAlign\`;
|
|
4725
|
+
|
|
4726
|
+
type ListColumnVerticalAlignUpdates = {
|
|
4727
|
+
AColumnVerticalAlign?: string;
|
|
4728
|
+
BColumnVerticalAlign?: string;
|
|
4729
|
+
CColumnVerticalAlign?: string;
|
|
4730
|
+
DColumnVerticalAlign?: string;
|
|
4731
|
+
EColumnVerticalAlign?: string;
|
|
4732
|
+
};
|
|
4733
|
+
|
|
4734
|
+
type ListColumnTextStyleSyncUpdates = {
|
|
4735
|
+
AColumnTextFontFamily?: string;
|
|
4736
|
+
AColumnTextFontSettings?: ListFontSettings;
|
|
4737
|
+
AColumnTextFontSize?: number;
|
|
4738
|
+
AColumnTextLineHeight?: number;
|
|
4739
|
+
AColumnTextLetterSpacing?: number;
|
|
4740
|
+
AColumnTextWordSpacing?: number;
|
|
4741
|
+
AColumnTextTextAppearance?: TextStyles['textAppearance'];
|
|
4742
|
+
BColumnTextFontFamily?: string;
|
|
4743
|
+
BColumnTextFontSettings?: ListFontSettings;
|
|
4744
|
+
BColumnTextFontSize?: number;
|
|
4745
|
+
BColumnTextLineHeight?: number;
|
|
4746
|
+
BColumnTextLetterSpacing?: number;
|
|
4747
|
+
BColumnTextWordSpacing?: number;
|
|
4748
|
+
BColumnTextTextAppearance?: TextStyles['textAppearance'];
|
|
4749
|
+
CColumnTextFontFamily?: string;
|
|
4750
|
+
CColumnTextFontSettings?: ListFontSettings;
|
|
4751
|
+
CColumnTextFontSize?: number;
|
|
4752
|
+
CColumnTextLineHeight?: number;
|
|
4753
|
+
CColumnTextLetterSpacing?: number;
|
|
4754
|
+
CColumnTextWordSpacing?: number;
|
|
4755
|
+
CColumnTextTextAppearance?: TextStyles['textAppearance'];
|
|
4756
|
+
DColumnTextFontFamily?: string;
|
|
4757
|
+
DColumnTextFontSettings?: ListFontSettings;
|
|
4758
|
+
DColumnTextFontSize?: number;
|
|
4759
|
+
DColumnTextLineHeight?: number;
|
|
4760
|
+
DColumnTextLetterSpacing?: number;
|
|
4761
|
+
DColumnTextWordSpacing?: number;
|
|
4762
|
+
DColumnTextTextAppearance?: TextStyles['textAppearance'];
|
|
4763
|
+
EColumnTextFontFamily?: string;
|
|
4764
|
+
EColumnTextFontSettings?: ListFontSettings;
|
|
4765
|
+
EColumnTextFontSize?: number;
|
|
4766
|
+
EColumnTextLineHeight?: number;
|
|
4767
|
+
EColumnTextLetterSpacing?: number;
|
|
4768
|
+
EColumnTextWordSpacing?: number;
|
|
4769
|
+
EColumnTextTextAppearance?: TextStyles['textAppearance'];
|
|
4770
|
+
cutLabelTextFontFamily?: string;
|
|
4771
|
+
cutLabelTextFontSettings?: ListFontSettings;
|
|
4772
|
+
cutLabelTextFontSize?: number;
|
|
4773
|
+
cutLabelTextLineHeight?: number;
|
|
4774
|
+
cutLabelTextLetterSpacing?: number;
|
|
4775
|
+
cutLabelTextWordSpacing?: number;
|
|
4776
|
+
cutLabelTextTextAppearance?: TextStyles['textAppearance'];
|
|
4777
|
+
};
|
|
4778
|
+
|
|
4779
|
+
export type ListSettings = {
|
|
4780
|
+
columns: number;
|
|
4781
|
+
type: 'A' | 'B';
|
|
4782
|
+
wrapperWidth: number;
|
|
4783
|
+
entriesCount: number;
|
|
4784
|
+
cellMinHeight: number;
|
|
4785
|
+
imageOnHover: 'On' | 'Off';
|
|
4786
|
+
imageSize?: { min: number; max: number };
|
|
4787
|
+
dividerWidth: number;
|
|
4788
|
+
showVisibility: boolean[];
|
|
4789
|
+
cut: number;
|
|
4790
|
+
showCut: number;
|
|
4791
|
+
cutCellMinHeight: number;
|
|
4792
|
+
cutLabel: string;
|
|
4793
|
+
entryHoverEffect: 'None' | 'Default' | 'Blinds';
|
|
4794
|
+
rowPaddingTop: number;
|
|
4795
|
+
rowPaddingBottom: number;
|
|
4796
|
+
rowPaddingTopB: number;
|
|
4797
|
+
AColumnWidth: number;
|
|
4798
|
+
AColumnPaddingLeft: number;
|
|
4799
|
+
AColumnPaddingRight: number;
|
|
4800
|
+
AColumnPaddingBottom: number;
|
|
4801
|
+
BColumnWidth: number;
|
|
4802
|
+
BColumnPaddingLeft: number;
|
|
4803
|
+
BColumnPaddingRight: number;
|
|
4804
|
+
BColumnPaddingBottom: number;
|
|
4805
|
+
CColumnWidth: number;
|
|
4806
|
+
CColumnPaddingLeft: number;
|
|
4807
|
+
CColumnPaddingRight: number;
|
|
4808
|
+
CColumnPaddingBottom: number;
|
|
4809
|
+
DColumnWidth: number;
|
|
4810
|
+
DColumnPaddingLeft: number;
|
|
4811
|
+
DColumnPaddingRight: number;
|
|
4812
|
+
DColumnPaddingBottom: number;
|
|
4813
|
+
EColumnWidth: number;
|
|
4814
|
+
EColumnPaddingLeft: number;
|
|
4815
|
+
EColumnPaddingRight: number;
|
|
4816
|
+
EColumnPaddingBottom: number;
|
|
4817
|
+
columnsOrder?: string[];
|
|
4818
|
+
textPaddingLR?: number;
|
|
4819
|
+
textColor: string;
|
|
4820
|
+
textFontFamily: string;
|
|
4821
|
+
textFontSettings?: ListFontSettings;
|
|
4822
|
+
textFontSize?: number;
|
|
4823
|
+
textLineHeight?: number;
|
|
4824
|
+
textLetterSpacing?: number;
|
|
4825
|
+
textWordSpacing?: number;
|
|
4826
|
+
textTextAppearance?: TextStyles['textAppearance'];
|
|
4827
|
+
backgroundColor: string;
|
|
4828
|
+
dividerColor: string;
|
|
4829
|
+
textHoverColor: string;
|
|
4830
|
+
backgroundHoverColor: string;
|
|
4831
|
+
dividerHoverColor: string;
|
|
4832
|
+
} & ListColumnTextStyleOverrides;
|
|
4833
|
+
|
|
4834
|
+
type ListContentItem = {
|
|
4835
|
+
AColumn?: string;
|
|
4836
|
+
BColumnWidth?: string;
|
|
4837
|
+
CColumnWidth?: string;
|
|
4838
|
+
DColumnWidth?: string;
|
|
4839
|
+
EColumnWidth?: string;
|
|
4840
|
+
image?: {
|
|
4841
|
+
objectFit?: 'cover' | 'contain';
|
|
4842
|
+
url: string;
|
|
4843
|
+
name: string;
|
|
4844
|
+
};
|
|
4845
|
+
link?: string;
|
|
4846
|
+
};
|
|
4847
|
+
|
|
4848
|
+
type ListItemRow = {
|
|
4849
|
+
id: string | number;
|
|
4850
|
+
cells: Record<string, React.ReactNode>;
|
|
4851
|
+
image?: ListContentItem['image'];
|
|
4852
|
+
link?: string;
|
|
4853
|
+
};
|
|
4854
|
+
|
|
4855
|
+
type HoverImageState = {
|
|
4856
|
+
rowId: string | number;
|
|
4857
|
+
url: string;
|
|
4858
|
+
objectFit: 'cover' | 'contain';
|
|
4859
|
+
widthPx: number;
|
|
4860
|
+
x: number;
|
|
4861
|
+
y: number;
|
|
4862
|
+
};
|
|
4863
|
+
|
|
4864
|
+
type ListProps = {
|
|
4865
|
+
layoutId?: string;
|
|
4866
|
+
settings: ListSettings;
|
|
4867
|
+
content?: ListContentItem[];
|
|
4868
|
+
isEditor?: boolean;
|
|
4869
|
+
isPreviewMode?: boolean;
|
|
4870
|
+
activeEvent: string | undefined;
|
|
4871
|
+
onUpdateSettings?: (settings: ListSettings) => void;
|
|
4872
|
+
} & CommonComponentProps;
|
|
4873
|
+
|
|
4874
|
+
function sv(px: number): string {
|
|
4875
|
+
return \`calc(var(--cntrl-article-width, 100vw) * \${px / 1440})\`;
|
|
4876
|
+
}
|
|
4877
|
+
|
|
4878
|
+
function hasListColumnText(value: React.ReactNode): boolean {
|
|
4879
|
+
return String(value ?? '').trim().length > 0;
|
|
4880
|
+
}
|
|
4881
|
+
|
|
4882
|
+
function getEntryDividerWidths(
|
|
4883
|
+
rowIdx: number,
|
|
4884
|
+
rowCount: number,
|
|
4885
|
+
showDividerTop: boolean,
|
|
4886
|
+
showDividerBottom: boolean,
|
|
4887
|
+
hasCutItem: boolean,
|
|
4888
|
+
dividerWidth: number,
|
|
4889
|
+
isEditor: boolean,
|
|
4890
|
+
): { borderTopWidth: string; borderBottomWidth: string } {
|
|
4891
|
+
const scaledDividerWidth = scalingValue(dividerWidth, isEditor);
|
|
4892
|
+
const none = scalingValue(0, isEditor);
|
|
4893
|
+
|
|
4894
|
+
const isFirst = rowIdx === 0;
|
|
4895
|
+
const isLastEntry = rowIdx === rowCount - 1 && !hasCutItem;
|
|
4896
|
+
|
|
4897
|
+
const borderTopWidth = isFirst && showDividerTop ? scaledDividerWidth : none;
|
|
4898
|
+
const borderBottomWidth = !isLastEntry || showDividerBottom ? scaledDividerWidth : none;
|
|
4899
|
+
|
|
4900
|
+
return { borderTopWidth, borderBottomWidth };
|
|
4901
|
+
}
|
|
4902
|
+
|
|
4903
|
+
function getCutItemDividerWidths(
|
|
4904
|
+
showDividerBottom: boolean,
|
|
4905
|
+
dividerWidth: number,
|
|
4906
|
+
isEditor: boolean,
|
|
4907
|
+
): { borderTopWidth: string; borderBottomWidth: string } {
|
|
4908
|
+
const scaledDividerWidth = scalingValue(dividerWidth, isEditor);
|
|
4909
|
+
const none = scalingValue(0, isEditor);
|
|
4910
|
+
|
|
4911
|
+
return {
|
|
4912
|
+
borderTopWidth: none,
|
|
4913
|
+
borderBottomWidth: showDividerBottom ? scaledDividerWidth : none,
|
|
4914
|
+
};
|
|
4915
|
+
}
|
|
4916
|
+
|
|
4917
|
+
const HOVER_IMAGE_CURSOR_OFFSET = 10;
|
|
4918
|
+
|
|
4919
|
+
function getCSS(P: string): string {
|
|
4920
|
+
return \`
|
|
4921
|
+
.\${P}-wrapper {
|
|
4922
|
+
display: grid;
|
|
4923
|
+
align-items: start;
|
|
4924
|
+
min-height: \${sv(48)};
|
|
4925
|
+
position: relative;
|
|
4926
|
+
overflow: visible;
|
|
4927
|
+
box-sizing: border-box;
|
|
4928
|
+
}
|
|
4929
|
+
|
|
4930
|
+
.\${P}-hover-image {
|
|
4931
|
+
position: absolute;
|
|
4932
|
+
left: 0;
|
|
4933
|
+
top: 0;
|
|
4934
|
+
z-index: 10;
|
|
4935
|
+
pointer-events: none;
|
|
4936
|
+
display: block;
|
|
4937
|
+
height: auto;
|
|
4938
|
+
}
|
|
4939
|
+
|
|
4940
|
+
.\${P}-list-item {
|
|
4941
|
+
display: flex;
|
|
4942
|
+
flex-direction: column;
|
|
4943
|
+
align-items: stretch;
|
|
4944
|
+
width: 100%;
|
|
4945
|
+
overflow: visible;
|
|
4946
|
+
position: relative;
|
|
4947
|
+
box-sizing: content-box;
|
|
4948
|
+
user-select: none;
|
|
4949
|
+
background: var(--\${P}-background-color);
|
|
4950
|
+
}
|
|
4951
|
+
|
|
4952
|
+
.\${P}-wrapper.\${P}-divider-top .\${P}-list-item {
|
|
4953
|
+
border-top-style: solid;
|
|
4954
|
+
border-top-color: var(--\${P}-divider-color);
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
.\${P}-wrapper.\${P}-divider-bottom .\${P}-list-item {
|
|
4958
|
+
border-bottom-style: solid;
|
|
4959
|
+
border-bottom-color: var(--\${P}-divider-color);
|
|
4960
|
+
}
|
|
4961
|
+
|
|
4962
|
+
.\${P}-list-cols-row {
|
|
4963
|
+
display: flex;
|
|
4964
|
+
align-items: start;
|
|
4965
|
+
width: 100%;
|
|
4966
|
+
box-sizing: border-box;
|
|
4967
|
+
}
|
|
4968
|
+
|
|
4969
|
+
.\${P}-list-cols-row-h {
|
|
4970
|
+
align-items: stretch;
|
|
4971
|
+
}
|
|
4972
|
+
|
|
4973
|
+
.\${P}-list-cols-row-h [data-list-col] {
|
|
4974
|
+
display: grid;
|
|
4975
|
+
grid-template-rows: minmax(0, 1fr);
|
|
4976
|
+
align-self: stretch;
|
|
4977
|
+
min-height: min-content;
|
|
4978
|
+
}
|
|
4979
|
+
|
|
4980
|
+
.\${P}-list-cols-row-h .\${P}-list-col {
|
|
4981
|
+
display: flex;
|
|
4982
|
+
flex-direction: column;
|
|
4983
|
+
align-items: flex-start;
|
|
4984
|
+
justify-content: flex-start;
|
|
4985
|
+
width: 100%;
|
|
4986
|
+
min-height: 0;
|
|
4987
|
+
}
|
|
4988
|
+
|
|
4989
|
+
.\${P}-list-cols-row-h .\${P}-list-col-title {
|
|
4990
|
+
display: block;
|
|
4991
|
+
flex: 0 0 auto;
|
|
4992
|
+
align-self: stretch;
|
|
4993
|
+
}
|
|
4994
|
+
|
|
4995
|
+
.\${P}-text-tight-leading {
|
|
4996
|
+
display: block;
|
|
4997
|
+
flex-shrink: 0;
|
|
4998
|
+
padding-top: var(--\${P}-title-leading-gap, 0);
|
|
4999
|
+
padding-bottom: var(--\${P}-title-leading-gap, 0);
|
|
5000
|
+
}
|
|
5001
|
+
|
|
5002
|
+
.\${P}-wrapper.\${P}-type-b .\${P}-list-cols-row {
|
|
5003
|
+
flex-direction: column;
|
|
5004
|
+
align-items: stretch;
|
|
5005
|
+
}
|
|
5006
|
+
|
|
5007
|
+
.\${P}-wrapper.\${P}-type-b .\${P}-list-col {
|
|
5008
|
+
width: 100%;
|
|
5009
|
+
min-width: 0;
|
|
5010
|
+
flex-direction: column;
|
|
5011
|
+
justify-content: flex-start;
|
|
5012
|
+
align-items: flex-start;
|
|
5013
|
+
min-height: min-content;
|
|
5014
|
+
}
|
|
5015
|
+
|
|
5016
|
+
.\${P}-wrapper.\${P}-type-b .\${P}-list-col-title {
|
|
5017
|
+
display: block;
|
|
5018
|
+
flex: 0 0 auto;
|
|
5019
|
+
align-self: stretch;
|
|
5020
|
+
text-align: center;
|
|
5021
|
+
}
|
|
5022
|
+
|
|
5023
|
+
.\${P}-wrapper.\${P}-type-b .\${P}-cut-item .\${P}-list-cols-row {
|
|
5024
|
+
flex-direction: row;
|
|
5025
|
+
align-items: center;
|
|
5026
|
+
justify-content: center;
|
|
5027
|
+
}
|
|
5028
|
+
|
|
5029
|
+
.\${P}-wrapper.\${P}-type-b .\${P}-cut-label {
|
|
5030
|
+
text-align: center;
|
|
5031
|
+
width: 100%;
|
|
5032
|
+
box-sizing: border-box;
|
|
5033
|
+
}
|
|
5034
|
+
|
|
5035
|
+
.\${P}-wrapper.\${P}-type-b .\${P}-list-col-last {
|
|
5036
|
+
flex: 0 0 auto;
|
|
5037
|
+
min-width: 0;
|
|
5038
|
+
}
|
|
5039
|
+
|
|
5040
|
+
a.\${P}-list-item {
|
|
5041
|
+
text-decoration: none;
|
|
5042
|
+
color: inherit;
|
|
5043
|
+
cursor: pointer;
|
|
5044
|
+
}
|
|
5045
|
+
|
|
5046
|
+
.\${P}-list-col {
|
|
5047
|
+
flex-shrink: 0;
|
|
5048
|
+
overflow: visible;
|
|
5049
|
+
box-sizing: border-box;
|
|
5050
|
+
min-width: \${sv(50)};
|
|
5051
|
+
position: relative;
|
|
5052
|
+
display: flex;
|
|
5053
|
+
align-items: flex-start;
|
|
5054
|
+
}
|
|
5055
|
+
|
|
5056
|
+
.\${P}-list-col-last {
|
|
5057
|
+
flex: 1 1 auto;
|
|
5058
|
+
min-width: \${sv(50)};
|
|
5059
|
+
}
|
|
5060
|
+
|
|
5061
|
+
.\${P}-list-col-title {
|
|
5062
|
+
color: var(--\${P}-text-color);
|
|
5063
|
+
white-space: pre-wrap;
|
|
5064
|
+
overflow-wrap: anywhere;
|
|
5065
|
+
word-break: break-word;
|
|
5066
|
+
flex: 1;
|
|
5067
|
+
min-width: 0;
|
|
5068
|
+
width: 100%;
|
|
5069
|
+
box-sizing: border-box;
|
|
5070
|
+
}
|
|
5071
|
+
|
|
5072
|
+
.\${P}-baseline-probe {
|
|
5073
|
+
display: inline-block;
|
|
5074
|
+
width: 0;
|
|
5075
|
+
height: 0;
|
|
5076
|
+
overflow: hidden;
|
|
5077
|
+
vertical-align: baseline;
|
|
5078
|
+
}
|
|
5079
|
+
|
|
5080
|
+
.\${P}-col-resize-handle,
|
|
5081
|
+
.\${P}-padding-control-handle {
|
|
5082
|
+
background: transparent;
|
|
5083
|
+
}
|
|
5084
|
+
|
|
5085
|
+
.\${P}-row-padding-handle {
|
|
5086
|
+
position: relative;
|
|
5087
|
+
z-index: 2;
|
|
5088
|
+
width: 100%;
|
|
5089
|
+
flex-shrink: 0;
|
|
5090
|
+
background: transparent;
|
|
5091
|
+
}
|
|
5092
|
+
|
|
5093
|
+
.\${P}-row-padding-handle::before {
|
|
5094
|
+
content: "";
|
|
5095
|
+
position: absolute;
|
|
5096
|
+
top: 0;
|
|
5097
|
+
left: 0;
|
|
5098
|
+
width: 100%;
|
|
5099
|
+
height: 100%;
|
|
5100
|
+
min-height: 20px;
|
|
5101
|
+
pointer-events: auto;
|
|
5102
|
+
z-index: 10;
|
|
5103
|
+
}
|
|
5104
|
+
|
|
5105
|
+
.\${P}-col-resize-handle::after {
|
|
5106
|
+
content: '';
|
|
5107
|
+
position: absolute;
|
|
5108
|
+
top: 0;
|
|
5109
|
+
left: 50%;
|
|
5110
|
+
transform: translateX(-50%);
|
|
5111
|
+
width: 2px;
|
|
5112
|
+
height: 100%;
|
|
5113
|
+
background: #FF5C02;
|
|
5114
|
+
pointer-events: none;
|
|
5115
|
+
}
|
|
5116
|
+
|
|
5117
|
+
.\${P}-wrapper.\${P}-type-b .\${P}-col-resize-handle::after {
|
|
5118
|
+
top: 50%;
|
|
5119
|
+
left: 0;
|
|
5120
|
+
transform: translateY(-50%);
|
|
5121
|
+
width: 100%;
|
|
5122
|
+
height: 2px;
|
|
5123
|
+
}
|
|
5124
|
+
|
|
5125
|
+
.\${P}-padding-control-handle::after {
|
|
5126
|
+
content: '';
|
|
5127
|
+
position: absolute;
|
|
5128
|
+
top: 50%;
|
|
5129
|
+
left: 50%;
|
|
5130
|
+
transform: translate(-50%, -50%);
|
|
5131
|
+
width: 4px;
|
|
5132
|
+
height: 12px;
|
|
5133
|
+
background: #FF5C02;
|
|
5134
|
+
border: 1px solid #FFFFFF;
|
|
5135
|
+
border-radius: 5px;
|
|
5136
|
+
pointer-events: none;
|
|
5137
|
+
box-sizing: border-box;
|
|
5138
|
+
}
|
|
5139
|
+
|
|
5140
|
+
.\${P}-wrapper.\${P}-type-b .\${P}-padding-control-handle::after {
|
|
5141
|
+
width: 12px;
|
|
5142
|
+
height: 4px;
|
|
5143
|
+
}
|
|
5144
|
+
|
|
5145
|
+
.\${P}-text-padding-lr-handle {
|
|
5146
|
+
background: transparent;
|
|
5147
|
+
}
|
|
5148
|
+
|
|
5149
|
+
.\${P}-text-padding-lr-handle::after {
|
|
5150
|
+
content: '';
|
|
5151
|
+
position: absolute;
|
|
5152
|
+
top: 50%;
|
|
5153
|
+
left: 50%;
|
|
5154
|
+
transform: translate(-50%, -50%);
|
|
5155
|
+
width: 4px;
|
|
5156
|
+
height: 12px;
|
|
5157
|
+
background: #FF5C02;
|
|
5158
|
+
border: 1px solid #FFFFFF;
|
|
5159
|
+
border-radius: 5px;
|
|
5160
|
+
pointer-events: none;
|
|
5161
|
+
box-sizing: border-box;
|
|
5162
|
+
}
|
|
5163
|
+
|
|
5164
|
+
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-list-item-has-link,
|
|
5165
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-item-has-link,
|
|
5166
|
+
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-cut-item,
|
|
5167
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-item {
|
|
5168
|
+
transition: background-color 250ms, border-color 250ms;
|
|
5169
|
+
}
|
|
5170
|
+
|
|
5171
|
+
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-list-item-has-link .\${P}-list-col-title,
|
|
5172
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-item-has-link .\${P}-list-col-title,
|
|
5173
|
+
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-cut-label,
|
|
5174
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-label {
|
|
5175
|
+
transition: color 250ms;
|
|
5176
|
+
}
|
|
5177
|
+
|
|
5178
|
+
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-list-item-has-link:hover,
|
|
5179
|
+
.\${P}-wrapper.\${P}-entry-hover-default.\${P}-state-hover .\${P}-list-item-has-link,
|
|
5180
|
+
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-cut-item:hover,
|
|
5181
|
+
.\${P}-wrapper.\${P}-entry-hover-default.\${P}-state-hover .\${P}-cut-item {
|
|
5182
|
+
background: var(--\${P}-background-hover-color);
|
|
5183
|
+
}
|
|
5184
|
+
|
|
5185
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default .\${P}-list-item-has-link:hover,
|
|
5186
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default .\${P}-list-item:has(+ .\${P}-list-item-has-link:hover),
|
|
5187
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default .\${P}-list-item:has(+ .\${P}-cut-item:hover),
|
|
5188
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default.\${P}-state-hover .\${P}-list-item-has-link,
|
|
5189
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default .\${P}-cut-item:hover,
|
|
5190
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-default.\${P}-state-hover .\${P}-cut-item,
|
|
5191
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds .\${P}-list-item-has-link:hover,
|
|
5192
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds .\${P}-list-item:has(+ .\${P}-list-item-has-link:hover),
|
|
5193
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds .\${P}-list-item:has(+ .\${P}-cut-item:hover),
|
|
5194
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-list-item-has-link,
|
|
5195
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds .\${P}-cut-item:hover,
|
|
5196
|
+
.\${P}-wrapper.\${P}-divider-bottom.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-cut-item {
|
|
5197
|
+
border-bottom-color: var(--\${P}-divider-hover-color);
|
|
5198
|
+
}
|
|
5199
|
+
|
|
5200
|
+
.\${P}-wrapper.\${P}-divider-top:not(.\${P}-divider-bottom).\${P}-entry-hover-default .\${P}-list-item-has-link:hover:first-child,
|
|
5201
|
+
.\${P}-wrapper.\${P}-divider-top:not(.\${P}-divider-bottom).\${P}-entry-hover-default.\${P}-state-hover .\${P}-list-item-has-link:first-child,
|
|
5202
|
+
.\${P}-wrapper.\${P}-divider-top:not(.\${P}-divider-bottom).\${P}-entry-hover-blinds .\${P}-list-item-has-link:hover:first-child,
|
|
5203
|
+
.\${P}-wrapper.\${P}-divider-top:not(.\${P}-divider-bottom).\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-list-item-has-link:first-child {
|
|
5204
|
+
border-top-color: var(--\${P}-divider-hover-color);
|
|
5205
|
+
}
|
|
5206
|
+
|
|
5207
|
+
.\${P}-wrapper.\${P}-divider-top.\${P}-divider-bottom.\${P}-entry-hover-default .\${P}-list-item-has-link:hover:first-child,
|
|
5208
|
+
.\${P}-wrapper.\${P}-divider-top.\${P}-divider-bottom.\${P}-entry-hover-default.\${P}-state-hover .\${P}-list-item-has-link:first-child,
|
|
5209
|
+
.\${P}-wrapper.\${P}-divider-top.\${P}-divider-bottom.\${P}-entry-hover-blinds .\${P}-list-item-has-link:hover:first-child,
|
|
5210
|
+
.\${P}-wrapper.\${P}-divider-top.\${P}-divider-bottom.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-list-item-has-link:first-child {
|
|
5211
|
+
border-top-color: var(--\${P}-divider-hover-color);
|
|
5212
|
+
}
|
|
5213
|
+
|
|
5214
|
+
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-list-item-has-link:hover .\${P}-list-col-title,
|
|
5215
|
+
.\${P}-wrapper.\${P}-entry-hover-default.\${P}-state-hover .\${P}-list-item-has-link .\${P}-list-col-title,
|
|
5216
|
+
.\${P}-wrapper.\${P}-entry-hover-default .\${P}-cut-item:hover .\${P}-cut-label,
|
|
5217
|
+
.\${P}-wrapper.\${P}-entry-hover-default.\${P}-state-hover .\${P}-cut-item .\${P}-cut-label,
|
|
5218
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-item-has-link:hover .\${P}-list-col-title,
|
|
5219
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-list-item-has-link .\${P}-list-col-title,
|
|
5220
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-item:hover .\${P}-cut-label,
|
|
5221
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-cut-item .\${P}-cut-label {
|
|
5222
|
+
color: var(--\${P}-text-hover-color);
|
|
5223
|
+
}
|
|
5224
|
+
|
|
5225
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-item-has-link::before,
|
|
5226
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-item::before {
|
|
5227
|
+
content: '';
|
|
5228
|
+
position: absolute;
|
|
5229
|
+
inset: 0;
|
|
5230
|
+
background: var(--\${P}-background-hover-color);
|
|
5231
|
+
transform: scaleY(0);
|
|
5232
|
+
transform-origin: center center;
|
|
5233
|
+
transition: transform 250ms;
|
|
5234
|
+
z-index: 0;
|
|
5235
|
+
pointer-events: none;
|
|
5236
|
+
}
|
|
5237
|
+
|
|
5238
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-col,
|
|
5239
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-label {
|
|
5240
|
+
position: relative;
|
|
5241
|
+
z-index: 1;
|
|
5242
|
+
}
|
|
5243
|
+
|
|
5244
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-list-item-has-link:hover::before,
|
|
5245
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-list-item-has-link::before,
|
|
5246
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds .\${P}-cut-item:hover::before,
|
|
5247
|
+
.\${P}-wrapper.\${P}-entry-hover-blinds.\${P}-state-hover .\${P}-cut-item::before {
|
|
5248
|
+
transform: scaleY(1);
|
|
5249
|
+
}
|
|
5250
|
+
|
|
5251
|
+
.\${P}-cut-item {
|
|
5252
|
+
display: flex;
|
|
5253
|
+
align-items: center;
|
|
5254
|
+
justify-content: center;
|
|
5255
|
+
width: 100%;
|
|
5256
|
+
overflow: visible;
|
|
5257
|
+
position: relative;
|
|
5258
|
+
z-index: 3;
|
|
5259
|
+
box-sizing: border-box;
|
|
5260
|
+
user-select: none;
|
|
5261
|
+
background: var(--\${P}-background-color);
|
|
5262
|
+
cursor: pointer;
|
|
5263
|
+
padding: 0;
|
|
5264
|
+
border: none;
|
|
5265
|
+
font: inherit;
|
|
5266
|
+
text-align: inherit;
|
|
5267
|
+
appearance: none;
|
|
5268
|
+
-webkit-appearance: none;
|
|
5269
|
+
}
|
|
5270
|
+
|
|
5271
|
+
.\${P}-cut-item .\${P}-list-cols-row {
|
|
5272
|
+
flex: 1;
|
|
5273
|
+
min-height: 100%;
|
|
5274
|
+
align-items: center;
|
|
5275
|
+
}
|
|
5276
|
+
|
|
5277
|
+
.\${P}-wrapper.\${P}-divider-bottom .\${P}-cut-item {
|
|
5278
|
+
border-bottom-style: solid;
|
|
5279
|
+
border-bottom-color: var(--\${P}-divider-color);
|
|
5280
|
+
}
|
|
5281
|
+
|
|
5282
|
+
.\${P}-cut-label {
|
|
5283
|
+
display: block;
|
|
5284
|
+
position: relative;
|
|
5285
|
+
z-index: 1;
|
|
5286
|
+
margin: 0;
|
|
5287
|
+
color: var(--\${P}-text-color);
|
|
5288
|
+
white-space: pre-wrap;
|
|
5289
|
+
overflow-wrap: anywhere;
|
|
5290
|
+
word-break: break-word;
|
|
5291
|
+
}
|
|
5292
|
+
\`;
|
|
5293
|
+
}
|
|
5294
|
+
|
|
5295
|
+
export const COLUMN_CONTENT_KEYS = [
|
|
5296
|
+
'AColumn',
|
|
5297
|
+
'BColumnWidth',
|
|
5298
|
+
'CColumnWidth',
|
|
5299
|
+
'DColumnWidth',
|
|
5300
|
+
'EColumnWidth',
|
|
5301
|
+
] as const;
|
|
5302
|
+
|
|
5303
|
+
export const COLUMN_TEXT_PREFIXES = [
|
|
5304
|
+
'AColumn',
|
|
5305
|
+
'BColumn',
|
|
5306
|
+
'CColumn',
|
|
5307
|
+
'DColumn',
|
|
5308
|
+
'EColumn',
|
|
5309
|
+
] as const;
|
|
5310
|
+
|
|
5311
|
+
export const CUT_LABEL_TEXT_PREFIX = 'cutLabel' as const;
|
|
5312
|
+
|
|
5313
|
+
export const LIST_TEXT_STYLE_PREFIXES = [
|
|
5314
|
+
...COLUMN_TEXT_PREFIXES,
|
|
5315
|
+
CUT_LABEL_TEXT_PREFIX,
|
|
5316
|
+
] as const;
|
|
5317
|
+
|
|
5318
|
+
export type ListTextStylePrefix = typeof LIST_TEXT_STYLE_PREFIXES[number];
|
|
5319
|
+
|
|
5320
|
+
export const LIST_COLUMN_LETTERS = ['A', 'B', 'C', 'D', 'E'] as const;
|
|
5321
|
+
|
|
5322
|
+
export function getListColumnVerticalAlignSettingKey(columnLetter: string): string {
|
|
5323
|
+
return \`\${columnLetter}ColumnVerticalAlign\`;
|
|
5324
|
+
}
|
|
5325
|
+
|
|
5326
|
+
export const COLUMN_VALIGN_BASIC_OPTIONS = ['Top', 'Center', 'Bottom'] as const;
|
|
5327
|
+
|
|
5328
|
+
export function isBaselineAnchorColumnVerticalAlign(value: string | undefined): boolean {
|
|
5329
|
+
const raw = String(value ?? 'Top').trim();
|
|
5330
|
+
if (raw.toLowerCase().startsWith('baseline')) {
|
|
5331
|
+
return false;
|
|
5332
|
+
}
|
|
5333
|
+
return raw === 'Top' || raw === 'Center' || raw === 'Bottom';
|
|
5334
|
+
}
|
|
5335
|
+
|
|
5336
|
+
export function parseBaselineAnchorLetter(value: string | undefined): string | null {
|
|
5337
|
+
const raw = String(value ?? '').trim();
|
|
5338
|
+
if (!raw.toLowerCase().startsWith('baseline')) {
|
|
5339
|
+
return null;
|
|
5340
|
+
}
|
|
5341
|
+
const anchorLetter = raw.slice(-1).toUpperCase();
|
|
5342
|
+
return LIST_COLUMN_LETTERS.includes(anchorLetter as typeof LIST_COLUMN_LETTERS[number])
|
|
5343
|
+
? anchorLetter
|
|
5344
|
+
: null;
|
|
5345
|
+
}
|
|
5346
|
+
|
|
5347
|
+
export function isValidColumnBaselineVAlign(
|
|
5348
|
+
value: string | undefined,
|
|
5349
|
+
forColumnLetter: string,
|
|
5350
|
+
settings: ListSettings,
|
|
5351
|
+
): boolean {
|
|
5352
|
+
const anchorLetter = parseBaselineAnchorLetter(value);
|
|
5353
|
+
if (!anchorLetter) {
|
|
5354
|
+
return true;
|
|
5355
|
+
}
|
|
5356
|
+
if (anchorLetter === forColumnLetter) {
|
|
5357
|
+
return false;
|
|
5358
|
+
}
|
|
5359
|
+
return isBaselineAnchorColumnVerticalAlign(settings[getListColumnVerticalAlignSettingKey(anchorLetter) as ListColumnVerticalAlignKey]);
|
|
5360
|
+
}
|
|
5361
|
+
|
|
5362
|
+
export function getColumnVerticalAlignOptionsForLetter(
|
|
5363
|
+
columnLetter: string,
|
|
5364
|
+
settings: ListSettings,
|
|
5365
|
+
): string[] {
|
|
5366
|
+
const baselineOptions = LIST_COLUMN_LETTERS
|
|
5367
|
+
.filter((letter) => letter !== columnLetter)
|
|
5368
|
+
.filter((letter) => isBaselineAnchorColumnVerticalAlign(settings[getListColumnVerticalAlignSettingKey(letter) as ListColumnVerticalAlignKey]))
|
|
5369
|
+
.map((letter) => \`Baseline \${letter}\`);
|
|
5370
|
+
|
|
5371
|
+
return [...COLUMN_VALIGN_BASIC_OPTIONS, ...baselineOptions];
|
|
5372
|
+
}
|
|
5373
|
+
|
|
5374
|
+
type ColumnVerticalAlign =
|
|
5375
|
+
| { kind: 'top' | 'center' | 'bottom' }
|
|
5376
|
+
| { kind: 'baseline'; anchorLetter: string };
|
|
5377
|
+
|
|
5378
|
+
function parseColumnVerticalAlign(value: string | undefined): ColumnVerticalAlign {
|
|
5379
|
+
const raw = String(value ?? 'Top').trim();
|
|
5380
|
+
if (raw.toLowerCase().startsWith('baseline')) {
|
|
5381
|
+
const anchorLetter = raw.slice(-1).toUpperCase();
|
|
5382
|
+
if (LIST_COLUMN_LETTERS.includes(anchorLetter as typeof LIST_COLUMN_LETTERS[number])) {
|
|
5383
|
+
return { kind: 'baseline', anchorLetter };
|
|
5384
|
+
}
|
|
5385
|
+
return { kind: 'top' };
|
|
5386
|
+
}
|
|
5387
|
+
if (raw === 'Center') return { kind: 'center' };
|
|
5388
|
+
if (raw === 'Bottom') return { kind: 'bottom' };
|
|
5389
|
+
return { kind: 'top' };
|
|
5390
|
+
}
|
|
5391
|
+
|
|
5392
|
+
function resolveColumnVerticalAlign(
|
|
5393
|
+
value: string | undefined,
|
|
5394
|
+
settings: ListSettings,
|
|
5395
|
+
columnLetter: string,
|
|
5396
|
+
): ColumnVerticalAlign {
|
|
5397
|
+
if (isActiveBaselineVAlign(value, settings, columnLetter)) {
|
|
5398
|
+
return parseColumnVerticalAlign(value);
|
|
5399
|
+
}
|
|
5400
|
+
|
|
5401
|
+
const parsed = parseColumnVerticalAlign(value);
|
|
5402
|
+
if (parsed.kind === 'baseline') {
|
|
5403
|
+
return { kind: 'top' };
|
|
5404
|
+
}
|
|
5405
|
+
|
|
5406
|
+
return parsed;
|
|
5407
|
+
}
|
|
5408
|
+
|
|
5409
|
+
function isActiveBaselineVAlign(
|
|
5410
|
+
value: string | undefined,
|
|
5411
|
+
settings: ListSettings,
|
|
5412
|
+
forColumnLetter: string,
|
|
5413
|
+
): boolean {
|
|
5414
|
+
if (!isValidColumnBaselineVAlign(value, forColumnLetter, settings)) {
|
|
5415
|
+
return false;
|
|
5416
|
+
}
|
|
5417
|
+
return parseColumnVerticalAlign(value).kind === 'baseline';
|
|
5418
|
+
}
|
|
5419
|
+
|
|
5420
|
+
function getListColumnVerticalAlignSanitizeUpdates(
|
|
5421
|
+
settings: ListSettings,
|
|
5422
|
+
): ListColumnVerticalAlignUpdates | null {
|
|
5423
|
+
if (settings.type === 'B') {
|
|
5424
|
+
return null;
|
|
5425
|
+
}
|
|
5426
|
+
|
|
5427
|
+
const updates: ListColumnVerticalAlignUpdates = {};
|
|
5428
|
+
let hasUpdates = false;
|
|
5429
|
+
|
|
5430
|
+
for (const letter of LIST_COLUMN_LETTERS) {
|
|
5431
|
+
const key = getListColumnVerticalAlignSettingKey(letter) as ListColumnVerticalAlignKey;
|
|
5432
|
+
const value = settings[key];
|
|
5433
|
+
if (!isValidColumnBaselineVAlign(value, letter, settings)) {
|
|
5434
|
+
updates[key] = 'Top';
|
|
5435
|
+
hasUpdates = true;
|
|
5436
|
+
}
|
|
5437
|
+
}
|
|
5438
|
+
|
|
5439
|
+
return hasUpdates ? updates : null;
|
|
5440
|
+
}
|
|
5441
|
+
|
|
5442
|
+
function vAlignToTitleStyle(
|
|
5443
|
+
kind: ColumnVerticalAlign['kind'],
|
|
5444
|
+
): React.CSSProperties {
|
|
5445
|
+
if (kind === 'center') {
|
|
5446
|
+
return { marginTop: 'auto', marginBottom: 'auto' };
|
|
5447
|
+
}
|
|
5448
|
+
if (kind === 'bottom') {
|
|
5449
|
+
return { marginTop: 'auto' };
|
|
5450
|
+
}
|
|
5451
|
+
return {};
|
|
5452
|
+
}
|
|
5453
|
+
|
|
5454
|
+
function getFirstLineBaselineOffsetInTitle(
|
|
5455
|
+
titleEl: HTMLElement,
|
|
5456
|
+
probeClassName: string,
|
|
5457
|
+
): number {
|
|
5458
|
+
const probe = document.createElement('i');
|
|
5459
|
+
probe.className = probeClassName;
|
|
5460
|
+
probe.setAttribute('aria-hidden', 'true');
|
|
5461
|
+
titleEl.prepend(probe);
|
|
5462
|
+
|
|
5463
|
+
const { top: titleTop } = titleEl.getBoundingClientRect();
|
|
5464
|
+
const { bottom: probeBottom } = probe.getBoundingClientRect();
|
|
5465
|
+
const baselineOffset = probeBottom - titleTop;
|
|
5466
|
+
probe.remove();
|
|
5467
|
+
|
|
5468
|
+
return baselineOffset;
|
|
5469
|
+
}
|
|
5470
|
+
|
|
5471
|
+
function measureColumnFirstLineBaselineOffset(
|
|
5472
|
+
info: {
|
|
5473
|
+
titleEl: HTMLElement | null;
|
|
5474
|
+
kind: string;
|
|
5475
|
+
},
|
|
5476
|
+
rowTop: number,
|
|
5477
|
+
listColClassName: string,
|
|
5478
|
+
probeClassName: string,
|
|
5479
|
+
): number {
|
|
5480
|
+
const titleEl = info.titleEl;
|
|
5481
|
+
if (!titleEl) return 0;
|
|
5482
|
+
|
|
5483
|
+
const listCol = titleEl.closest<HTMLElement>(\`.\${listColClassName}\`);
|
|
5484
|
+
if (!listCol) return 0;
|
|
5485
|
+
|
|
5486
|
+
const baselineInTitle = getFirstLineBaselineOffsetInTitle(titleEl, probeClassName);
|
|
5487
|
+
|
|
5488
|
+
if (info.kind === 'baseline') {
|
|
5489
|
+
return titleEl.getBoundingClientRect().top - rowTop + baselineInTitle;
|
|
5490
|
+
}
|
|
5491
|
+
|
|
5492
|
+
const listColRect = listCol.getBoundingClientRect();
|
|
5493
|
+
const titleHeight = titleEl.getBoundingClientRect().height;
|
|
5494
|
+
let valignOffset = 0;
|
|
5495
|
+
|
|
5496
|
+
if (info.kind === 'center') {
|
|
5497
|
+
valignOffset = (listColRect.height - titleHeight) / 2;
|
|
5498
|
+
} else if (info.kind === 'bottom') {
|
|
5499
|
+
valignOffset = listColRect.height - titleHeight;
|
|
5500
|
+
}
|
|
5501
|
+
|
|
5502
|
+
return (listColRect.top - rowTop) + valignOffset + baselineInTitle;
|
|
5503
|
+
}
|
|
5504
|
+
|
|
5505
|
+
function syncRowListColHeights(
|
|
5506
|
+
rowEl: HTMLElement,
|
|
5507
|
+
cols: HTMLElement[],
|
|
5508
|
+
listColClassName: string,
|
|
5509
|
+
): number {
|
|
5510
|
+
const rowHeight = rowEl.getBoundingClientRect().height;
|
|
5511
|
+
if (rowHeight <= 0) {
|
|
5512
|
+
return 0;
|
|
5513
|
+
}
|
|
5514
|
+
|
|
5515
|
+
cols.forEach((colEl) => {
|
|
5516
|
+
const listCol = colEl.querySelector<HTMLElement>(\`.\${listColClassName}\`);
|
|
5517
|
+
if (listCol) {
|
|
5518
|
+
listCol.style.minHeight = \`\${rowHeight}px\`;
|
|
5519
|
+
listCol.style.height = \`\${rowHeight}px\`;
|
|
5520
|
+
}
|
|
5521
|
+
});
|
|
5522
|
+
|
|
5523
|
+
void rowEl.offsetHeight;
|
|
5524
|
+
return rowHeight;
|
|
5525
|
+
}
|
|
5526
|
+
|
|
5527
|
+
function applyBaselineTitleShift(titleEl: HTMLElement | null, shift: number): number {
|
|
5528
|
+
if (!titleEl || !shift) {
|
|
5529
|
+
if (titleEl) {
|
|
5530
|
+
titleEl.style.transform = '';
|
|
5531
|
+
}
|
|
5532
|
+
return 0;
|
|
5533
|
+
}
|
|
5534
|
+
|
|
5535
|
+
titleEl.style.transform = \`translateY(\${shift}px)\`;
|
|
5536
|
+
return shift;
|
|
5537
|
+
}
|
|
5538
|
+
|
|
5539
|
+
const COLUMN_CONTENT_KEY_TO_TEXT_PREFIX: Record<
|
|
5540
|
+
typeof COLUMN_CONTENT_KEYS[number],
|
|
5541
|
+
typeof COLUMN_TEXT_PREFIXES[number]
|
|
5542
|
+
> = {
|
|
5543
|
+
AColumn: 'AColumn',
|
|
5544
|
+
BColumnWidth: 'BColumn',
|
|
5545
|
+
CColumnWidth: 'CColumn',
|
|
5546
|
+
DColumnWidth: 'DColumn',
|
|
5547
|
+
EColumnWidth: 'EColumn',
|
|
5548
|
+
};
|
|
5549
|
+
|
|
5550
|
+
export const LIST_GLOBAL_TEXT_STYLE_KEYS = [
|
|
5551
|
+
'textFontFamily',
|
|
5552
|
+
'textFontSettings',
|
|
5553
|
+
'textFontSize',
|
|
5554
|
+
'textLineHeight',
|
|
5555
|
+
'textLetterSpacing',
|
|
5556
|
+
'textWordSpacing',
|
|
5557
|
+
'textTextAppearance',
|
|
5558
|
+
] as const;
|
|
5559
|
+
|
|
5560
|
+
export type ListGlobalTextStyleKey = typeof LIST_GLOBAL_TEXT_STYLE_KEYS[number];
|
|
5561
|
+
|
|
5562
|
+
export function getListColumnTextSettingKey(
|
|
5563
|
+
prefix: ListTextStylePrefix,
|
|
5564
|
+
globalKey: ListGlobalTextStyleKey,
|
|
5565
|
+
): string {
|
|
5566
|
+
return \`\${prefix}\${globalKey.replace(/^text/, 'Text')}\`;
|
|
5567
|
+
}
|
|
5568
|
+
|
|
5569
|
+
type ListTextStyleFields = {
|
|
5570
|
+
textFontFamily?: string;
|
|
5571
|
+
textFontSettings?: { fontWeight: number; fontStyle: string };
|
|
5572
|
+
textFontSize?: number;
|
|
5573
|
+
textLineHeight?: number;
|
|
5574
|
+
textLetterSpacing?: number;
|
|
5575
|
+
textWordSpacing?: number;
|
|
5576
|
+
textTextAppearance?: TextStyles['textAppearance'];
|
|
5577
|
+
textColor?: string;
|
|
5578
|
+
};
|
|
5579
|
+
|
|
5580
|
+
type ResolvedListTextFields = {
|
|
5581
|
+
textFontFamily: string;
|
|
5582
|
+
textFontSettings: { fontWeight: number; fontStyle: string };
|
|
5583
|
+
textFontSize?: number;
|
|
5584
|
+
textLineHeight?: number;
|
|
5585
|
+
textLetterSpacing: number;
|
|
5586
|
+
textWordSpacing: number;
|
|
5587
|
+
textTextAppearance?: TextStyles['textAppearance'];
|
|
5588
|
+
textColor?: string;
|
|
5589
|
+
};
|
|
5590
|
+
|
|
5591
|
+
function resolveListGlobalTextFields(
|
|
5592
|
+
settings: ListTextStyleFields,
|
|
5593
|
+
): ResolvedListTextFields {
|
|
5594
|
+
return {
|
|
5595
|
+
textFontFamily: settings.textFontFamily ?? 'Arial',
|
|
5596
|
+
textFontSettings: settings.textFontSettings ?? {
|
|
5597
|
+
fontWeight: 400,
|
|
5598
|
+
fontStyle: 'normal',
|
|
5599
|
+
},
|
|
5600
|
+
textFontSize: settings.textFontSize,
|
|
5601
|
+
textLineHeight: settings.textLineHeight,
|
|
5602
|
+
textLetterSpacing: settings.textLetterSpacing ?? 0,
|
|
5603
|
+
textWordSpacing: settings.textWordSpacing ?? 0,
|
|
5604
|
+
textTextAppearance: settings.textTextAppearance,
|
|
5605
|
+
textColor: settings.textColor,
|
|
5606
|
+
};
|
|
5607
|
+
}
|
|
5608
|
+
|
|
5609
|
+
function resolveListColumnTextFields(
|
|
5610
|
+
settings: ListSettings,
|
|
5611
|
+
textPrefix: ListTextStylePrefix,
|
|
5612
|
+
): ResolvedListTextFields {
|
|
5613
|
+
const read = <K extends ListGlobalTextStyleKey>(globalKey: K) => {
|
|
5614
|
+
const columnKey = getListColumnTextSettingKey(textPrefix, globalKey);
|
|
5615
|
+
const columnValue = settings[columnKey as keyof ListSettings];
|
|
5616
|
+
if (columnValue !== undefined) {
|
|
5617
|
+
return columnValue as ListTextStyleFields[K];
|
|
5618
|
+
}
|
|
5619
|
+
return settings[globalKey];
|
|
5620
|
+
};
|
|
5621
|
+
|
|
5622
|
+
return {
|
|
5623
|
+
textFontFamily: (read('textFontFamily') as string | undefined) ?? 'Arial',
|
|
5624
|
+
textFontSettings: (read('textFontSettings') as ListTextStyleFields['textFontSettings']) ?? {
|
|
5625
|
+
fontWeight: 400,
|
|
5626
|
+
fontStyle: 'normal',
|
|
5627
|
+
},
|
|
5628
|
+
textFontSize: read('textFontSize') as number | undefined,
|
|
5629
|
+
textLineHeight: read('textLineHeight') as number | undefined,
|
|
5630
|
+
textLetterSpacing: (read('textLetterSpacing') as number | undefined) ?? 0,
|
|
5631
|
+
textWordSpacing: (read('textWordSpacing') as number | undefined) ?? 0,
|
|
5632
|
+
textTextAppearance: read('textTextAppearance') as ListTextStyleFields['textTextAppearance'],
|
|
5633
|
+
textColor: settings.textColor,
|
|
5634
|
+
};
|
|
5635
|
+
}
|
|
5636
|
+
|
|
5637
|
+
function listColumnTextFieldsToCss(
|
|
5638
|
+
fields: ResolvedListTextFields,
|
|
5639
|
+
isEditor?: boolean,
|
|
5640
|
+
): React.CSSProperties {
|
|
5641
|
+
const resolvedTextStyle: TextStyles = {
|
|
5642
|
+
fontSettings: {
|
|
5643
|
+
fontFamily: fields.textFontFamily,
|
|
5644
|
+
fontWeight: fields.textFontSettings?.fontWeight ?? 400,
|
|
5645
|
+
fontStyle: fields.textFontSettings?.fontStyle ?? 'normal',
|
|
5646
|
+
},
|
|
5647
|
+
fontSize: fields.textFontSize ?? 0.01,
|
|
5648
|
+
lineHeight: fields.textLineHeight,
|
|
5649
|
+
letterSpacing: fields.textLetterSpacing,
|
|
5650
|
+
wordSpacing: fields.textWordSpacing,
|
|
5651
|
+
textAppearance: fields.textTextAppearance,
|
|
5652
|
+
color: fields.textColor ?? '#767676',
|
|
5653
|
+
};
|
|
5654
|
+
|
|
5655
|
+
return omitTextColors(textStylesToCss(resolvedTextStyle, isEditor));
|
|
5656
|
+
}
|
|
5657
|
+
|
|
5658
|
+
function getListColumnTitleClassName(
|
|
5659
|
+
settings: ListSettings,
|
|
5660
|
+
prefix: ListTextStylePrefix,
|
|
5661
|
+
baseClassName: string,
|
|
5662
|
+
tightLeadingClassName: string,
|
|
5663
|
+
): string {
|
|
5664
|
+
const fields = resolveListColumnTextFields(settings, prefix);
|
|
5665
|
+
const fontSize = fields.textFontSize ?? 0.01;
|
|
5666
|
+
const lineHeight = fields.textLineHeight;
|
|
5667
|
+
const needsTightLeading = lineHeight !== undefined && lineHeight < fontSize;
|
|
5668
|
+
|
|
5669
|
+
return needsTightLeading
|
|
5670
|
+
? \`\${baseClassName} \${tightLeadingClassName}\`
|
|
5671
|
+
: baseClassName;
|
|
5672
|
+
}
|
|
5673
|
+
|
|
5674
|
+
function getListColumnTitleVars(
|
|
5675
|
+
settings: ListSettings,
|
|
5676
|
+
prefix: ListTextStylePrefix,
|
|
5677
|
+
titleVarPrefix: string,
|
|
5678
|
+
isEditor?: boolean,
|
|
5679
|
+
): React.CSSProperties {
|
|
5680
|
+
const fields = resolveListColumnTextFields(settings, prefix);
|
|
5681
|
+
const fontSize = fields.textFontSize ?? 0.01;
|
|
5682
|
+
const lineHeight = fields.textLineHeight;
|
|
5683
|
+
|
|
5684
|
+
if (lineHeight === undefined || lineHeight >= fontSize) {
|
|
5685
|
+
return {};
|
|
5686
|
+
}
|
|
5687
|
+
|
|
5688
|
+
return {
|
|
5689
|
+
[\`--\${titleVarPrefix}-title-leading-gap\`]: scalingValue((fontSize - lineHeight) / 2, isEditor),
|
|
5690
|
+
} as React.CSSProperties;
|
|
5691
|
+
}
|
|
5692
|
+
|
|
5693
|
+
function getListGlobalTextSyncUpdates(
|
|
5694
|
+
nextSettings: ListSettings,
|
|
5695
|
+
prevSettings: ListSettings,
|
|
5696
|
+
): ListColumnTextStyleSyncUpdates | null {
|
|
5697
|
+
const updates: ListColumnTextStyleSyncUpdates = {};
|
|
5698
|
+
let hasChanges = false;
|
|
5699
|
+
|
|
5700
|
+
for (const globalKey of LIST_GLOBAL_TEXT_STYLE_KEYS) {
|
|
5701
|
+
if (nextSettings[globalKey] === prevSettings[globalKey]) {
|
|
5702
|
+
continue;
|
|
5703
|
+
}
|
|
5704
|
+
if (nextSettings[globalKey] === undefined) {
|
|
5705
|
+
continue;
|
|
5706
|
+
}
|
|
5707
|
+
|
|
5708
|
+
hasChanges = true;
|
|
5709
|
+
for (const prefix of LIST_TEXT_STYLE_PREFIXES) {
|
|
5710
|
+
Object.assign(updates, {
|
|
5711
|
+
[getListColumnTextSettingKey(prefix, globalKey)]: nextSettings[globalKey],
|
|
5712
|
+
});
|
|
5713
|
+
}
|
|
5714
|
+
}
|
|
5715
|
+
|
|
5716
|
+
return hasChanges ? updates : null;
|
|
5717
|
+
}
|
|
5718
|
+
|
|
5719
|
+
const COLUMN_WIDTH_KEYS = [
|
|
5720
|
+
'AColumnWidth',
|
|
5721
|
+
'BColumnWidth',
|
|
5722
|
+
'CColumnWidth',
|
|
5723
|
+
'DColumnWidth',
|
|
5724
|
+
'EColumnWidth',
|
|
5725
|
+
] as const;
|
|
5726
|
+
|
|
5727
|
+
const COLUMN_PADDING_LEFT_KEYS = [
|
|
5728
|
+
'AColumnPaddingLeft',
|
|
5729
|
+
'BColumnPaddingLeft',
|
|
5730
|
+
'CColumnPaddingLeft',
|
|
5731
|
+
'DColumnPaddingLeft',
|
|
5732
|
+
'EColumnPaddingLeft',
|
|
5733
|
+
] as const;
|
|
5734
|
+
|
|
5735
|
+
const COLUMN_PADDING_RIGHT_KEYS = [
|
|
5736
|
+
'AColumnPaddingRight',
|
|
5737
|
+
'BColumnPaddingRight',
|
|
5738
|
+
'CColumnPaddingRight',
|
|
5739
|
+
'DColumnPaddingRight',
|
|
5740
|
+
'EColumnPaddingRight',
|
|
5741
|
+
] as const;
|
|
5742
|
+
|
|
5743
|
+
const COLUMN_PADDING_BOTTOM_KEYS = [
|
|
5744
|
+
'AColumnPaddingBottom',
|
|
5745
|
+
'BColumnPaddingBottom',
|
|
5746
|
+
'CColumnPaddingBottom',
|
|
5747
|
+
'DColumnPaddingBottom',
|
|
5748
|
+
'EColumnPaddingBottom',
|
|
5749
|
+
] as const;
|
|
5750
|
+
|
|
5751
|
+
type ColumnWidthKey = typeof COLUMN_WIDTH_KEYS[number];
|
|
5752
|
+
type ColumnPaddingLeftKey = typeof COLUMN_PADDING_LEFT_KEYS[number];
|
|
5753
|
+
type ColumnPaddingRightKey = typeof COLUMN_PADDING_RIGHT_KEYS[number];
|
|
5754
|
+
type ColumnPaddingBottomKey = typeof COLUMN_PADDING_BOTTOM_KEYS[number];
|
|
5755
|
+
|
|
5756
|
+
type ListColumnPaddingUpdates = {
|
|
5757
|
+
AColumnPaddingLeft?: number;
|
|
5758
|
+
AColumnPaddingRight?: number;
|
|
5759
|
+
BColumnPaddingLeft?: number;
|
|
5760
|
+
BColumnPaddingRight?: number;
|
|
5761
|
+
CColumnPaddingLeft?: number;
|
|
5762
|
+
CColumnPaddingRight?: number;
|
|
5763
|
+
DColumnPaddingLeft?: number;
|
|
5764
|
+
DColumnPaddingRight?: number;
|
|
5765
|
+
EColumnPaddingLeft?: number;
|
|
5766
|
+
EColumnPaddingRight?: number;
|
|
5767
|
+
};
|
|
5768
|
+
|
|
5769
|
+
type ListColumnWidthUpdates = {
|
|
5770
|
+
AColumnWidth?: number;
|
|
5771
|
+
BColumnWidth?: number;
|
|
5772
|
+
CColumnWidth?: number;
|
|
5773
|
+
DColumnWidth?: number;
|
|
5774
|
+
EColumnWidth?: number;
|
|
5775
|
+
};
|
|
5776
|
+
|
|
5777
|
+
type ListItemColumn = {
|
|
5778
|
+
key: string;
|
|
5779
|
+
textPrefix: typeof COLUMN_TEXT_PREFIXES[number];
|
|
5780
|
+
widthKey: ColumnWidthKey;
|
|
5781
|
+
paddingLeftKey: ColumnPaddingLeftKey;
|
|
5782
|
+
paddingRightKey: ColumnPaddingRightKey;
|
|
5783
|
+
paddingBottomKey: ColumnPaddingBottomKey;
|
|
5784
|
+
width: number;
|
|
5785
|
+
paddingLeft: number;
|
|
5786
|
+
paddingRight: number;
|
|
5787
|
+
paddingBottom: number;
|
|
5788
|
+
};
|
|
5789
|
+
|
|
5790
|
+
type ColorKeys =
|
|
5791
|
+
| 'textColor'
|
|
5792
|
+
| 'backgroundColor'
|
|
5793
|
+
| 'dividerColor'
|
|
5794
|
+
| 'textHoverColor'
|
|
5795
|
+
| 'backgroundHoverColor'
|
|
5796
|
+
| 'dividerHoverColor';
|
|
5797
|
+
|
|
5798
|
+
const COLOR_VAR_MAP: Record<ColorKeys, string> = {
|
|
5799
|
+
textColor: 'text-color',
|
|
5800
|
+
backgroundColor: 'background-color',
|
|
5801
|
+
dividerColor: 'divider-color',
|
|
5802
|
+
textHoverColor: 'text-hover-color',
|
|
5803
|
+
backgroundHoverColor: 'background-hover-color',
|
|
5804
|
+
dividerHoverColor: 'divider-hover-color',
|
|
5805
|
+
};
|
|
5806
|
+
|
|
5807
|
+
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
5808
|
+
|
|
5809
|
+
const COL_RESIZE_HANDLE_WIDTH = 0.004;
|
|
5810
|
+
const COL_PADDING_HANDLE_WIDTH = 0.004;
|
|
5811
|
+
const MIN_COLUMN_WIDTH_PX = 50;
|
|
5812
|
+
const ARTICLE_DESIGN_WIDTH = 1440;
|
|
5813
|
+
const MIN_COLUMN_WIDTH = MIN_COLUMN_WIDTH_PX / ARTICLE_DESIGN_WIDTH;
|
|
5814
|
+
|
|
5815
|
+
export function getListMinColumnWidth(designWidthPx?: number): number {
|
|
5816
|
+
const designWidth = typeof designWidthPx === 'number' && designWidthPx > 0
|
|
5817
|
+
? designWidthPx
|
|
5818
|
+
: ARTICLE_DESIGN_WIDTH;
|
|
5819
|
+
|
|
5820
|
+
return MIN_COLUMN_WIDTH_PX / designWidth;
|
|
5821
|
+
}
|
|
5822
|
+
|
|
5823
|
+
function getEditorDesignWidth(element: HTMLElement | null | undefined): number {
|
|
5824
|
+
let el = element ?? null;
|
|
5825
|
+
|
|
5826
|
+
while (el) {
|
|
5827
|
+
const inline = el.style.getPropertyValue('--cntrl-article-width').trim();
|
|
5828
|
+
if (inline) {
|
|
5829
|
+
const px = parseFloat(inline);
|
|
5830
|
+
if (Number.isFinite(px) && px > 0) {
|
|
5831
|
+
return px;
|
|
5832
|
+
}
|
|
5833
|
+
}
|
|
5834
|
+
|
|
5835
|
+
const computed = getComputedStyle(el).getPropertyValue('--cntrl-article-width').trim();
|
|
5836
|
+
if (computed) {
|
|
5837
|
+
const px = parseFloat(computed);
|
|
5838
|
+
if (Number.isFinite(px) && px > 0) {
|
|
5839
|
+
return px;
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
|
|
5843
|
+
el = el.parentElement;
|
|
5844
|
+
}
|
|
5845
|
+
|
|
5846
|
+
return ARTICLE_DESIGN_WIDTH;
|
|
5847
|
+
}
|
|
5848
|
+
|
|
5849
|
+
const DEFAULT_COLUMN_WIDTHS: Record<ColumnWidthKey, number> = {
|
|
5850
|
+
AColumnWidth: 0.02,
|
|
5851
|
+
BColumnWidth: 0.02,
|
|
5852
|
+
CColumnWidth: 0.02,
|
|
5853
|
+
DColumnWidth: 0.02,
|
|
5854
|
+
EColumnWidth: 0.02,
|
|
5855
|
+
};
|
|
5856
|
+
|
|
5857
|
+
export function getListEffectiveContentWidth(
|
|
5858
|
+
settings: ListSettings,
|
|
5859
|
+
): number {
|
|
5860
|
+
const wrapperWidth = typeof settings.wrapperWidth === 'number' ? settings.wrapperWidth : 1;
|
|
5861
|
+
|
|
5862
|
+
return Math.max(0, wrapperWidth);
|
|
5863
|
+
}
|
|
5864
|
+
|
|
5865
|
+
export function getEqualListColumnWidthUpdates(
|
|
5866
|
+
columns: number,
|
|
5867
|
+
contentWidth: number = 1,
|
|
5868
|
+
): Record<ColumnWidthKey, number> {
|
|
5869
|
+
const equalColumnWidth = contentWidth / columns;
|
|
5870
|
+
return Object.fromEntries(
|
|
5871
|
+
COLUMN_WIDTH_KEYS.map((key) => [key, equalColumnWidth]),
|
|
5872
|
+
) as Record<ColumnWidthKey, number>;
|
|
5873
|
+
}
|
|
5874
|
+
|
|
5875
|
+
function getResetListColumnPaddingUpdates(): Record<
|
|
5876
|
+
ColumnPaddingLeftKey | ColumnPaddingRightKey,
|
|
5877
|
+
number
|
|
5878
|
+
> {
|
|
5879
|
+
return Object.fromEntries([
|
|
5880
|
+
...COLUMN_PADDING_LEFT_KEYS.map((key) => [key, 0]),
|
|
5881
|
+
...COLUMN_PADDING_RIGHT_KEYS.map((key) => [key, 0]),
|
|
5882
|
+
]) as Record<ColumnPaddingLeftKey | ColumnPaddingRightKey, number>;
|
|
5883
|
+
}
|
|
5884
|
+
|
|
5885
|
+
function getResetListColumnPaddingBottomUpdates(): Record<ColumnPaddingBottomKey, number> {
|
|
5886
|
+
return Object.fromEntries(
|
|
5887
|
+
COLUMN_PADDING_BOTTOM_KEYS.map((key) => [key, 0]),
|
|
5888
|
+
) as Record<ColumnPaddingBottomKey, number>;
|
|
5889
|
+
}
|
|
5890
|
+
|
|
5891
|
+
function getStoredColumnWidths(
|
|
5892
|
+
settings: ListSettings,
|
|
5893
|
+
): Record<ColumnWidthKey, number> {
|
|
5894
|
+
return Object.fromEntries(
|
|
5895
|
+
COLUMN_WIDTH_KEYS.map((key) => [
|
|
5896
|
+
key,
|
|
5897
|
+
typeof settings[key] === 'number'
|
|
5898
|
+
? settings[key] as number
|
|
5899
|
+
: DEFAULT_COLUMN_WIDTHS[key],
|
|
5900
|
+
]),
|
|
5901
|
+
) as Record<ColumnWidthKey, number>;
|
|
5902
|
+
}
|
|
5903
|
+
|
|
5904
|
+
export function resolveListColumnPadding(
|
|
5905
|
+
columnWidth: number,
|
|
5906
|
+
paddingLeft: number,
|
|
5907
|
+
paddingRight: number,
|
|
5908
|
+
): { paddingLeft: number; paddingRight: number } {
|
|
5909
|
+
const maxTotalPadding = columnWidth - MIN_COLUMN_WIDTH;
|
|
5910
|
+
const totalPadding = paddingLeft + paddingRight;
|
|
5911
|
+
|
|
5912
|
+
if (totalPadding <= 0 || totalPadding <= maxTotalPadding) {
|
|
5913
|
+
return { paddingLeft, paddingRight };
|
|
5914
|
+
}
|
|
5915
|
+
|
|
5916
|
+
if (maxTotalPadding <= 0) {
|
|
5917
|
+
return { paddingLeft: 0, paddingRight: 0 };
|
|
5918
|
+
}
|
|
5919
|
+
|
|
5920
|
+
const scale = maxTotalPadding / totalPadding;
|
|
5921
|
+
|
|
5922
|
+
return {
|
|
5923
|
+
paddingLeft: paddingLeft * scale,
|
|
5924
|
+
paddingRight: paddingRight * scale,
|
|
5925
|
+
};
|
|
5926
|
+
}
|
|
5927
|
+
|
|
5928
|
+
export function getEffectiveListColumnWidths(
|
|
5929
|
+
columns: number,
|
|
5930
|
+
wrapperWidth: number,
|
|
5931
|
+
storedWidths: Record<ColumnWidthKey, number>,
|
|
5932
|
+
): number[] {
|
|
5933
|
+
const resolvedWidths = resolveListColumnWidths(columns, wrapperWidth, storedWidths);
|
|
5934
|
+
|
|
5935
|
+
if (columns <= 0) {
|
|
5936
|
+
return [];
|
|
5937
|
+
}
|
|
5938
|
+
|
|
5939
|
+
const sumFixed = resolvedWidths.slice(0, columns - 1).reduce((sum, width) => sum + width, 0);
|
|
5940
|
+
|
|
5941
|
+
return [
|
|
5942
|
+
...resolvedWidths.slice(0, columns - 1),
|
|
5943
|
+
Math.max(0, wrapperWidth - sumFixed),
|
|
5944
|
+
];
|
|
5945
|
+
}
|
|
5946
|
+
|
|
5947
|
+
function getListColumnPaddingUpdates(
|
|
5948
|
+
columns: number,
|
|
5949
|
+
effectiveWidths: number[],
|
|
5950
|
+
settings: ListSettings,
|
|
5951
|
+
): ListColumnPaddingUpdates {
|
|
5952
|
+
const updates: ListColumnPaddingUpdates = {};
|
|
5953
|
+
|
|
5954
|
+
for (let index = 0; index < columns; index += 1) {
|
|
5955
|
+
const paddingLeftKey = COLUMN_PADDING_LEFT_KEYS[index];
|
|
5956
|
+
const paddingRightKey = COLUMN_PADDING_RIGHT_KEYS[index];
|
|
5957
|
+
const storedPaddingLeft = typeof settings[paddingLeftKey] === 'number'
|
|
5958
|
+
? settings[paddingLeftKey] as number
|
|
5959
|
+
: 0;
|
|
5960
|
+
const storedPaddingRight = typeof settings[paddingRightKey] === 'number'
|
|
5961
|
+
? settings[paddingRightKey] as number
|
|
5962
|
+
: 0;
|
|
5963
|
+
const resolvedPadding = resolveListColumnPadding(
|
|
5964
|
+
effectiveWidths[index] ?? 0,
|
|
5965
|
+
storedPaddingLeft,
|
|
5966
|
+
storedPaddingRight,
|
|
5967
|
+
);
|
|
5968
|
+
|
|
5969
|
+
if (resolvedPadding.paddingLeft !== storedPaddingLeft) {
|
|
5970
|
+
updates[paddingLeftKey] = resolvedPadding.paddingLeft;
|
|
5971
|
+
}
|
|
5972
|
+
|
|
5973
|
+
if (resolvedPadding.paddingRight !== storedPaddingRight) {
|
|
5974
|
+
updates[paddingRightKey] = resolvedPadding.paddingRight;
|
|
5975
|
+
}
|
|
5976
|
+
}
|
|
5977
|
+
|
|
5978
|
+
return updates;
|
|
5979
|
+
}
|
|
5980
|
+
|
|
5981
|
+
export function resolveListColumnWidths(
|
|
5982
|
+
columns: number,
|
|
5983
|
+
wrapperWidth: number,
|
|
5984
|
+
storedWidths: Record<ColumnWidthKey, number>,
|
|
5985
|
+
): number[] {
|
|
5986
|
+
if (columns <= 0) {
|
|
5987
|
+
return [];
|
|
5988
|
+
}
|
|
5989
|
+
|
|
5990
|
+
const widths = COLUMN_WIDTH_KEYS.slice(0, columns).map(
|
|
5991
|
+
(key) => storedWidths[key],
|
|
5992
|
+
);
|
|
5993
|
+
|
|
5994
|
+
if (columns === 1) {
|
|
5995
|
+
return widths;
|
|
5996
|
+
}
|
|
5997
|
+
|
|
5998
|
+
const fixedWidths = widths.slice(0, columns - 1);
|
|
5999
|
+
const fixedSum = fixedWidths.reduce((sum, width) => sum + width, 0);
|
|
6000
|
+
const minTotalWidth = fixedSum + MIN_COLUMN_WIDTH;
|
|
6001
|
+
|
|
6002
|
+
if (wrapperWidth >= minTotalWidth) {
|
|
6003
|
+
return widths;
|
|
6004
|
+
}
|
|
6005
|
+
|
|
6006
|
+
const resolvedFixedWidths = [...fixedWidths];
|
|
6007
|
+
let overflow = minTotalWidth - wrapperWidth;
|
|
6008
|
+
|
|
6009
|
+
for (let index = resolvedFixedWidths.length - 1; index >= 0 && overflow > 0; index -= 1) {
|
|
6010
|
+
const shrinkable = resolvedFixedWidths[index] - MIN_COLUMN_WIDTH;
|
|
6011
|
+
if (shrinkable <= 0) {
|
|
6012
|
+
continue;
|
|
6013
|
+
}
|
|
6014
|
+
|
|
6015
|
+
const shrinkAmount = Math.min(overflow, shrinkable);
|
|
6016
|
+
resolvedFixedWidths[index] -= shrinkAmount;
|
|
6017
|
+
overflow -= shrinkAmount;
|
|
6018
|
+
}
|
|
6019
|
+
|
|
6020
|
+
return [...resolvedFixedWidths, widths[columns - 1]];
|
|
6021
|
+
}
|
|
6022
|
+
|
|
6023
|
+
function getListColumnWidthUpdatesForWrapperWidth(
|
|
6024
|
+
columns: number,
|
|
6025
|
+
wrapperWidth: number,
|
|
6026
|
+
storedWidths: Record<ColumnWidthKey, number>,
|
|
6027
|
+
): ListColumnWidthUpdates {
|
|
6028
|
+
if (columns <= 1) {
|
|
6029
|
+
return {};
|
|
6030
|
+
}
|
|
6031
|
+
|
|
6032
|
+
const resolvedWidths = resolveListColumnWidths(columns, wrapperWidth, storedWidths);
|
|
6033
|
+
const updates: ListColumnWidthUpdates = {};
|
|
6034
|
+
|
|
6035
|
+
for (let index = 0; index < columns - 1; index += 1) {
|
|
6036
|
+
const key = COLUMN_WIDTH_KEYS[index];
|
|
6037
|
+
if (resolvedWidths[index] !== storedWidths[key]) {
|
|
6038
|
+
updates[key] = resolvedWidths[index];
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
|
|
6042
|
+
return updates;
|
|
6043
|
+
}
|
|
6044
|
+
|
|
6045
|
+
function getColumnsOrder(settings: ListSettings): string[] {
|
|
6046
|
+
if (Array.isArray(settings.columnsOrder) && settings.columnsOrder.length > 0) {
|
|
6047
|
+
return settings.columnsOrder as string[];
|
|
6048
|
+
}
|
|
6049
|
+
|
|
6050
|
+
return [...COLUMN_CONTENT_KEYS];
|
|
6051
|
+
}
|
|
6052
|
+
|
|
6053
|
+
function areStringArraysEqual(left: string[], right: string[]): boolean {
|
|
6054
|
+
if (left.length !== right.length) {
|
|
6055
|
+
return false;
|
|
6056
|
+
}
|
|
6057
|
+
|
|
6058
|
+
return left.every((value, index) => value === right[index]);
|
|
6059
|
+
}
|
|
6060
|
+
|
|
6061
|
+
function getColumnLayoutUpdatesForOrderChange(
|
|
6062
|
+
nextOrder: string[],
|
|
6063
|
+
prevOrder: string[],
|
|
6064
|
+
prevSettings: ListSettings,
|
|
6065
|
+
columns: number,
|
|
6066
|
+
): Record<string, number> {
|
|
6067
|
+
const count = Math.min(columns, nextOrder.length, COLUMN_WIDTH_KEYS.length);
|
|
6068
|
+
const updates: Record<string, number> = {};
|
|
6069
|
+
|
|
6070
|
+
for (let index = 0; index < count; index += 1) {
|
|
6071
|
+
const contentKey = nextOrder[index];
|
|
6072
|
+
const prevSlotIndex = prevOrder.indexOf(contentKey);
|
|
6073
|
+
|
|
6074
|
+
if (prevSlotIndex === -1) {
|
|
6075
|
+
continue;
|
|
6076
|
+
}
|
|
6077
|
+
|
|
6078
|
+
const prevWidthKey = COLUMN_WIDTH_KEYS[prevSlotIndex];
|
|
6079
|
+
const prevPaddingLeftKey = COLUMN_PADDING_LEFT_KEYS[prevSlotIndex];
|
|
6080
|
+
const prevPaddingRightKey = COLUMN_PADDING_RIGHT_KEYS[prevSlotIndex];
|
|
6081
|
+
const prevPaddingBottomKey = COLUMN_PADDING_BOTTOM_KEYS[prevSlotIndex];
|
|
6082
|
+
const widthKey = COLUMN_WIDTH_KEYS[index];
|
|
6083
|
+
const paddingLeftKey = COLUMN_PADDING_LEFT_KEYS[index];
|
|
6084
|
+
const paddingRightKey = COLUMN_PADDING_RIGHT_KEYS[index];
|
|
6085
|
+
const paddingBottomKey = COLUMN_PADDING_BOTTOM_KEYS[index];
|
|
6086
|
+
|
|
6087
|
+
const prevWidth = prevSettings[prevWidthKey];
|
|
6088
|
+
const prevPaddingLeft = prevSettings[prevPaddingLeftKey];
|
|
6089
|
+
const prevPaddingRight = prevSettings[prevPaddingRightKey];
|
|
6090
|
+
const prevPaddingBottom = prevSettings[prevPaddingBottomKey];
|
|
6091
|
+
|
|
6092
|
+
if (typeof prevWidth === 'number') {
|
|
6093
|
+
updates[widthKey] = prevWidth;
|
|
6094
|
+
}
|
|
6095
|
+
|
|
6096
|
+
if (typeof prevPaddingLeft === 'number') {
|
|
6097
|
+
updates[paddingLeftKey] = prevPaddingLeft;
|
|
6098
|
+
}
|
|
6099
|
+
|
|
6100
|
+
if (typeof prevPaddingRight === 'number') {
|
|
6101
|
+
updates[paddingRightKey] = prevPaddingRight;
|
|
6102
|
+
}
|
|
6103
|
+
|
|
6104
|
+
if (typeof prevPaddingBottom === 'number') {
|
|
6105
|
+
updates[paddingBottomKey] = prevPaddingBottom;
|
|
6106
|
+
}
|
|
6107
|
+
}
|
|
6108
|
+
|
|
6109
|
+
return updates;
|
|
6110
|
+
}
|
|
6111
|
+
|
|
6112
|
+
export function applyListSettingsChange(
|
|
6113
|
+
nextSettings: ListSettings,
|
|
6114
|
+
prevSettings: ListSettings,
|
|
6115
|
+
options?: { designWidth?: number },
|
|
6116
|
+
): ListSettings {
|
|
6117
|
+
const textSyncUpdates = getListGlobalTextSyncUpdates(nextSettings, prevSettings);
|
|
6118
|
+
if (textSyncUpdates) {
|
|
6119
|
+
nextSettings = { ...nextSettings, ...textSyncUpdates };
|
|
6120
|
+
}
|
|
6121
|
+
|
|
6122
|
+
const valignSanitizeUpdates = getListColumnVerticalAlignSanitizeUpdates(nextSettings);
|
|
6123
|
+
if (valignSanitizeUpdates) {
|
|
6124
|
+
nextSettings = { ...nextSettings, ...valignSanitizeUpdates };
|
|
6125
|
+
}
|
|
6126
|
+
|
|
6127
|
+
const minColumnWidth = getListMinColumnWidth(options?.designWidth);
|
|
6128
|
+
const nextColumns = nextSettings.columns;
|
|
6129
|
+
const prevColumns = prevSettings.columns;
|
|
6130
|
+
const nextContentWidth = getListEffectiveContentWidth(nextSettings);
|
|
6131
|
+
const prevContentWidth = getListEffectiveContentWidth(prevSettings);
|
|
6132
|
+
const isVerticalLayout = nextSettings.type === 'B'
|
|
6133
|
+
|| (nextSettings.type === undefined && prevSettings.type === 'B');
|
|
6134
|
+
const columns =
|
|
6135
|
+
typeof nextColumns === 'number'
|
|
6136
|
+
? nextColumns
|
|
6137
|
+
: typeof prevColumns === 'number'
|
|
6138
|
+
? prevColumns
|
|
6139
|
+
: COLUMN_CONTENT_KEYS.length;
|
|
6140
|
+
|
|
6141
|
+
const withColumnPaddingUpdates = (
|
|
6142
|
+
settings: ListSettings,
|
|
6143
|
+
): ListSettings => {
|
|
6144
|
+
if (isVerticalLayout) {
|
|
6145
|
+
return settings;
|
|
6146
|
+
}
|
|
6147
|
+
|
|
6148
|
+
const storedWidths = getStoredColumnWidths({ ...prevSettings, ...settings });
|
|
6149
|
+
const contentWidth = getListEffectiveContentWidth(settings);
|
|
6150
|
+
const effectiveWidths = getEffectiveListColumnWidths(columns, contentWidth, storedWidths);
|
|
6151
|
+
const paddingUpdates = getListColumnPaddingUpdates(columns, effectiveWidths, {
|
|
6152
|
+
...prevSettings,
|
|
6153
|
+
...settings,
|
|
6154
|
+
});
|
|
6155
|
+
|
|
6156
|
+
if (Object.keys(paddingUpdates).length === 0) {
|
|
6157
|
+
return settings;
|
|
6158
|
+
}
|
|
6159
|
+
|
|
6160
|
+
return {
|
|
6161
|
+
...settings,
|
|
6162
|
+
...paddingUpdates,
|
|
6163
|
+
};
|
|
6164
|
+
};
|
|
6165
|
+
|
|
6166
|
+
if (typeof nextColumns === 'number' && nextColumns !== prevColumns) {
|
|
6167
|
+
const updates: ListSettings = {
|
|
6168
|
+
...nextSettings,
|
|
6169
|
+
...getEqualListColumnWidthUpdates(nextColumns, nextContentWidth),
|
|
6170
|
+
...getResetListColumnPaddingUpdates(),
|
|
6171
|
+
};
|
|
6172
|
+
|
|
6173
|
+
if (isVerticalLayout) {
|
|
6174
|
+
for (const key of COLUMN_PADDING_BOTTOM_KEYS) {
|
|
6175
|
+
if (typeof prevSettings[key] === 'number') {
|
|
6176
|
+
updates[key] = prevSettings[key];
|
|
6177
|
+
}
|
|
6178
|
+
}
|
|
6179
|
+
} else {
|
|
6180
|
+
Object.assign(updates, getResetListColumnPaddingBottomUpdates());
|
|
6181
|
+
}
|
|
6182
|
+
|
|
6183
|
+
return updates;
|
|
6184
|
+
}
|
|
6185
|
+
|
|
6186
|
+
const nextOrder = getColumnsOrder(nextSettings);
|
|
6187
|
+
const prevOrder = getColumnsOrder(prevSettings);
|
|
6188
|
+
|
|
6189
|
+
if (!areStringArraysEqual(nextOrder, prevOrder)) {
|
|
6190
|
+
return withColumnPaddingUpdates({
|
|
6191
|
+
...nextSettings,
|
|
6192
|
+
...getColumnLayoutUpdatesForOrderChange(nextOrder, prevOrder, prevSettings, columns),
|
|
6193
|
+
});
|
|
6194
|
+
}
|
|
6195
|
+
|
|
6196
|
+
if (nextContentWidth < prevContentWidth) {
|
|
6197
|
+
if (typeof columns === 'number' && !isVerticalLayout) {
|
|
6198
|
+
const storedWidths = getStoredColumnWidths({ ...prevSettings, ...nextSettings });
|
|
6199
|
+
|
|
6200
|
+
return withColumnPaddingUpdates({
|
|
6201
|
+
...nextSettings,
|
|
6202
|
+
...getListColumnWidthUpdatesForWrapperWidth(columns, nextContentWidth, storedWidths),
|
|
6203
|
+
});
|
|
6204
|
+
}
|
|
6205
|
+
}
|
|
6206
|
+
|
|
6207
|
+
if (isVerticalLayout) {
|
|
6208
|
+
const storedTextPaddingLR = typeof nextSettings.textPaddingLR === 'number'
|
|
6209
|
+
? nextSettings.textPaddingLR as number
|
|
6210
|
+
: 0;
|
|
6211
|
+
const maxAllowedPadding = Math.max(0, (nextContentWidth - minColumnWidth) / 2);
|
|
6212
|
+
|
|
6213
|
+
if (storedTextPaddingLR > maxAllowedPadding) {
|
|
6214
|
+
return { ...nextSettings, textPaddingLR: maxAllowedPadding };
|
|
6215
|
+
}
|
|
6216
|
+
|
|
6217
|
+
return nextSettings;
|
|
6218
|
+
}
|
|
6219
|
+
|
|
6220
|
+
const storedWidths = getStoredColumnWidths({ ...prevSettings, ...nextSettings });
|
|
6221
|
+
const prevEffectiveWidths = getEffectiveListColumnWidths(
|
|
6222
|
+
columns,
|
|
6223
|
+
prevContentWidth,
|
|
6224
|
+
getStoredColumnWidths(prevSettings),
|
|
6225
|
+
);
|
|
6226
|
+
const nextEffectiveWidths = getEffectiveListColumnWidths(
|
|
6227
|
+
columns,
|
|
6228
|
+
nextContentWidth,
|
|
6229
|
+
storedWidths,
|
|
6230
|
+
);
|
|
6231
|
+
const columnWidthDecreased = nextEffectiveWidths.some(
|
|
6232
|
+
(width, index) => width < (prevEffectiveWidths[index] ?? width),
|
|
6233
|
+
);
|
|
6234
|
+
const columnWidthSettingChanged = COLUMN_WIDTH_KEYS.some((key) => {
|
|
6235
|
+
const nextWidth = nextSettings[key];
|
|
6236
|
+
const prevWidth = prevSettings[key];
|
|
6237
|
+
|
|
6238
|
+
return typeof nextWidth === 'number'
|
|
6239
|
+
&& typeof prevWidth === 'number'
|
|
6240
|
+
&& nextWidth !== prevWidth;
|
|
6241
|
+
});
|
|
6242
|
+
|
|
6243
|
+
if (columnWidthDecreased || columnWidthSettingChanged) {
|
|
6244
|
+
return withColumnPaddingUpdates(nextSettings);
|
|
6245
|
+
}
|
|
6246
|
+
|
|
6247
|
+
return nextSettings;
|
|
6248
|
+
}
|
|
6249
|
+
|
|
6250
|
+
function getColumnMaxWidth(
|
|
6251
|
+
columnIndex: number,
|
|
6252
|
+
resolvedWidths: number[],
|
|
6253
|
+
storedWidths: number[],
|
|
6254
|
+
wrapperWidth: number,
|
|
6255
|
+
): number {
|
|
6256
|
+
const leftWidth = resolvedWidths
|
|
6257
|
+
.slice(0, columnIndex)
|
|
6258
|
+
.reduce((sum, width) => sum + width, 0);
|
|
6259
|
+
const rightPreferredWidth = storedWidths
|
|
6260
|
+
.slice(columnIndex + 1, resolvedWidths.length - 1)
|
|
6261
|
+
.reduce((sum, width) => sum + width, 0);
|
|
6262
|
+
|
|
6263
|
+
return Math.max(
|
|
6264
|
+
MIN_COLUMN_WIDTH,
|
|
6265
|
+
wrapperWidth - leftWidth - rightPreferredWidth - MIN_COLUMN_WIDTH,
|
|
6266
|
+
);
|
|
6267
|
+
}
|
|
6268
|
+
|
|
6269
|
+
function randomBetween(min: number, max: number): number {
|
|
6270
|
+
return Math.random() * (max - min) + min;
|
|
6271
|
+
}
|
|
6272
|
+
|
|
6273
|
+
function getColumnWidthsFromSettings(
|
|
6274
|
+
settings: ListSettings,
|
|
6275
|
+
): Record<ColumnWidthKey, number> {
|
|
6276
|
+
return Object.fromEntries(
|
|
6277
|
+
COLUMN_WIDTH_KEYS.map((key) => [
|
|
6278
|
+
key,
|
|
6279
|
+
typeof settings[key] === 'number' ? settings[key] as number : DEFAULT_COLUMN_WIDTHS[key],
|
|
6280
|
+
]),
|
|
6281
|
+
) as Record<ColumnWidthKey, number>;
|
|
6282
|
+
}
|
|
6283
|
+
|
|
6284
|
+
function getNumericSettingValues<K extends ColumnPaddingLeftKey | ColumnPaddingRightKey | ColumnPaddingBottomKey>(
|
|
6285
|
+
settings: ListSettings,
|
|
6286
|
+
keys: readonly K[],
|
|
6287
|
+
fallback = 0,
|
|
6288
|
+
): Record<K, number> {
|
|
6289
|
+
return Object.fromEntries(
|
|
6290
|
+
keys.map((key) => [
|
|
6291
|
+
key,
|
|
6292
|
+
typeof settings[key] === 'number' ? settings[key] as number : fallback,
|
|
6293
|
+
]),
|
|
6294
|
+
) as Record<K, number>;
|
|
6295
|
+
}
|
|
6296
|
+
|
|
6297
|
+
function buildListColumns(
|
|
6298
|
+
columnContentOrder: readonly typeof COLUMN_CONTENT_KEYS[number][],
|
|
6299
|
+
columns: number,
|
|
6300
|
+
columnWidthByKey: Record<ColumnWidthKey, number>,
|
|
6301
|
+
columnPaddingLeftByKey: Record<ColumnPaddingLeftKey, number>,
|
|
6302
|
+
columnPaddingRightByKey: Record<ColumnPaddingRightKey, number>,
|
|
6303
|
+
columnPaddingBottomByKey: Record<ColumnPaddingBottomKey, number>,
|
|
6304
|
+
): ListItemColumn[] {
|
|
6305
|
+
return columnContentOrder.slice(0, columns).map((key, index) => {
|
|
6306
|
+
const paddingLeftKey = COLUMN_PADDING_LEFT_KEYS[index];
|
|
6307
|
+
const paddingRightKey = COLUMN_PADDING_RIGHT_KEYS[index];
|
|
6308
|
+
const paddingBottomKey = COLUMN_PADDING_BOTTOM_KEYS[index];
|
|
6309
|
+
|
|
6310
|
+
return {
|
|
6311
|
+
key,
|
|
6312
|
+
textPrefix: COLUMN_CONTENT_KEY_TO_TEXT_PREFIX[key],
|
|
6313
|
+
widthKey: COLUMN_WIDTH_KEYS[index],
|
|
6314
|
+
width: columnWidthByKey[COLUMN_WIDTH_KEYS[index]],
|
|
6315
|
+
paddingLeftKey,
|
|
6316
|
+
paddingRightKey,
|
|
6317
|
+
paddingBottomKey,
|
|
6318
|
+
paddingLeft: columnPaddingLeftByKey[paddingLeftKey],
|
|
6319
|
+
paddingRight: columnPaddingRightByKey[paddingRightKey],
|
|
6320
|
+
paddingBottom: columnPaddingBottomByKey[paddingBottomKey],
|
|
6321
|
+
};
|
|
6322
|
+
});
|
|
6323
|
+
}
|
|
6324
|
+
|
|
6325
|
+
export function List({ settings, content, isEditor, isPreviewMode, activeEvent, layoutId, onUpdateSettings }: ListProps) {
|
|
6326
|
+
const { prefix: P } = useScopedStyles();
|
|
6327
|
+
const showControls = Boolean(isEditor && isPreviewMode);
|
|
6328
|
+
const {
|
|
6329
|
+
columns,
|
|
6330
|
+
type,
|
|
6331
|
+
wrapperWidth,
|
|
6332
|
+
entriesCount,
|
|
6333
|
+
cellMinHeight,
|
|
6334
|
+
dividerWidth,
|
|
6335
|
+
showVisibility,
|
|
6336
|
+
cut,
|
|
6337
|
+
showCut,
|
|
6338
|
+
cutCellMinHeight,
|
|
6339
|
+
cutLabel,
|
|
6340
|
+
imageSize,
|
|
6341
|
+
imageOnHover,
|
|
6342
|
+
entryHoverEffect,
|
|
6343
|
+
rowPaddingTop,
|
|
6344
|
+
rowPaddingBottom,
|
|
6345
|
+
rowPaddingTopB,
|
|
6346
|
+
columnsOrder,
|
|
6347
|
+
textPaddingLR,
|
|
6348
|
+
textColor,
|
|
6349
|
+
textFontFamily,
|
|
6350
|
+
textFontSettings,
|
|
6351
|
+
textFontSize,
|
|
6352
|
+
textLineHeight,
|
|
6353
|
+
textLetterSpacing,
|
|
6354
|
+
textWordSpacing,
|
|
6355
|
+
textTextAppearance,
|
|
6356
|
+
backgroundColor,
|
|
6357
|
+
dividerColor,
|
|
6358
|
+
textHoverColor,
|
|
6359
|
+
backgroundHoverColor,
|
|
6360
|
+
dividerHoverColor,
|
|
6361
|
+
} = settings;
|
|
6362
|
+
|
|
6363
|
+
const [visibleRowCount, setVisibleRowCount] = useState<number | undefined>(undefined);
|
|
6364
|
+
const [hoverImage, setHoverImage] = useState<HoverImageState | null>(null);
|
|
6365
|
+
const showHoverImage = imageOnHover === 'On' && (!isEditor || isPreviewMode);
|
|
6366
|
+
const cutEnabled = (cut ?? 0) > 0;
|
|
6367
|
+
const isVerticalLayout = type === 'B';
|
|
6368
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
6369
|
+
const [designWidth, setDesignWidth] = useState(ARTICLE_DESIGN_WIDTH);
|
|
6370
|
+
const minColumnWidth = getListMinColumnWidth(designWidth);
|
|
6371
|
+
|
|
6372
|
+
const storedTextPaddingLRMax = Math.max(0, ((wrapperWidth ?? 0) - minColumnWidth) / 2);
|
|
6373
|
+
const effectiveTextPaddingLR = Math.min(textPaddingLR ?? 0, storedTextPaddingLRMax);
|
|
6374
|
+
const textPaddingLRHandleWidth = Math.max(effectiveTextPaddingLR, COL_PADDING_HANDLE_WIDTH);
|
|
6375
|
+
const textPaddingLRMaxFraction = ((wrapperWidth ?? 0) + minColumnWidth) / 2;
|
|
6376
|
+
|
|
6377
|
+
useLayoutEffect(() => {
|
|
6378
|
+
if (!isEditor) {
|
|
6379
|
+
setDesignWidth(ARTICLE_DESIGN_WIDTH);
|
|
6380
|
+
return;
|
|
6381
|
+
}
|
|
6382
|
+
|
|
6383
|
+
const syncDesignWidth = () => {
|
|
6384
|
+
setDesignWidth(getEditorDesignWidth(containerRef.current));
|
|
6385
|
+
};
|
|
6386
|
+
|
|
6387
|
+
syncDesignWidth();
|
|
6388
|
+
|
|
6389
|
+
const observed = containerRef.current;
|
|
6390
|
+
if (!observed) {
|
|
6391
|
+
return;
|
|
6392
|
+
}
|
|
6393
|
+
|
|
6394
|
+
const observer = new ResizeObserver(syncDesignWidth);
|
|
6395
|
+
observer.observe(observed);
|
|
6396
|
+
|
|
6397
|
+
let pageEl: HTMLElement | null = observed;
|
|
6398
|
+
while (pageEl && !pageEl.style.getPropertyValue('--cntrl-article-width')) {
|
|
6399
|
+
pageEl = pageEl.parentElement;
|
|
6400
|
+
}
|
|
6401
|
+
if (pageEl) {
|
|
6402
|
+
observer.observe(pageEl);
|
|
6403
|
+
}
|
|
6404
|
+
|
|
6405
|
+
return () => observer.disconnect();
|
|
6406
|
+
}, [isEditor, layoutId]);
|
|
6407
|
+
|
|
6408
|
+
useEffect(() => {
|
|
6409
|
+
setVisibleRowCount(undefined);
|
|
6410
|
+
}, [cut, showCut, content, entriesCount]);
|
|
6411
|
+
|
|
6412
|
+
const colorVars = buildColorVars(P, {
|
|
6413
|
+
textColor,
|
|
6414
|
+
backgroundColor,
|
|
6415
|
+
dividerColor,
|
|
6416
|
+
textHoverColor,
|
|
6417
|
+
backgroundHoverColor,
|
|
6418
|
+
dividerHoverColor
|
|
6419
|
+
}, COLOR_VAR_MAP, STATE_KEYS);
|
|
6420
|
+
|
|
6421
|
+
const stateClass = activeEvent && activeEvent !== 'default' ? \`\${P}-state-\${activeEvent}\` : '';
|
|
6422
|
+
const entryHoverClass =
|
|
6423
|
+
entryHoverEffect === 'Default'
|
|
6424
|
+
? \`\${P}-entry-hover-default\`
|
|
6425
|
+
: entryHoverEffect === 'Blinds'
|
|
6426
|
+
? \`\${P}-entry-hover-blinds\`
|
|
6427
|
+
: '';
|
|
6428
|
+
const wrapperStateClasses = \`\${entryHoverClass} \${stateClass}\`.trim();
|
|
6429
|
+
const showDividerTop = showVisibility?.[0] ?? false;
|
|
6430
|
+
const showDividerBottom = showVisibility?.[1] ?? false;
|
|
6431
|
+
|
|
6432
|
+
const prevSettingsRef = useRef(settings);
|
|
6433
|
+
const prevLayoutIdRef = useRef(layoutId);
|
|
6434
|
+
|
|
6435
|
+
useEffect(() => {
|
|
6436
|
+
if (!onUpdateSettings || !isEditor) {
|
|
6437
|
+
prevSettingsRef.current = settings;
|
|
6438
|
+
prevLayoutIdRef.current = layoutId;
|
|
6439
|
+
return;
|
|
6440
|
+
}
|
|
6441
|
+
|
|
6442
|
+
if (prevLayoutIdRef.current !== layoutId) {
|
|
6443
|
+
prevSettingsRef.current = settings;
|
|
6444
|
+
prevLayoutIdRef.current = layoutId;
|
|
6445
|
+
return;
|
|
6446
|
+
}
|
|
6447
|
+
|
|
6448
|
+
const prevSettings = prevSettingsRef.current;
|
|
6449
|
+
const updatedSettings = applyListSettingsChange(
|
|
6450
|
+
settings,
|
|
6451
|
+
prevSettings,
|
|
6452
|
+
{ designWidth },
|
|
6453
|
+
);
|
|
6454
|
+
|
|
6455
|
+
prevSettingsRef.current = settings;
|
|
6456
|
+
|
|
6457
|
+
if (updatedSettings === settings) {
|
|
6458
|
+
return;
|
|
6459
|
+
}
|
|
6460
|
+
|
|
6461
|
+
onUpdateSettings(updatedSettings);
|
|
6462
|
+
}, [settings, onUpdateSettings, isEditor, layoutId, designWidth]);
|
|
6463
|
+
|
|
6464
|
+
const columnWidthByKey = useMemo(
|
|
6465
|
+
() => getColumnWidthsFromSettings(settings),
|
|
6466
|
+
[
|
|
6467
|
+
settings.AColumnWidth,
|
|
6468
|
+
settings.BColumnWidth,
|
|
6469
|
+
settings.CColumnWidth,
|
|
6470
|
+
settings.DColumnWidth,
|
|
6471
|
+
settings.EColumnWidth,
|
|
6472
|
+
],
|
|
6473
|
+
);
|
|
6474
|
+
|
|
6475
|
+
const columnPaddingLeftByKey = useMemo(
|
|
6476
|
+
() => getNumericSettingValues(settings, COLUMN_PADDING_LEFT_KEYS),
|
|
6477
|
+
[
|
|
6478
|
+
settings.AColumnPaddingLeft,
|
|
6479
|
+
settings.BColumnPaddingLeft,
|
|
6480
|
+
settings.CColumnPaddingLeft,
|
|
6481
|
+
settings.DColumnPaddingLeft,
|
|
6482
|
+
settings.EColumnPaddingLeft,
|
|
6483
|
+
],
|
|
6484
|
+
);
|
|
6485
|
+
|
|
6486
|
+
const columnPaddingRightByKey = useMemo(
|
|
6487
|
+
() => getNumericSettingValues(settings, COLUMN_PADDING_RIGHT_KEYS),
|
|
6488
|
+
[
|
|
6489
|
+
settings.AColumnPaddingRight,
|
|
6490
|
+
settings.BColumnPaddingRight,
|
|
6491
|
+
settings.CColumnPaddingRight,
|
|
6492
|
+
settings.DColumnPaddingRight,
|
|
6493
|
+
settings.EColumnPaddingRight,
|
|
6494
|
+
],
|
|
6495
|
+
);
|
|
6496
|
+
|
|
6497
|
+
const columnPaddingBottomByKey = useMemo(
|
|
6498
|
+
() => getNumericSettingValues(settings, COLUMN_PADDING_BOTTOM_KEYS),
|
|
6499
|
+
[
|
|
6500
|
+
settings.AColumnPaddingBottom,
|
|
6501
|
+
settings.BColumnPaddingBottom,
|
|
6502
|
+
settings.CColumnPaddingBottom,
|
|
6503
|
+
settings.DColumnPaddingBottom,
|
|
6504
|
+
settings.EColumnPaddingBottom,
|
|
6505
|
+
],
|
|
6506
|
+
);
|
|
6507
|
+
|
|
6508
|
+
const columnContentOrder = useMemo((): typeof COLUMN_CONTENT_KEYS[number][] => {
|
|
6509
|
+
if (Array.isArray(columnsOrder) && columnsOrder.length > 0) {
|
|
6510
|
+
return columnsOrder as typeof COLUMN_CONTENT_KEYS[number][];
|
|
6511
|
+
}
|
|
6512
|
+
return [...COLUMN_CONTENT_KEYS];
|
|
6513
|
+
}, [columnsOrder]);
|
|
6514
|
+
|
|
6515
|
+
const listColumns = useMemo(
|
|
6516
|
+
() => buildListColumns(
|
|
6517
|
+
columnContentOrder,
|
|
6518
|
+
columns,
|
|
6519
|
+
columnWidthByKey,
|
|
6520
|
+
columnPaddingLeftByKey,
|
|
6521
|
+
columnPaddingRightByKey,
|
|
6522
|
+
columnPaddingBottomByKey,
|
|
6523
|
+
),
|
|
6524
|
+
[columnContentOrder, columns, columnWidthByKey, columnPaddingLeftByKey, columnPaddingRightByKey, columnPaddingBottomByKey],
|
|
6525
|
+
);
|
|
6526
|
+
|
|
6527
|
+
const resolvedContentWidth = getListEffectiveContentWidth(settings);
|
|
6528
|
+
|
|
6529
|
+
const storedColumnWidths = useMemo(
|
|
6530
|
+
() => COLUMN_WIDTH_KEYS.slice(0, columns).map((key) => columnWidthByKey[key]),
|
|
6531
|
+
[columns, columnWidthByKey],
|
|
6532
|
+
);
|
|
6533
|
+
|
|
6534
|
+
const resolvedColumnWidths = useMemo(
|
|
6535
|
+
() => resolveListColumnWidths(columns, resolvedContentWidth, columnWidthByKey),
|
|
6536
|
+
[columns, resolvedContentWidth, columnWidthByKey],
|
|
6537
|
+
);
|
|
6538
|
+
|
|
6539
|
+
const effectiveColumnWidths = useMemo(
|
|
6540
|
+
() => getEffectiveListColumnWidths(columns, resolvedContentWidth, columnWidthByKey),
|
|
6541
|
+
[columns, resolvedContentWidth, columnWidthByKey],
|
|
6542
|
+
);
|
|
6543
|
+
|
|
6544
|
+
const effectiveColumnPaddings = useMemo(
|
|
6545
|
+
() =>
|
|
6546
|
+
listColumns.map((col, index) =>
|
|
6547
|
+
resolveListColumnPadding(
|
|
6548
|
+
effectiveColumnWidths[index] ?? 0,
|
|
6549
|
+
col.paddingLeft,
|
|
6550
|
+
col.paddingRight,
|
|
6551
|
+
)),
|
|
6552
|
+
[listColumns, effectiveColumnWidths],
|
|
6553
|
+
);
|
|
6554
|
+
|
|
6555
|
+
const allRows: ListItemRow[] = useMemo(() => {
|
|
6556
|
+
const resEntriesCount = entriesCount === 0 ? Infinity : entriesCount;
|
|
6557
|
+
const items = (content ?? []).slice(0, resEntriesCount);
|
|
6558
|
+
|
|
6559
|
+
return items.map((item, index) => ({
|
|
6560
|
+
id: index,
|
|
6561
|
+
cells: Object.fromEntries(
|
|
6562
|
+
COLUMN_CONTENT_KEYS.map((key) => [key, item[key] ?? ''])
|
|
6563
|
+
),
|
|
6564
|
+
image: item.image,
|
|
6565
|
+
link: item.link,
|
|
6566
|
+
}));
|
|
6567
|
+
}, [content, entriesCount]);
|
|
6568
|
+
|
|
6569
|
+
const effectiveVisibleCount = cutEnabled
|
|
6570
|
+
? (visibleRowCount ?? cut)
|
|
6571
|
+
: allRows.length;
|
|
6572
|
+
|
|
6573
|
+
const visibleRows = useMemo(() => {
|
|
6574
|
+
if (cutEnabled) {
|
|
6575
|
+
return allRows.slice(0, effectiveVisibleCount);
|
|
6576
|
+
}
|
|
6577
|
+
return allRows;
|
|
6578
|
+
}, [allRows, cutEnabled, effectiveVisibleCount]);
|
|
6579
|
+
|
|
6580
|
+
const showCutLabel = cutEnabled && effectiveVisibleCount < allRows.length;
|
|
6581
|
+
|
|
6582
|
+
const hasBetweenItemDividers = visibleRows.length > 1 || showCutLabel;
|
|
6583
|
+
const dividerClassNames = [
|
|
6584
|
+
showDividerTop ? \`\${P}-divider-top\` : '',
|
|
6585
|
+
showDividerBottom || hasBetweenItemDividers ? \`\${P}-divider-bottom\` : '',
|
|
6586
|
+
].filter(Boolean).join(' ');
|
|
6587
|
+
|
|
6588
|
+
const handleShowMore = () => {
|
|
6589
|
+
const currentVisible = visibleRowCount ?? cut;
|
|
6590
|
+
if (!showCut) {
|
|
6591
|
+
setVisibleRowCount(allRows.length);
|
|
6592
|
+
return;
|
|
6593
|
+
}
|
|
6594
|
+
setVisibleRowCount(Math.min(currentVisible + showCut, allRows.length));
|
|
6595
|
+
};
|
|
6596
|
+
|
|
6597
|
+
const scaled = (v: number) => scalingValue(v, isEditor ?? false);
|
|
6598
|
+
const resolvedRowPaddingTop = isVerticalLayout
|
|
6599
|
+
? (rowPaddingTopB ?? 0)
|
|
6600
|
+
: (rowPaddingTop ?? 0);
|
|
6601
|
+
const resolvedRowPaddingBottom = rowPaddingBottom ?? 0;
|
|
6602
|
+
const resolvedCellMinHeight = cellMinHeight ?? 0;
|
|
6603
|
+
const rowPaddingTopControlKey = isVerticalLayout ? 'rowPaddingTopB' : 'rowPaddingTop';
|
|
6604
|
+
const firstColumn = listColumns[0];
|
|
6605
|
+
const lastColumn = listColumns[listColumns.length - 1];
|
|
6606
|
+
const firstColumnEffectivePadding = effectiveColumnPaddings[0];
|
|
6607
|
+
const lastColumnEffectivePadding = effectiveColumnPaddings[effectiveColumnPaddings.length - 1];
|
|
6608
|
+
const firstColumnPaddingLeftWidth = firstColumn && firstColumnEffectivePadding
|
|
6609
|
+
? Math.max(firstColumnEffectivePadding.paddingLeft, COL_PADDING_HANDLE_WIDTH)
|
|
6610
|
+
: 0;
|
|
6611
|
+
const lastColumnPaddingRightWidth = lastColumn && lastColumnEffectivePadding
|
|
6612
|
+
? Math.max(lastColumnEffectivePadding.paddingRight, COL_PADDING_HANDLE_WIDTH)
|
|
6613
|
+
: 0;
|
|
6614
|
+
const columnsRightEdge = resolvedContentWidth;
|
|
6615
|
+
|
|
6616
|
+
const getHoverImagePosition = (event: React.MouseEvent) => {
|
|
6617
|
+
const container = containerRef.current;
|
|
6618
|
+
if (!container) {
|
|
6619
|
+
return { x: 0, y: 0 };
|
|
6620
|
+
}
|
|
6621
|
+
|
|
6622
|
+
const rect = container.getBoundingClientRect();
|
|
6623
|
+
return {
|
|
6624
|
+
x: event.clientX - rect.left + HOVER_IMAGE_CURSOR_OFFSET,
|
|
6625
|
+
y: event.clientY - rect.top + HOVER_IMAGE_CURSOR_OFFSET,
|
|
6626
|
+
};
|
|
6627
|
+
};
|
|
6628
|
+
|
|
6629
|
+
const handleRowMouseEnter = (row: ListItemRow, event: React.MouseEvent) => {
|
|
6630
|
+
if (!showHoverImage) return;
|
|
6631
|
+
|
|
6632
|
+
const image = row.image;
|
|
6633
|
+
if (!image?.url) {
|
|
6634
|
+
setHoverImage(null);
|
|
6635
|
+
return;
|
|
6636
|
+
}
|
|
6637
|
+
|
|
6638
|
+
const { x, y } = getHoverImagePosition(event);
|
|
6639
|
+
const minWidth = imageSize?.min ?? 80;
|
|
6640
|
+
const maxWidth = imageSize?.max ?? 320;
|
|
6641
|
+
const widthPx = hoverImage?.rowId === row.id
|
|
6642
|
+
? hoverImage.widthPx
|
|
6643
|
+
: randomBetween(minWidth, maxWidth);
|
|
6644
|
+
|
|
6645
|
+
setHoverImage({
|
|
6646
|
+
rowId: row.id,
|
|
6647
|
+
url: image.url,
|
|
6648
|
+
objectFit: image.objectFit ?? 'cover',
|
|
6649
|
+
widthPx,
|
|
6650
|
+
x,
|
|
6651
|
+
y,
|
|
6652
|
+
});
|
|
6653
|
+
};
|
|
6654
|
+
|
|
6655
|
+
const handleWrapperMouseMove = (event: React.MouseEvent) => {
|
|
6656
|
+
if (!showHoverImage || !hoverImage) return;
|
|
6657
|
+
|
|
6658
|
+
const { x, y } = getHoverImagePosition(event);
|
|
6659
|
+
setHoverImage((prev) => {
|
|
6660
|
+
if (!prev) return prev;
|
|
6661
|
+
if (prev.x === x && prev.y === y) return prev;
|
|
6662
|
+
return { ...prev, x, y };
|
|
6663
|
+
});
|
|
6664
|
+
};
|
|
6665
|
+
|
|
6666
|
+
const handleWrapperMouseLeave = () => {
|
|
6667
|
+
setHoverImage(null);
|
|
6668
|
+
};
|
|
6669
|
+
|
|
6670
|
+
const hasBaselineColumn = useMemo(
|
|
6671
|
+
() =>
|
|
6672
|
+
!isVerticalLayout &&
|
|
6673
|
+
COLUMN_TEXT_PREFIXES.some((prefix) => {
|
|
6674
|
+
const columnLetter = prefix.charAt(0);
|
|
6675
|
+
const valign = settings[\`\${prefix}VerticalAlign\` as ListColumnVerticalAlignKey];
|
|
6676
|
+
return isActiveBaselineVAlign(valign, settings, columnLetter);
|
|
6677
|
+
}),
|
|
6678
|
+
[
|
|
6679
|
+
isVerticalLayout,
|
|
6680
|
+
settings,
|
|
6681
|
+
settings.AColumnVerticalAlign,
|
|
6682
|
+
settings.BColumnVerticalAlign,
|
|
6683
|
+
settings.CColumnVerticalAlign,
|
|
6684
|
+
settings.DColumnVerticalAlign,
|
|
6685
|
+
settings.EColumnVerticalAlign,
|
|
6686
|
+
],
|
|
6687
|
+
);
|
|
6688
|
+
|
|
6689
|
+
useLayoutEffect(() => {
|
|
6690
|
+
const container = containerRef.current;
|
|
6691
|
+
if (!container) return;
|
|
6692
|
+
|
|
6693
|
+
const clearBaselineStyles = () => {
|
|
6694
|
+
container.querySelectorAll<HTMLElement>('[data-list-col]').forEach((el) => {
|
|
6695
|
+
el.style.transform = '';
|
|
6696
|
+
const listCol = el.querySelector<HTMLElement>(\`.\${P}-list-col\`);
|
|
6697
|
+
if (listCol) {
|
|
6698
|
+
listCol.style.minHeight = '';
|
|
6699
|
+
listCol.style.height = '';
|
|
6700
|
+
}
|
|
6701
|
+
const title = el.querySelector<HTMLElement>(\`.\${P}-list-col-title\`);
|
|
6702
|
+
if (title) {
|
|
6703
|
+
title.style.transform = '';
|
|
6704
|
+
}
|
|
6705
|
+
});
|
|
6706
|
+
};
|
|
6707
|
+
|
|
6708
|
+
if (isVerticalLayout || !hasBaselineColumn) {
|
|
6709
|
+
clearBaselineStyles();
|
|
6710
|
+
return;
|
|
6711
|
+
}
|
|
6712
|
+
|
|
6713
|
+
const applyBaselines = () => {
|
|
6714
|
+
container.querySelectorAll<HTMLElement>('[data-list-row]').forEach((rowEl) => {
|
|
6715
|
+
const cols = Array.from(rowEl.querySelectorAll<HTMLElement>('[data-list-col]'));
|
|
6716
|
+
cols.forEach((el) => {
|
|
6717
|
+
el.style.transform = '';
|
|
6718
|
+
const listCol = el.querySelector<HTMLElement>(\`.\${P}-list-col\`);
|
|
6719
|
+
if (listCol) {
|
|
6720
|
+
listCol.style.minHeight = '';
|
|
6721
|
+
listCol.style.height = '';
|
|
6722
|
+
}
|
|
6723
|
+
const title = el.querySelector<HTMLElement>(\`.\${P}-list-col-title\`);
|
|
6724
|
+
if (title) {
|
|
6725
|
+
title.style.transform = '';
|
|
6726
|
+
}
|
|
6727
|
+
});
|
|
6728
|
+
|
|
6729
|
+
syncRowListColHeights(rowEl, cols, \`\${P}-list-col\`);
|
|
6730
|
+
void rowEl.offsetHeight;
|
|
6731
|
+
const rowTop = rowEl.getBoundingClientRect().top;
|
|
6732
|
+
|
|
6733
|
+
type ColInfo = {
|
|
6734
|
+
el: HTMLElement;
|
|
6735
|
+
titleEl: HTMLElement | null;
|
|
6736
|
+
letter: string;
|
|
6737
|
+
kind: string;
|
|
6738
|
+
anchor: string | null;
|
|
6739
|
+
};
|
|
6740
|
+
|
|
6741
|
+
const probeClassName = \`\${P}-baseline-probe\`;
|
|
6742
|
+
const byLetter = new Map<string, ColInfo>();
|
|
6743
|
+
const infos: ColInfo[] = cols.map((el) => {
|
|
6744
|
+
const titleEl = el.querySelector<HTMLElement>(\`.\${P}-list-col-title\`);
|
|
6745
|
+
const info: ColInfo = {
|
|
6746
|
+
el,
|
|
6747
|
+
titleEl,
|
|
6748
|
+
letter: el.getAttribute('data-col-letter') ?? '',
|
|
6749
|
+
kind: el.getAttribute('data-valign') ?? 'top',
|
|
6750
|
+
anchor: el.getAttribute('data-valign-anchor'),
|
|
6751
|
+
};
|
|
6752
|
+
byLetter.set(info.letter, info);
|
|
6753
|
+
return info;
|
|
6754
|
+
});
|
|
6755
|
+
|
|
6756
|
+
const finalBaseline = new Map<string, number>();
|
|
6757
|
+
const resolve = (info: ColInfo, stack: Set<string>): number => {
|
|
6758
|
+
const cached = finalBaseline.get(info.letter);
|
|
6759
|
+
if (cached !== undefined) return cached;
|
|
6760
|
+
|
|
6761
|
+
const anchor = info.anchor ? byLetter.get(info.anchor) : undefined;
|
|
6762
|
+
if (info.kind !== 'baseline' || !anchor || stack.has(info.letter)) {
|
|
6763
|
+
const baseline = measureColumnFirstLineBaselineOffset(
|
|
6764
|
+
info,
|
|
6765
|
+
rowTop,
|
|
6766
|
+
\`\${P}-list-col\`,
|
|
6767
|
+
probeClassName,
|
|
6768
|
+
);
|
|
6769
|
+
finalBaseline.set(info.letter, baseline);
|
|
6770
|
+
return baseline;
|
|
6771
|
+
}
|
|
6772
|
+
|
|
6773
|
+
stack.add(info.letter);
|
|
6774
|
+
const anchorBaseline = resolve(anchor, stack);
|
|
6775
|
+
stack.delete(info.letter);
|
|
6776
|
+
|
|
6777
|
+
const followerNatural = measureColumnFirstLineBaselineOffset(
|
|
6778
|
+
info,
|
|
6779
|
+
rowTop,
|
|
6780
|
+
\`\${P}-list-col\`,
|
|
6781
|
+
probeClassName,
|
|
6782
|
+
);
|
|
6783
|
+
const shift = anchorBaseline - followerNatural;
|
|
6784
|
+
applyBaselineTitleShift(info.titleEl, shift);
|
|
6785
|
+
|
|
6786
|
+
const result = measureColumnFirstLineBaselineOffset(
|
|
6787
|
+
info,
|
|
6788
|
+
rowTop,
|
|
6789
|
+
\`\${P}-list-col\`,
|
|
6790
|
+
probeClassName,
|
|
6791
|
+
);
|
|
6792
|
+
finalBaseline.set(info.letter, result);
|
|
6793
|
+
return result;
|
|
6794
|
+
};
|
|
6795
|
+
|
|
6796
|
+
infos.forEach((info) => resolve(info, new Set<string>()));
|
|
6797
|
+
});
|
|
6798
|
+
};
|
|
6799
|
+
|
|
6800
|
+
applyBaselines();
|
|
6801
|
+
|
|
6802
|
+
const observer = new ResizeObserver(() => applyBaselines());
|
|
6803
|
+
observer.observe(container);
|
|
6804
|
+
|
|
6805
|
+
let cancelled = false;
|
|
6806
|
+
if (typeof document !== 'undefined' && document.fonts?.ready) {
|
|
6807
|
+
document.fonts.ready.then(() => {
|
|
6808
|
+
if (!cancelled) applyBaselines();
|
|
6809
|
+
});
|
|
6810
|
+
}
|
|
6811
|
+
|
|
6812
|
+
return () => {
|
|
6813
|
+
cancelled = true;
|
|
6814
|
+
observer.disconnect();
|
|
6815
|
+
clearBaselineStyles();
|
|
6816
|
+
};
|
|
6817
|
+
}, [
|
|
6818
|
+
hasBaselineColumn,
|
|
6819
|
+
isVerticalLayout,
|
|
6820
|
+
settings,
|
|
6821
|
+
content,
|
|
6822
|
+
designWidth,
|
|
6823
|
+
visibleRows,
|
|
6824
|
+
effectiveColumnWidths,
|
|
6825
|
+
]);
|
|
6826
|
+
|
|
6827
|
+
return (
|
|
6828
|
+
<>
|
|
6829
|
+
<style dangerouslySetInnerHTML={{ __html: getCSS(P) }} />
|
|
6830
|
+
<div style={colorVars}>
|
|
6831
|
+
<div
|
|
6832
|
+
ref={containerRef}
|
|
6833
|
+
className={\`\${P}-wrapper \${wrapperStateClasses}\${dividerClassNames ? \` \${dividerClassNames}\` : ''}\${isVerticalLayout ? \` \${P}-type-b\` : ''}\`.trim()}
|
|
6834
|
+
style={{
|
|
6835
|
+
width: scalingValue(wrapperWidth ?? 0, isEditor),
|
|
6836
|
+
}}
|
|
6837
|
+
onMouseMove={showHoverImage ? handleWrapperMouseMove : undefined}
|
|
6838
|
+
onMouseLeave={showHoverImage ? handleWrapperMouseLeave : undefined}
|
|
6839
|
+
>
|
|
6840
|
+
<div style={{ width: '100%' }}>
|
|
6841
|
+
{visibleRows.map((row, rowIdx) => {
|
|
6842
|
+
const hasLink = (row.link?.length ?? 0) > 0;
|
|
6843
|
+
const RowElement = hasLink ? 'a' : 'div';
|
|
6844
|
+
const rowStyle = getEntryDividerWidths(
|
|
6845
|
+
rowIdx,
|
|
6846
|
+
visibleRows.length,
|
|
6847
|
+
showDividerTop,
|
|
6848
|
+
showDividerBottom,
|
|
6849
|
+
showCutLabel,
|
|
6850
|
+
dividerWidth ?? 0,
|
|
6851
|
+
isEditor ?? false,
|
|
6852
|
+
);
|
|
6853
|
+
|
|
6854
|
+
return (
|
|
6855
|
+
<RowElement
|
|
6856
|
+
key={row.id}
|
|
6857
|
+
className={\`\${P}-list-item\${hasLink ? \` \${P}-list-item-has-link\` : ''}\`}
|
|
6858
|
+
{...(hasLink ? { href: row.link, target: '_blank' } : {})}
|
|
6859
|
+
style={rowStyle}
|
|
6860
|
+
onMouseEnter={showHoverImage ? (event) => handleRowMouseEnter(row, event) : undefined}
|
|
6861
|
+
>
|
|
6862
|
+
{(resolvedRowPaddingTop > 0 || showControls) && (
|
|
6863
|
+
<div
|
|
6864
|
+
{...(showControls ? {
|
|
6865
|
+
'data-controls': rowPaddingTopControlKey,
|
|
6866
|
+
'data-controls-axis': 'y',
|
|
6867
|
+
'data-controls-min': '0',
|
|
6868
|
+
} : {})}
|
|
6869
|
+
className={\`\${P}-row-padding-handle\`}
|
|
6870
|
+
style={{ height: scaled(resolvedRowPaddingTop) }}
|
|
6871
|
+
/>
|
|
6872
|
+
)}
|
|
6873
|
+
<div
|
|
6874
|
+
className={\`\${P}-list-cols-row\${isVerticalLayout ? '' : \` \${P}-list-cols-row-h\`}\`}
|
|
6875
|
+
{...(isVerticalLayout ? {} : { 'data-list-row': '' })}
|
|
6876
|
+
style={isVerticalLayout ? undefined : { minHeight: scaled(resolvedCellMinHeight) }}
|
|
6877
|
+
>
|
|
6878
|
+
{listColumns.map((col, colIndex) => {
|
|
6879
|
+
const isLastColumn = colIndex === listColumns.length - 1;
|
|
6880
|
+
const effectivePadding = effectiveColumnPaddings[colIndex];
|
|
6881
|
+
const columnPaddingBottom = col.paddingBottom;
|
|
6882
|
+
const hasColumnText = hasListColumnText(row.cells[col.key]);
|
|
6883
|
+
const showColumnPaddingBottom = isVerticalLayout
|
|
6884
|
+
&& hasColumnText
|
|
6885
|
+
&& (columnPaddingBottom > 0 || showControls);
|
|
6886
|
+
const columnSizeStyle = isVerticalLayout
|
|
6887
|
+
? { minHeight: scaled(resolvedCellMinHeight) }
|
|
6888
|
+
: (isLastColumn ? {} : { width: scaled(effectiveColumnWidths[colIndex]) });
|
|
6889
|
+
const columnPaddingStyle = isVerticalLayout
|
|
6890
|
+
? {
|
|
6891
|
+
paddingLeft: scaled(effectiveTextPaddingLR),
|
|
6892
|
+
paddingRight: scaled(effectiveTextPaddingLR),
|
|
6893
|
+
}
|
|
6894
|
+
: {
|
|
6895
|
+
paddingLeft: scaled(effectivePadding.paddingLeft),
|
|
6896
|
+
paddingRight: scaled(effectivePadding.paddingRight),
|
|
6897
|
+
};
|
|
6898
|
+
const columnLetter = col.textPrefix.charAt(0);
|
|
6899
|
+
const vAlign = isVerticalLayout
|
|
6900
|
+
? { kind: 'top' as const }
|
|
6901
|
+
: resolveColumnVerticalAlign(
|
|
6902
|
+
settings[\`\${col.textPrefix}VerticalAlign\` as ListColumnVerticalAlignKey],
|
|
6903
|
+
settings,
|
|
6904
|
+
columnLetter,
|
|
6905
|
+
);
|
|
6906
|
+
|
|
6907
|
+
return (
|
|
6908
|
+
<div
|
|
6909
|
+
key={col.key}
|
|
6910
|
+
{...(isVerticalLayout
|
|
6911
|
+
? {}
|
|
6912
|
+
: {
|
|
6913
|
+
'data-list-col': '',
|
|
6914
|
+
'data-col-letter': columnLetter,
|
|
6915
|
+
'data-valign': vAlign.kind,
|
|
6916
|
+
...(vAlign.kind === 'baseline'
|
|
6917
|
+
? { 'data-valign-anchor': vAlign.anchorLetter }
|
|
6918
|
+
: {}),
|
|
6919
|
+
})}
|
|
6920
|
+
>
|
|
6921
|
+
<div
|
|
6922
|
+
className={\`\${P}-list-col\${isLastColumn ? \` \${P}-list-col-last\` : ''}\`}
|
|
6923
|
+
style={{
|
|
6924
|
+
...columnPaddingStyle,
|
|
6925
|
+
...columnSizeStyle,
|
|
6926
|
+
}}
|
|
6927
|
+
data-test={col.width}
|
|
6928
|
+
>
|
|
6929
|
+
<span
|
|
6930
|
+
className={getListColumnTitleClassName(
|
|
6931
|
+
settings,
|
|
6932
|
+
col.textPrefix,
|
|
6933
|
+
\`\${P}-list-col-title\`,
|
|
6934
|
+
\`\${P}-text-tight-leading\`,
|
|
6935
|
+
)}
|
|
6936
|
+
style={{
|
|
6937
|
+
...listColumnTextFieldsToCss(resolveListColumnTextFields(settings, col.textPrefix), isEditor),
|
|
6938
|
+
...getListColumnTitleVars(settings, col.textPrefix, P, isEditor),
|
|
6939
|
+
...(!isVerticalLayout ? vAlignToTitleStyle(vAlign.kind) : {}),
|
|
6940
|
+
}}
|
|
6941
|
+
>
|
|
6942
|
+
{row.cells[col.key] ?? null}
|
|
6943
|
+
</span>
|
|
6944
|
+
</div>
|
|
6945
|
+
{showColumnPaddingBottom && (
|
|
6946
|
+
<div
|
|
6947
|
+
{...(showControls ? {
|
|
6948
|
+
'data-controls': col.paddingBottomKey,
|
|
6949
|
+
'data-controls-axis': 'y',
|
|
6950
|
+
'data-controls-min': '0',
|
|
6951
|
+
} : {})}
|
|
6952
|
+
className={\`\${P}-row-padding-handle\`}
|
|
6953
|
+
style={{ height: scaled(columnPaddingBottom) }}
|
|
6954
|
+
/>
|
|
6955
|
+
)}
|
|
6956
|
+
</div>
|
|
6957
|
+
);
|
|
6958
|
+
})}
|
|
6959
|
+
</div>
|
|
6960
|
+
{!isVerticalLayout && (resolvedRowPaddingBottom > 0 || showControls) && (
|
|
6961
|
+
<div
|
|
6962
|
+
{...(showControls ? {
|
|
6963
|
+
'data-controls': 'rowPaddingBottom',
|
|
6964
|
+
'data-controls-axis': 'y',
|
|
6965
|
+
'data-controls-min': '0',
|
|
6966
|
+
} : {})}
|
|
6967
|
+
className={\`\${P}-row-padding-handle\`}
|
|
6968
|
+
style={{ height: scaled(resolvedRowPaddingBottom) }}
|
|
6969
|
+
/>
|
|
6970
|
+
)}
|
|
6971
|
+
</RowElement>
|
|
6972
|
+
);
|
|
6973
|
+
})}
|
|
6974
|
+
{showCutLabel && (
|
|
6975
|
+
<button
|
|
6976
|
+
type="button"
|
|
6977
|
+
className={\`\${P}-cut-item\`}
|
|
6978
|
+
style={{
|
|
6979
|
+
minHeight: scaled(cutCellMinHeight ?? 0),
|
|
6980
|
+
...getCutItemDividerWidths(
|
|
6981
|
+
showDividerBottom,
|
|
6982
|
+
dividerWidth ?? 0,
|
|
6983
|
+
isEditor ?? false,
|
|
6984
|
+
),
|
|
6985
|
+
}}
|
|
6986
|
+
onClick={handleShowMore}
|
|
6987
|
+
>
|
|
6988
|
+
<div
|
|
6989
|
+
className={\`\${P}-list-cols-row\`}
|
|
6990
|
+
style={
|
|
6991
|
+
isVerticalLayout
|
|
6992
|
+
? {
|
|
6993
|
+
paddingLeft: scaled(effectiveTextPaddingLR),
|
|
6994
|
+
paddingRight: scaled(effectiveTextPaddingLR),
|
|
6995
|
+
}
|
|
6996
|
+
: { justifyContent: 'center' }
|
|
6997
|
+
}
|
|
6998
|
+
>
|
|
6999
|
+
<span
|
|
7000
|
+
className={getListColumnTitleClassName(
|
|
7001
|
+
settings,
|
|
7002
|
+
CUT_LABEL_TEXT_PREFIX,
|
|
7003
|
+
\`\${P}-cut-label\`,
|
|
7004
|
+
\`\${P}-text-tight-leading\`,
|
|
7005
|
+
)}
|
|
7006
|
+
style={{
|
|
7007
|
+
...listColumnTextFieldsToCss(resolveListColumnTextFields(settings, CUT_LABEL_TEXT_PREFIX), isEditor),
|
|
7008
|
+
...getListColumnTitleVars(settings, CUT_LABEL_TEXT_PREFIX, P, isEditor),
|
|
7009
|
+
}}
|
|
7010
|
+
>
|
|
7011
|
+
{cutLabel}
|
|
7012
|
+
</span>
|
|
7013
|
+
</div>
|
|
7014
|
+
</button>
|
|
7015
|
+
)}
|
|
7016
|
+
</div>
|
|
7017
|
+
{showControls && !isVerticalLayout && firstColumn && lastColumn && (
|
|
7018
|
+
<div key="column-edge-padding-handles" style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
|
|
7019
|
+
<div
|
|
7020
|
+
data-controls={firstColumn.paddingLeftKey}
|
|
7021
|
+
data-controls-axis="x"
|
|
7022
|
+
data-controls-variant="column-padding"
|
|
7023
|
+
data-controls-min="0"
|
|
7024
|
+
data-controls-max-fraction={String(
|
|
7025
|
+
effectiveColumnWidths[0] - (firstColumnEffectivePadding?.paddingRight ?? 0),
|
|
7026
|
+
)}
|
|
7027
|
+
data-controls-static-handle=""
|
|
7028
|
+
className={\`\${P}-padding-control-handle\`}
|
|
7029
|
+
style={{
|
|
7030
|
+
position: 'absolute',
|
|
7031
|
+
top: 0,
|
|
7032
|
+
left: 0,
|
|
7033
|
+
width: scaled(firstColumnPaddingLeftWidth),
|
|
7034
|
+
height: '100%',
|
|
7035
|
+
pointerEvents: 'auto',
|
|
7036
|
+
zIndex: 2,
|
|
7037
|
+
}}
|
|
7038
|
+
/>
|
|
7039
|
+
<div
|
|
7040
|
+
data-controls={lastColumn.paddingRightKey}
|
|
7041
|
+
data-controls-axis="x"
|
|
7042
|
+
data-controls-variant="column-padding"
|
|
7043
|
+
data-controls-reverse=""
|
|
7044
|
+
data-controls-min="0"
|
|
7045
|
+
data-controls-max-fraction={String(
|
|
7046
|
+
effectiveColumnWidths[listColumns.length - 1]
|
|
7047
|
+
- (lastColumnEffectivePadding?.paddingLeft ?? 0),
|
|
7048
|
+
)}
|
|
7049
|
+
data-controls-static-handle=""
|
|
7050
|
+
className={\`\${P}-padding-control-handle\`}
|
|
7051
|
+
style={{
|
|
7052
|
+
position: 'absolute',
|
|
7053
|
+
top: 0,
|
|
7054
|
+
left: scaled(columnsRightEdge - lastColumnPaddingRightWidth),
|
|
7055
|
+
width: scaled(lastColumnPaddingRightWidth),
|
|
7056
|
+
height: '100%',
|
|
7057
|
+
pointerEvents: 'auto',
|
|
7058
|
+
zIndex: 2,
|
|
7059
|
+
}}
|
|
7060
|
+
/>
|
|
7061
|
+
</div>
|
|
7062
|
+
)}
|
|
7063
|
+
{showControls && !isVerticalLayout && listColumns.slice(0, -1).map((col, colIndex) => {
|
|
7064
|
+
const nextCol = listColumns[colIndex + 1];
|
|
7065
|
+
const maxColumnWidth = getColumnMaxWidth(
|
|
7066
|
+
colIndex,
|
|
7067
|
+
resolvedColumnWidths,
|
|
7068
|
+
storedColumnWidths,
|
|
7069
|
+
resolvedContentWidth,
|
|
7070
|
+
);
|
|
7071
|
+
const boundaryOffset = resolvedColumnWidths.slice(0, colIndex + 1).reduce((sum, width) => sum + width, 0);
|
|
7072
|
+
const colEffectivePadding = effectiveColumnPaddings[colIndex];
|
|
7073
|
+
const nextColEffectivePadding = effectiveColumnPaddings[colIndex + 1];
|
|
7074
|
+
const paddingRightWidth = Math.max(
|
|
7075
|
+
colEffectivePadding.paddingRight,
|
|
7076
|
+
COL_PADDING_HANDLE_WIDTH,
|
|
7077
|
+
);
|
|
7078
|
+
const paddingLeftWidth = Math.max(
|
|
7079
|
+
nextColEffectivePadding.paddingLeft,
|
|
7080
|
+
COL_PADDING_HANDLE_WIDTH,
|
|
7081
|
+
);
|
|
7082
|
+
const columnWidthHandleOffset = boundaryOffset - COL_RESIZE_HANDLE_WIDTH / 2;
|
|
7083
|
+
|
|
7084
|
+
return (
|
|
7085
|
+
<div key={\`\${col.widthKey}-junction\`} style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
|
|
7086
|
+
<div
|
|
7087
|
+
data-controls={col.paddingRightKey}
|
|
7088
|
+
data-controls-axis="x"
|
|
7089
|
+
data-controls-variant="column-padding"
|
|
7090
|
+
data-controls-reverse=""
|
|
7091
|
+
data-controls-min="0"
|
|
7092
|
+
data-controls-max-fraction={String(
|
|
7093
|
+
effectiveColumnWidths[colIndex] - colEffectivePadding.paddingLeft,
|
|
7094
|
+
)}
|
|
7095
|
+
data-controls-static-handle=""
|
|
7096
|
+
className={\`\${P}-padding-control-handle\`}
|
|
7097
|
+
style={{
|
|
7098
|
+
position: 'absolute',
|
|
7099
|
+
top: 0,
|
|
7100
|
+
left: scaled(boundaryOffset - paddingRightWidth),
|
|
7101
|
+
width: scaled(paddingRightWidth),
|
|
7102
|
+
height: '100%',
|
|
7103
|
+
pointerEvents: 'auto',
|
|
7104
|
+
zIndex: 2,
|
|
7105
|
+
}}
|
|
7106
|
+
/>
|
|
7107
|
+
<div
|
|
7108
|
+
data-controls={col.widthKey}
|
|
7109
|
+
data-controls-axis="x"
|
|
7110
|
+
data-controls-min={String(MIN_COLUMN_WIDTH_PX)}
|
|
7111
|
+
data-controls-max-fraction={String(maxColumnWidth)}
|
|
7112
|
+
data-controls-variant="column-width"
|
|
7113
|
+
className={\`\${P}-col-resize-handle\`}
|
|
7114
|
+
style={{
|
|
7115
|
+
position: 'absolute',
|
|
7116
|
+
top: '0px',
|
|
7117
|
+
left: scaled(columnWidthHandleOffset),
|
|
7118
|
+
width: scaled(COL_RESIZE_HANDLE_WIDTH),
|
|
7119
|
+
height: 'calc(100%)',
|
|
7120
|
+
pointerEvents: 'auto',
|
|
7121
|
+
zIndex: 4,
|
|
7122
|
+
}}
|
|
7123
|
+
/>
|
|
7124
|
+
<div
|
|
7125
|
+
data-controls={nextCol.paddingLeftKey}
|
|
7126
|
+
data-controls-axis="x"
|
|
7127
|
+
data-controls-variant="column-padding"
|
|
7128
|
+
data-controls-min="0"
|
|
7129
|
+
data-controls-max-fraction={String(
|
|
7130
|
+
effectiveColumnWidths[colIndex + 1] - nextColEffectivePadding.paddingRight,
|
|
7131
|
+
)}
|
|
7132
|
+
data-controls-static-handle=""
|
|
7133
|
+
className={\`\${P}-padding-control-handle\`}
|
|
7134
|
+
style={{
|
|
7135
|
+
position: 'absolute',
|
|
7136
|
+
top: 0,
|
|
7137
|
+
left: scaled(boundaryOffset),
|
|
7138
|
+
width: scaled(paddingLeftWidth),
|
|
7139
|
+
height: '100%',
|
|
7140
|
+
pointerEvents: 'auto',
|
|
7141
|
+
zIndex: 2,
|
|
7142
|
+
}}
|
|
7143
|
+
/>
|
|
7144
|
+
</div>
|
|
7145
|
+
);
|
|
7146
|
+
})}
|
|
7147
|
+
{showControls && isVerticalLayout && (
|
|
7148
|
+
<div key="text-padding-lr-handles" style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
|
|
7149
|
+
<div
|
|
7150
|
+
data-controls="textPaddingLR"
|
|
7151
|
+
data-controls-paired=""
|
|
7152
|
+
data-controls-axis="x"
|
|
7153
|
+
data-controls-min="0"
|
|
7154
|
+
data-controls-max-fraction={String(textPaddingLRMaxFraction)}
|
|
7155
|
+
data-controls-static-handle=""
|
|
7156
|
+
className={\`\${P}-text-padding-lr-handle\`}
|
|
7157
|
+
style={{
|
|
7158
|
+
position: 'absolute',
|
|
7159
|
+
top: 0,
|
|
7160
|
+
left: 0,
|
|
7161
|
+
width: scaled(textPaddingLRHandleWidth),
|
|
7162
|
+
height: '100%',
|
|
7163
|
+
pointerEvents: 'auto',
|
|
7164
|
+
zIndex: 2,
|
|
7165
|
+
}}
|
|
7166
|
+
/>
|
|
7167
|
+
<div
|
|
7168
|
+
data-controls="textPaddingLR"
|
|
7169
|
+
data-controls-paired=""
|
|
7170
|
+
data-controls-axis="x"
|
|
7171
|
+
data-controls-reverse=""
|
|
7172
|
+
data-controls-min="0"
|
|
7173
|
+
data-controls-max-fraction={String(textPaddingLRMaxFraction)}
|
|
7174
|
+
data-controls-static-handle=""
|
|
7175
|
+
className={\`\${P}-text-padding-lr-handle\`}
|
|
7176
|
+
style={{
|
|
7177
|
+
position: 'absolute',
|
|
7178
|
+
top: 0,
|
|
7179
|
+
left: scaled(Math.max(textPaddingLRHandleWidth, resolvedContentWidth - textPaddingLRHandleWidth)),
|
|
7180
|
+
width: scaled(textPaddingLRHandleWidth),
|
|
7181
|
+
height: '100%',
|
|
7182
|
+
pointerEvents: 'auto',
|
|
7183
|
+
zIndex: 2,
|
|
7184
|
+
}}
|
|
7185
|
+
/>
|
|
7186
|
+
</div>
|
|
7187
|
+
)}
|
|
7188
|
+
{showHoverImage && hoverImage && (
|
|
7189
|
+
<img
|
|
7190
|
+
className={\`\${P}-hover-image\`}
|
|
7191
|
+
src={hoverImage.url}
|
|
7192
|
+
alt=""
|
|
7193
|
+
style={{
|
|
7194
|
+
width: sv(hoverImage.widthPx),
|
|
7195
|
+
objectFit: hoverImage.objectFit,
|
|
7196
|
+
left: hoverImage.x,
|
|
7197
|
+
top: hoverImage.y,
|
|
7198
|
+
}}
|
|
7199
|
+
/>
|
|
7200
|
+
)}
|
|
7201
|
+
</div>
|
|
7202
|
+
</div>
|
|
7203
|
+
</>
|
|
7204
|
+
);
|
|
7205
|
+
}
|
|
7206
7206
|
`,Bt=["A","B","C","D","E"],zo=[...Xc,"Baseline A","Baseline B","Baseline C","Baseline D","Baseline E"],Mt={fontSettings:{type:"object",display:{type:"font-settings-weight"},properties:{fontWeight:{type:"number"},fontStyle:{type:"string"}}},fontSize:{type:"number",display:{type:"font-size"}},lineHeight:{type:"number",display:{type:"line-height-input"}},letterSpacing:{type:"number",display:{type:"letter-spacing-input"}},wordSpacing:{type:"number",display:{type:"word-spacing-input"}},textAppearance:{type:"object",display:{type:"text-appearance"},properties:{textTransform:{type:"string",enum:["none","uppercase","lowercase","capitalize"]},textDecoration:{type:"string",enum:["none","underline"]},fontVariant:{type:"string",enum:["normal","small-caps"]}}}};function Td(e){return{type:"string",label:e,placeholder:"Add Title...",display:{type:"text-input"}}}function Hn(e){return{type:"number",scope:"layout",title:e,min:0,max:100,display:{type:"range-control"}}}function Ld(){return Object.fromEntries(Bt.map((e,t)=>{const n=Pt[t],r=`${e} column`;return[n,Td(r)]}))}function Ed(){const e={};for(const t of Bt)e[`${t}ColumnWidth`]=Hn(`${t} column width`),e[`${t}ColumnPaddingLeft`]=Hn(`${t} column padding left`),e[`${t}ColumnPaddingRight`]=Hn(`${t} column padding right`),e[`${t}ColumnPaddingBottom`]=Hn(`${t} column padding bottom`);return e}function jo(e={}){const t={columns:5,wrapperWidth:1,columnsOrder:[...Pt]};for(const n of Bt)t[`${n}ColumnWidth`]=.2,t[`${n}ColumnPaddingLeft`]=0,t[`${n}ColumnPaddingRight`]=0,t[`${n}ColumnPaddingBottom`]=0;return{...t,...e}}function _d(e){const t={};if(e!==vt){const n=e.charAt(0);t[`${e}VerticalAlign`]={type:"string",scope:"layout",title:"Vertical align",display:{type:"drop-down",enum:[...zo],filterBaselineByTopAnchor:!0,columnLetter:n},enum:[...zo]}}return t[we(e,"textFontFamily")]={type:"string",scope:"common",title:"Font family",display:{type:"font-family-select"}},t[we(e,"textFontSettings")]={...Mt.fontSettings,scope:"common",title:"",display:{type:"font-settings-weight"}},t[we(e,"textFontSize")]={...Mt.fontSize,scope:"layout",title:"Font Size",display:{type:"font-size"}},t[we(e,"textLineHeight")]={...Mt.lineHeight,scope:"layout",title:"Line Height",display:{type:"line-height-input"}},t[we(e,"textLetterSpacing")]={...Mt.letterSpacing,scope:"layout",title:"Letter Spacing",display:{type:"letter-spacing-input"}},t[we(e,"textWordSpacing")]={...Mt.wordSpacing,scope:"layout",title:"Word Spacing",display:{type:"word-spacing-input"}},t[we(e,"textTextAppearance")]={...Mt.textAppearance,scope:"layout",title:"Text Appearance",display:{type:"text-appearance"}},t}const Pd=Pn.reduce((e,t)=>({...e,..._d(t)}),{}),Ad=Pn.reduce((e,t)=>({...e,...t!==vt?{[`${t}VerticalAlign`]:"Top"}:{},[we(t,"textFontFamily")]:"Arial",[we(t,"textFontSettings")]:{fontWeight:400,fontStyle:"normal"},[we(t,"textLetterSpacing")]:0,[we(t,"textWordSpacing")]:0,[we(t,"textTextAppearance")]:{textTransform:"none",textDecoration:"none",fontVariant:"normal"}}),{});function Ko(e){const{textFontSize:t,textLineHeight:n}=e;return Pn.reduce((r,o)=>(t!==void 0&&(r[`${o}TextFontSize`]=t),n!==void 0&&(r[`${o}TextLineHeight`]=n),r),{})}const Rd={AColumn:"A column",BColumn:"B column",CColumn:"C column",DColumn:"D column",EColumn:"E column",cutLabel:"See all"},Id=Pn.map(e=>({type:"group",title:Rd[e],items:[we(e,"textFontFamily"),we(e,"textFontSettings"),{type:"row",items:[we(e,"textFontSize"),we(e,"textLineHeight"),we(e,"textLetterSpacing"),we(e,"textWordSpacing")]},we(e,"textTextAppearance"),...e!==vt?[`${e}VerticalAlign`]:[]]}));function Mi(e){return[we(e,"textFontFamily"),we(e,"textFontSettings"),we(e,"textFontSize"),we(e,"textLineHeight"),we(e,"textLetterSpacing"),we(e,"textWordSpacing"),we(e,"textTextAppearance"),...e!==vt?[`${e}VerticalAlign`]:[]]}function Wd(){const e=[];return eo.forEach((t,n)=>{const r=Pt[n],o=Mi(t);for(let s=1;s<Pt.length;s+=1){const i=[{name:"columns",value:s},...Array.from({length:s},(a,c)=>({name:`columnsOrder.${c}`,value:r,isNotEqual:!0}))];o.forEach(a=>{e.push({if:i,then:{name:`properties.${a}.display.visible`,value:!1}})})}}),e}const Fd=["textColor","backgroundColor","dividerColor","textHoverColor","backgroundHoverColor","dividerHoverColor"],kd=["cutLabel","cutCellMinHeight","showCut"],Md=Mi(vt),Nd=[...kd,...Md],Hd=[...Bt.flatMap(e=>[`${e}ColumnWidth`,`${e}ColumnPaddingLeft`,`${e}ColumnPaddingRight`]),"rowPaddingTop","rowPaddingBottom"];function Cr(e,t){const n=e?` ${e}`:"";return{AColumn:`AColumn${n}`,BColumnWidth:`BColumnWidth${n}`,CColumnWidth:`CColumnWidth${n}`,DColumnWidth:`DColumnWidth${n}`,EColumnWidth:`EColumnWidth${n}`,image:t,link:""}}const Od=[Cr("",{objectFit:"cover",url:"https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERQK9211QXBE9W284ZNKB8.png",name:"Slider-1.png"}),Cr("2",{objectFit:"cover",url:"https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERQMFT72JD18WKP0Q2DVAT.png",name:"Slider-2.png"}),Cr("3",{objectFit:"cover",url:"https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERQNEVRXPSRX5K1YTMJQY9.png",name:"Slider-3.png"})],Bd=[...Bt.flatMap(e=>[`${e}ColumnWidth`,`${e}ColumnPaddingLeft`,`${e}ColumnPaddingRight`,`${e}ColumnPaddingBottom`]),"columnsOrder"],Vd={type:"object",version:1,content:{type:"array",settings:{addItemWithoutImage:!0},display:{type:"array",ref:{columnsOrder:"settings.properties.columnsOrder",columnsCount:"settings.properties.columns"}},items:{type:"object",properties:{...Ld(),image:{type:"object",label:"Image",display:{isObjectFitEditable:!1,type:"media-input"},properties:{url:{type:"string"},name:{type:"string"},objectFit:{type:"string",enum:["cover","contain"]}},required:["url","name"]},link:{type:"string",label:"Link",placeholder:"Add link...",display:{type:"text-input"}}},required:["image"]},default:Od},settings:{sizing:"auto auto",properties:{type:{type:"string",scope:"layout",title:"",display:{type:"radio-group"},enum:["A","B"]},columns:{type:"number",scope:"layout",title:"Columns",display:{type:"count-number"},min:1,max:5},wrapperWidth:{type:"number",scope:"layout",title:"Width",display:{type:"numeric-input"},min:0,max:9999},textPaddingLR:{type:"number",scope:"layout",title:"Text Padding LR",min:0,max:9999,display:{type:"range-control"}},entriesCount:{type:"number",scope:"layout",title:"Entries #",display:{type:"toggle-numeric-input",enum:["Auto","Fixed"]},min:1},cellMinHeight:{type:"number",scope:"layout",title:"Cell min height",display:{type:"numeric-input"},min:0,max:9999},imageOnHover:{type:"boolean",scope:"common",title:"Image On Hover",display:{type:"toggle-cycle",enum:["On","Off"]}},imageSize:{type:"object",scope:"layout",title:"Image size",display:{type:"min-max-input"},min:1,max:1440,properties:{min:{type:"number"},max:{type:"number"}}},dividerWidth:{type:"number",scope:"layout",title:"Divider width",display:{type:"numeric-input"},min:0,max:9999},showVisibility:{type:"array",scope:"common",title:"Show",display:{type:"double-toggle",enum:["Top","Bottom"]},items:{type:"boolean"},default:[!0,!1]},cut:{type:"number",scope:"layout",title:"Cut",display:{type:"toggle-numeric-input",enum:["Off","On"]},min:1},entryHoverEffect:{type:"string",scope:"common",title:"Entry Hover Effect",display:{type:"toggle-cycle",enum:["None","Default","Blinds"]}},cutCellMinHeight:{type:"number",scope:"layout",title:"Cell min height",display:{type:"numeric-input"},min:0,max:9999},cutLabel:{type:"string",scope:"common",title:"Cut Label",display:{type:"label-input"}},showCut:{type:"number",scope:"layout",title:"Show",display:{type:"toggle-numeric-input",enum:["All","Custom"]},min:1},rowPaddingTop:{type:"number",scope:"layout",title:"Row Padding Top",min:0,max:100,display:{type:"range-control"}},rowPaddingBottom:{type:"number",scope:"layout",title:"Row Padding Bottom",min:0,max:100,display:{type:"range-control"}},rowPaddingTopB:{type:"number",scope:"layout",title:"Row Padding Top",min:0,max:100,display:{type:"range-control"}},...Ed(),columnsOrder:{type:"array",scope:"layout",title:"Columns Order",display:{type:"reorder-input"},items:{type:"string"}},textColor:{type:"string",scope:"common",title:"Text Default",display:{type:"palette-color-picker"}},textHoverColor:{type:"string",scope:"common",title:"Text Hover",display:{type:"palette-color-picker"}},textFontFamily:{type:"string",scope:"common",title:"Font family",display:{type:"font-family-select"}},textFontSettings:{...Mt.fontSettings,scope:"common",title:"",display:{type:"font-settings-weight"}},textFontSize:{type:"number",scope:"layout",title:"Input Font Size",display:{type:"font-size"}},textLineHeight:{type:"number",scope:"layout",title:"Input Line Height",display:{type:"line-height-input"}},textLetterSpacing:{type:"number",scope:"layout",title:"Input Letter Spacing",display:{type:"letter-spacing-input"}},textWordSpacing:{type:"number",scope:"layout",title:"Input Word Spacing",display:{type:"word-spacing-input"}},textTextAppearance:{type:"object",scope:"layout",title:"Input Text Appearance",display:{type:"text-appearance"}},...Pd,backgroundColor:{type:"string",scope:"common",title:"BG Default",display:{type:"palette-color-picker"}},dividerColor:{type:"string",scope:"common",title:"Divider Default",display:{type:"palette-color-picker"}},backgroundHoverColor:{type:"string",scope:"common",title:"BG Hover",display:{type:"palette-color-picker"}},dividerHoverColor:{type:"string",scope:"common",title:"Divider Hover",display:{type:"palette-color-picker"}}},defaults:{imageOnHover:"Off",entryHoverEffect:"None",cutLabel:"SEE ALL",showVisibility:[!0,!0],textColor:"#767676",textHoverColor:"#767676",textFontFamily:"Arial",textFontSettings:{fontWeight:400,fontStyle:"normal"},textLetterSpacing:0,textWordSpacing:0,textTextAppearance:{textTransform:"none",textDecoration:"none",fontVariant:"normal"},...Ad,backgroundColor:"#FFFFFF00",dividerColor:"#767676",backgroundHoverColor:"#FFFFFF00",dividerHoverColor:"#767676"},layoutDefaults:{m:jo({type:"B",textPaddingLR:.0373,entriesCount:0,cellMinHeight:.02,imageSize:{min:80,max:320},dividerWidth:.002,cut:0,showCut:0,cutCellMinHeight:.043,rowPaddingTop:.01,rowPaddingBottom:.01,rowPaddingTopB:.01,textStroke:.003,textCorners:.192,textPadding:{top:.0373,right:.0373,bottom:.0373,left:.0373},textFontSize:.043,textLineHeight:.043,...Ko({textFontSize:.043,textLineHeight:.043})}),d:jo({type:"A",textPaddingLR:.01,entriesCount:0,cellMinHeight:.03,imageSize:{min:80,max:320},dividerWidth:6e-4,cut:0,showCut:0,cutCellMinHeight:.03,rowPaddingTop:.01,rowPaddingBottom:.01,rowPaddingTopB:.01,textStroke:.001,textCorners:.05,textPadding:{top:.01,right:.01,bottom:.01,left:.01},textFontSize:.01,textLineHeight:.01,...Ko({textFontSize:.01,textLineHeight:.01})})},displayRules:[...Wd(),...Nd.map(e=>({if:{name:"cut",value:0},then:{name:`properties.${e}.display.visible`,value:!1}})),{if:{name:"type",value:"A"},then:{name:"properties.textPaddingLR.display.visible",value:!1}},...Hd.map(e=>({if:{name:"type",value:"B"},then:{name:`properties.${e}.display.visible`,value:!1}})),{if:{name:"type",value:"A"},then:{name:"properties.rowPaddingTopB.display.visible",value:!1}},...Bt.map(e=>({if:{name:"type",value:"A"},then:{name:`properties.${e}ColumnPaddingBottom.display.visible`,value:!1}})),...Bt.map(e=>({if:{name:"type",value:"B"},then:{name:`properties.${e}ColumnVerticalAlign.display.visible`,value:!1}}))],layout:["__componentName__","name","type","columns","wrapperWidth","textPaddingLR","entriesCount","cellMinHeight","imageOnHover","imageSize","dividerWidth","showVisibility","cut","showCut","cutCellMinHeight","entryHoverEffect","cutLabel","rowPaddingTop","rowPaddingBottom","rowPaddingTopB",...Bd]},panels:[{id:"general",icon:"cursor",title:"General",tooltip:"General Settings",layout:[{type:"row",items:["__componentName__","name"]},"type",{type:"row",title:"",items:["columns","wrapperWidth"]},{type:"row",title:"",items:["entriesCount","cellMinHeight"]},{type:"row",title:"",items:["imageOnHover","imageSize"]},{type:"row",title:"",items:["entryHoverEffect"]},{type:"row",title:"Divider Settings",items:["dividerWidth","showVisibility"]},{type:"row",title:"",items:["cut"]},{type:"row",title:"Cut Settings",items:["cutLabel","cutCellMinHeight"]},{type:"row",title:"",items:["showCut"]}]},{id:"columnsOrder",icon:"layers",title:"Columns Order",tooltip:"Columns order",layout:["columnsOrder"]},{id:"typeStyle",icon:"text-icon",title:"Type Style",tooltip:"Typography",layout:[{type:"group",title:"All text",items:["textFontFamily","textFontSettings",{type:"row",items:["textFontSize","textLineHeight","textLetterSpacing","textWordSpacing"]},"textTextAppearance"]},...Id]}],paletteBookmark:{items:[...Fd],panelIds:["general","typeStyle"],stateItems:{default:["textColor","backgroundColor","dividerColor","textHoverColor","backgroundHoverColor","dividerHoverColor"]}}},Dd={element:wd,id:"list",name:"Default List",category:"lists",layoutMode:"structured",preview:{type:"image",url:"https://cdn.cntrl.site/component-assets/Programme_List.png "},version:1,defaultSize:{d:{width:720,height:540}},assetsPaths:{content:[{path:"image.url",placeholderEnabled:!0}],parameters:[]},schema:Vd,sourceCode:$d},zd=[Qs,al,Gl,rc,mc,wc,_c,Fc,Kc,Dd];exports.components=zd;exports.isSchemaV1=ji;
|