@cntrl-site/components 1.0.107-alpha.3 → 1.0.107-alpha.4

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