@cntrl-site/components 1.0.107-alpha.1 → 1.0.107-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.
@@ -1,176 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),a=require("react"),ct=require("react-dom"),w=require("classnames"),ut=require("./scalingValue-CSHYgTZl.js"),dt=require("./buildColorVars-CE2D5cQV.js"),pt=require("./useScopedStyles-Bf6yohVQ.js"),mt=require("./RichTextRenderer-K90Dd7pt.js"),T=require("./textStylesToCss-CNN3zZTV.js"),ft=require("./useLightboxScrollLock-Hf16Eq4g.js"),M=2,_e=5,Ee=["title2","title3","title4"],R=["column1Width","column2Width","column3Width","column4Width"],X={center:{x:"50%",y:"50%"},"left-top":{x:"0%",y:"0%"},"top-center":{x:"50%",y:"0%"},"top-right":{x:"100%",y:"0%"},"left-center":{x:"0%",y:"50%"},"right-center":{x:"100%",y:"50%"},"left-bottom":{x:"0%",y:"100%"},"bottom-center":{x:"50%",y:"100%"},"right-bottom":{x:"100%",y:"100%"}},vt=Object.keys(X),Le=["column1","column2","column3","column4","column5"],ht={triggerColor:"trigger-color",triggerHoverColor:"trigger-hover-color",closeColor:"close-color",closeHoverColor:"close-hover-color",panelColor:"panel-color",textColor:"text-color",textHoverColor:"text-hover-color",overlayColor:"overlay-color"},gt=["hover","open"],j=300,Ae=.004,we=.004,yt=20,Re=.0139,Ie=.3194,Oe={top:.00972,right:.00972,bottom:.00972,left:.00972},Ne=800,$t=["--cntrl-article-width","--cntrl-article-top","--cntrl-article-left","--cntrl-viewport-height"];function F(e){return Math.min(Math.max(Math.round(e??M),M),_e)}function Te(e){const{panelWidth:o=Ie,panelPadding:n=Oe,columnGap:s=Re}=e,l=(F(e.columns)-1)*s;return Math.max(0,o-n.left-n.right-l)}function Me(e){const o=F(e.columns),n=Te(e)/o;return Object.fromEntries(R.slice(0,o-1).map(s=>[s,n]))}function je(e){const o=F(e.columns),n=Te(e),s=R.slice(0,o-1).map(f=>{const m=e[f];return typeof m=="number"?Math.max(0,m):n/o}),l=s.reduce((f,m)=>f+m,0),c=l>n?n/l:1;return[...s.map(f=>f*c),Math.max(0,n-l*c)]}function xt(e,o){return typeof e.columns!="number"||e.columns===o.columns?e:{...e,...Me({...o,...e})}}function Ct(e){const o=e.reduce((n,s)=>n+s,0);return e.map(n=>`minmax(0, ${o>0?n/o*100:1}fr)`).join(" ")}function Fe(e){const o=[];return e.forEach((n,s)=>{var p;const l=((p=n.group)==null?void 0:p.trim())??"",c=o[o.length-1];if(!c||l!==""&&l!==c.label){o.push({label:l,rows:[{item:n,index:s}]});return}c.rows.push({item:n,index:s})}),o}function wt(e){return e.type==="video"?!0:e.type==="image"?!1:/\.(mp4|webm|ogg|mov)(\?|$)/i.test(e.name??"")||/\.(mp4|webm|ogg|mov)(\?|$)/i.test(e.assetId)}function bt(e){let o=e;for(;o;){if(getComputedStyle(o).getPropertyValue("--cntrl-article-width").trim())return o;o=o.parentElement}return e}function be(e){const o={},n=bt(e);if(!n)return o;const s=getComputedStyle(n);for(const l of $t){const c=s.getPropertyValue(l).trim();c&&(o[l]=c)}return o}function Se(e,o,n){const s=e,l=p=>s[`${o}${p}`]??(n?s[`${n}${p}`]:void 0),c=l("FontSettings");return{fontSettings:{fontFamily:l("FontFamily"),fontWeight:(c==null?void 0:c.fontWeight)??400,fontStyle:(c==null?void 0:c.fontStyle)??"normal"},fontSize:l("FontSize")??.01,lineHeight:l("LineHeight"),letterSpacing:l("LetterSpacing")??0,wordSpacing:l("WordSpacing")??0,textAlign:l("TextAlign"),textAppearance:l("TextAppearance"),color:"#000000"}}function St(e){return`
2
- .${e}-trigger,
3
- .${e}-close {
4
- display: inline-block;
5
- margin: 0;
6
- padding: 0;
7
- border: 0;
8
- background: none;
9
- cursor: pointer;
10
- white-space: nowrap;
11
- transition: color 150ms ease;
12
- -webkit-appearance: none;
13
- appearance: none;
14
- -webkit-tap-highlight-color: transparent;
15
- }
16
- .${e}-trigger {
17
- color: var(--${e}-trigger-color);
18
- }
19
- .${e}-close {
20
- color: var(--${e}-close-color);
21
- }
22
- .${e}-trigger:focus,
23
- .${e}-close:focus {
24
- outline: none;
25
- }
26
- .${e}-trigger:focus-visible,
27
- .${e}-close:focus-visible {
28
- outline: 1px solid currentColor;
29
- outline-offset: 2px;
30
- }
31
- .${e}-interactive .${e}-trigger:hover,
32
- .${e}-state-hover .${e}-trigger {
33
- color: var(--${e}-trigger-hover-color, var(--${e}-trigger-color));
34
- }
35
- .${e}-close:hover {
36
- color: var(--${e}-close-hover-color, var(--${e}-close-color));
37
- }
38
- .${e}-editor .${e}-trigger {
39
- cursor: default;
40
- }
41
- .${e}-overlay {
42
- position: fixed;
43
- inset: 0;
44
- z-index: 9997;
45
- overflow: hidden;
46
- overscroll-behavior: none;
47
- opacity: 0;
48
- pointer-events: none;
49
- transition: opacity ${j}ms ease;
50
- }
51
- .${e}-inline-layer {
52
- position: fixed;
53
- inset: 0;
54
- z-index: 9997;
55
- overflow: hidden;
56
- pointer-events: none;
57
- }
58
- .${e}-overlay-editor {
59
- inset: auto;
60
- top: var(--cntrl-article-top, 0);
61
- left: var(--cntrl-article-left, 0);
62
- width: var(--cntrl-article-width, 100vw) !important;
63
- height: var(--cntrl-viewport-height, 100vh) !important;
64
- }
65
- .${e}-overlay-edit-mode {
66
- z-index: 1;
67
- }
68
- .${e}-overlay-active {
69
- opacity: 1;
70
- pointer-events: auto;
71
- }
72
- .${e}-backdrop {
73
- position: absolute;
74
- inset: 0;
75
- background-color: var(--${e}-overlay-color);
76
- }
77
- .${e}-media-layer {
78
- position: absolute;
79
- inset: 0;
80
- pointer-events: none;
81
- }
82
- .${e}-media {
83
- position: absolute;
84
- inset: 0;
85
- width: 100%;
86
- height: 100%;
87
- object-fit: cover;
88
- opacity: 0;
89
- transition: opacity ${Ne}ms cubic-bezier(0, 0, 0.58, 1);
90
- }
91
- .${e}-media-contain {
92
- object-fit: contain;
93
- }
94
- .${e}-media-visible {
95
- opacity: 1;
96
- }
97
- .${e}-close {
98
- position: absolute;
99
- z-index: 2;
100
- }
101
- .${e}-panel {
102
- position: absolute;
103
- top: var(--${e}-panel-y);
104
- left: var(--${e}-panel-x);
105
- z-index: 1;
106
- box-sizing: border-box;
107
- max-width: 100%;
108
- max-height: 100%;
109
- overflow-y: auto;
110
- transform: translate(calc(-1 * var(--${e}-panel-x)), calc(-1 * var(--${e}-panel-y) + 12px));
111
- background-color: var(--${e}-panel-color);
112
- color: var(--${e}-text-color);
113
- overscroll-behavior: contain;
114
- transition: transform ${j}ms cubic-bezier(0, 0, 0.58, 1);
115
- }
116
- .${e}-overlay-active .${e}-panel {
117
- transform: translate(calc(-1 * var(--${e}-panel-x)), calc(-1 * var(--${e}-panel-y)));
118
- }
119
- .${e}-panel-settled {
120
- transition: none;
121
- }
122
- .${e}-panel-inline {
123
- position: relative;
124
- top: auto;
125
- left: auto;
126
- max-height: none;
127
- transform: none;
128
- transition: none;
129
- }
130
- .${e}-media-layer-instant .${e}-media {
131
- transition: none;
132
- }
133
- .${e}-panel-copy {
134
- position: absolute;
135
- pointer-events: none;
136
- }
137
- .${e}-panel-copy .${e}-row-active .${e}-title {
138
- color: var(--${e}-text-hover-color, var(--${e}-text-color));
139
- }
140
- @media (prefers-reduced-motion: reduce) {
141
- .${e}-panel {
142
- transition: none;
143
- }
144
- }
145
- .${e}-group ~ .${e}-group {
146
- margin-top: var(--${e}-group-gap);
147
- }
148
- .${e}-row {
149
- display: grid;
150
- grid-template-columns: var(--${e}-grid-columns);
151
- column-gap: var(--${e}-column-gap);
152
- align-items: baseline;
153
- }
154
- .${e}-group-label {
155
- min-width: 0;
156
- overflow-wrap: anywhere;
157
- }
158
- .${e}-title {
159
- min-width: 0;
160
- overflow-wrap: anywhere;
161
- transition: color 150ms cubic-bezier(0, 0, 0.58, 1);
162
- }
163
- .${e}-control-anchor {
164
- position: absolute;
165
- pointer-events: none;
166
- z-index: 2;
167
- }
168
- .${e}-title a {
169
- text-decoration: inherit;
170
- }
171
- .${e}-interactive .${e}-row:hover .${e}-title,
172
- .${e}-row:focus-within .${e}-title,
173
- .${e}-state-hover .${e}-row:first-child .${e}-title {
174
- color: var(--${e}-text-hover-color, var(--${e}-text-color));
175
- }
176
- `}function _t({P:e,media:o,isVisible:n}){const s=a.useRef(null),[l,c]=a.useState(!1),p=wt(o),f=w(`${e}-media`,o.objectFit==="contain"&&`${e}-media-contain`,n&&l&&`${e}-media-visible`);return a.useEffect(()=>{var r;const m=s.current;!p||!m||(n?(r=m.play())==null||r.catch(()=>{}):m.pause())},[p,n]),p?i.jsx("video",{ref:s,className:f,src:o.assetId,muted:!0,loop:!0,playsInline:!0,preload:"auto",onLoadedData:()=>c(!0)}):i.jsx("img",{className:f,src:o.assetId,alt:"",decoding:"async",onLoad:()=>c(!0)})}function Et(e,o,n,s,l){const c=o[o.length-1];let p=n;return o.slice(0,-1).map((f,m)=>{const r=p+f+s/2;return p+=f+s,i.jsx("div",{"data-controls":R[m],"data-controls-axis":"x","data-controls-variant":"column-width","data-controls-min":String(yt),"data-controls-max-fraction":String(f+c),className:`${e}-control-anchor`,style:{top:0,left:l(r-we/2),width:l(we),height:"100%"}},R[m])})}function Lt(e,o,n,s){const l=c=>s(Math.max(c,Ae));return i.jsxs(i.Fragment,{children:[i.jsx("div",{"data-controls":"panelPadding.top","data-controls-axis":"y","data-controls-variant":"row-padding","data-controls-min":"0",className:`${e}-control-anchor`,style:{top:0,left:0,width:"100%",height:l(n.top)}}),i.jsx("div",{"data-controls":"panelPadding.bottom","data-controls-axis":"y","data-controls-variant":"row-padding","data-controls-reverse":"","data-controls-min":"0",className:`${e}-control-anchor`,style:{bottom:0,left:0,width:"100%",height:l(n.bottom)}}),i.jsx("div",{"data-controls":"panelPadding.left","data-controls-axis":"x","data-controls-variant":"column-padding","data-controls-min":"0","data-controls-max-fraction":String(Math.max(0,o-n.right)),className:`${e}-control-anchor`,style:{top:0,left:0,width:l(n.left),height:"100%"}}),i.jsx("div",{"data-controls":"panelPadding.right","data-controls-axis":"x","data-controls-variant":"column-padding","data-controls-reverse":"","data-controls-min":"0","data-controls-max-fraction":String(Math.max(0,o-n.left)),className:`${e}-control-anchor`,style:{top:0,right:0,width:l(n.right),height:"100%"}})]})}function At({settings:e,content:o,isEditor:n,isEditMode:s,isPreviewMode:l,activeEvent:c,portalId:p,currentState:f,unavailableStates:m}){const{prefix:r}=pt.useScopedStyles(),{type:He="a",triggerLabel:Y="Archive",closeLabel:Ue="Close",columns:Ve=M,columnGap:K=Re,panelPosition:ze,panelWidth:Z=Ie,panelPadding:b=Oe,panelRadius:We=0,groupGap:J=.0139,triggerColor:Be="#000000",triggerHoverColor:De="#666666",closeColor:ke="#000000",closeHoverColor:qe="#666666",panelColor:Ge="#FFFFFF",textColor:Xe="#333132",textHoverColor:Ye="#BBBBBB",overlayColor:Ke="#FFFFFFE6"}=e,Q=o??[],H=a.useRef(null),U=a.useRef(null),V=a.useRef(null),P=a.useRef(null),ee=a.useRef(null),te=a.useRef(null),[Ze,I]=a.useState(!1),[L,oe]=a.useState(!1),[O,ne]=a.useState(!1),[re,le]=a.useState(!1),[x,S]=a.useState(null),[ae,Je]=a.useState(()=>new Set),[C,Qe]=a.useState(null),[se,ie]=a.useState({}),[_,z]=a.useState(null),[Pe,ce]=a.useState(!1),A=!!(n&&!l),y=!n||!!l,v=He==="b",et=A&&f==="open"&&!(m!=null&&m.includes("open")),$=!v&&(et||(y||!!s)&&Ze),h=t=>ut.scalingValue(t,n??!1),tt=a.useMemo(()=>St(r),[r]),ot=a.useMemo(()=>Fe(o??[]),[o]),ue=X[ze]??X.center,de=F(Ve),pe=je(e),nt=["title",...Ee].slice(0,de-1);ft.useLightboxScrollLock($&&!A),a.useEffect(()=>{A&&!s&&I(!1)},[A,s]),a.useEffect(()=>{if($){ie(be(H.current)),oe(!0);return}ne(!1),S(null);const t=window.setTimeout(()=>oe(!1),j);return()=>window.clearTimeout(t)},[$]),a.useEffect(()=>{var u;if(!$||!L)return;(u=V.current)==null||u.getBoundingClientRect();const t=requestAnimationFrame(()=>ne(!0));return()=>cancelAnimationFrame(t)},[$,L]),a.useEffect(()=>{if(!O){le(!1);return}const t=window.setTimeout(()=>le(!0),j);return()=>window.clearTimeout(t)},[O]);const N=a.useCallback(()=>{const t=U.current,u=V.current;if(!t||!u)return;const d=t.getBoundingClientRect(),g=u.getBoundingClientRect();Qe({top:d.top-g.top,left:d.left-g.left})},[]);a.useLayoutEffect(()=>{if(L)return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[L,N]),a.useEffect(()=>{var u;if(!$||!y)return;(u=P.current)==null||u.focus({preventScroll:!0});const t=d=>{d.key==="Escape"&&I(!1)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[$,y]),a.useLayoutEffect(()=>{if(!v||x===null)return;const t=ee.current,u=te.current;if(!t||!u)return;const d=t.getBoundingClientRect(),g=u.getBoundingClientRect();z({top:d.top-g.top,left:d.left-g.left,width:d.width})},[v,x]),a.useEffect(()=>{if(x!==null)return;const t=window.setTimeout(()=>z(null),Ne);return()=>window.clearTimeout(t)},[x]);const me=_!==null;a.useEffect(()=>{if(!v||!me)return;const t=()=>{ce(!0),S(null),z(null)};return document.addEventListener("scroll",t,{capture:!0,passive:!0}),window.addEventListener("resize",t),()=>{document.removeEventListener("scroll",t,{capture:!0}),window.removeEventListener("resize",t)}},[v,me]);const fe=()=>{var t;y&&(I(!1),(t=U.current)==null||t.focus({preventScroll:!0}))},ve=t=>{var u,d;if(!y||!((d=(u=Q[t])==null?void 0:u.image)!=null&&d.assetId)){S(null);return}Je(g=>g.has(t)?g:new Set(g).add(t)),v&&x===null&&ie(be(H.current)),ce(!1),S(t)},he=t=>{S(u=>u===t?null:u)},rt=t=>{!y&&t.target.closest("a")&&t.preventDefault()},ge=T.omitTextColors(T.textStylesToCss(Se(e,"trigger"),n)),ye=Le.slice(0,de).map(t=>T.omitTextColors(T.textStylesToCss(Se(e,t,"list"),n))),W=dt.buildColorVars(r,{triggerColor:Be,triggerHoverColor:De,closeColor:ke,closeHoverColor:qe,panelColor:Ge,textColor:Xe,textHoverColor:Ye,overlayColor:Ke},ht,gt),B=c&&c!=="default"?`${r}-state-${c}`:"",D=y?`${r}-interactive`:"",$e=i.jsx("div",{className:w(`${r}-media-layer`,Pe&&`${r}-media-layer-instant`),"aria-hidden":"true",children:[...ae].map(t=>{var d;const u=(d=Q[t])==null?void 0:d.image;return u!=null&&u.assetId?i.jsx(_t,{P:r,media:u,isVisible:x===t},`${t}-${u.assetId}`):null})}),k=!!s&&(v||re),q=t=>i.jsxs("div",{ref:t?void 0:ee,className:w(`${r}-panel`,O&&re&&`${r}-panel-settled`,v&&`${r}-panel-inline`,t&&`${r}-panel-copy`),style:{width:h(Z),paddingTop:h(b.top),paddingRight:h(b.right),paddingBottom:h(b.bottom),paddingLeft:h(b.left),borderRadius:h(We),[`--${r}-group-gap`]:h(J),[`--${r}-panel-x`]:ue.x,[`--${r}-panel-y`]:ue.y,[`--${r}-grid-columns`]:Ct(pe),[`--${r}-column-gap`]:h(K),...t&&_?{top:_.top,left:_.left,width:_.width}:{}},"data-lightbox-scrollable":v?void 0:"","aria-hidden":t||void 0,onMouseLeave:t?void 0:()=>S(null),onClickCapture:t?void 0:rt,children:[!t&&k&&Lt(r,Z,b,h),!t&&k&&Et(r,pe,b.left,K,h),ot.map((u,d)=>i.jsxs(a.Fragment,{children:[!t&&k&&d>0&&i.jsx("div",{"data-controls":"groupGap","data-controls-paired":"","data-controls-axis":"y","data-controls-reverse":"","data-controls-min":"0",className:`${r}-control-anchor`,style:{left:0,width:"100%",height:h(Math.max(J,Ae))}}),i.jsx("div",{className:`${r}-group`,children:u.rows.map(({item:g,index:E},st)=>i.jsxs("div",{className:w(`${r}-row`,t&&E===x&&`${r}-row-active`),...t?{}:{onMouseEnter:()=>ve(E),onMouseLeave:()=>he(E),onFocus:()=>ve(E),onBlur:()=>he(E)},children:[i.jsx("span",{className:`${r}-group-label`,style:ye[0],children:st===0?u.label:""}),nt.map((Ce,it)=>{const G=g[Ce];return i.jsx("div",{className:`${r}-title`,style:ye[it+1],children:Array.isArray(G)?i.jsx(mt.RichTextRenderer,{content:G}):G},Ce)})]},E))})]},d))]}),lt=L?i.jsxs("div",{ref:V,className:w(`${r}-overlay`,n&&`${r}-overlay-editor`,s&&`${r}-overlay-edit-mode`,O&&`${r}-overlay-active`,D,B),style:{...W,...se},role:"dialog","aria-modal":"true","aria-label":Y,"data-selection":"none",children:[i.jsx("div",{className:`${r}-backdrop`,"aria-hidden":"true",onClick:fe}),$e,i.jsx("button",{ref:P,type:"button",className:`${r}-close`,style:{...ge,top:(C==null?void 0:C.top)??0,left:(C==null?void 0:C.left)??0,visibility:C?"visible":"hidden"},onClick:fe,children:Ue}),q(!1)]}):null,at=v&&ae.size>0?i.jsxs("div",{ref:te,className:w(`${r}-inline-layer`,n&&`${r}-overlay-editor`,D,B),style:{...W,...se},"aria-hidden":"true","data-selection":"none",children:[$e,_&&q(!0)]}):null,xe=lt??at;return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:tt}}),i.jsx("div",{ref:H,className:w(A&&`${r}-editor`,D,B),style:W,children:v?q(!1):i.jsx("button",{ref:U,type:"button",className:`${r}-trigger`,style:ge,"aria-haspopup":"dialog","aria-expanded":$,onClick:()=>{y&&I(!0)},children:Y})}),xe&&typeof document<"u"&&ct.createPortal(xe,(p?document.getElementById(p):null)??document.body)]})}exports.ARCHIVE_POPUP_COLUMN_STYLE_PREFIXES=Le;exports.ARCHIVE_POPUP_COLUMN_WIDTH_KEYS=R;exports.ARCHIVE_POPUP_EXTRA_TITLE_KEYS=Ee;exports.ARCHIVE_POPUP_MAX_COLUMNS=_e;exports.ARCHIVE_POPUP_MIN_COLUMNS=M;exports.ARCHIVE_POPUP_PANEL_POSITIONS=vt;exports.ArchivePopup=At;exports.applyArchivePopupColumnCountChange=xt;exports.getArchivePopupEqualColumnWidths=Me;exports.groupArchiveRows=Fe;exports.resolveArchivePopupColumnWidths=je;