@rulecms/widget-svelte 0.2.0 → 0.3.0
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/README.md +14 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +15 -0
- package/dist/index.js +26 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,6 +67,20 @@ Pass extra props — a click handler, a callback — to one component instance b
|
|
|
67
67
|
|
|
68
68
|
`r-button` reads `onClick` from the bag. The renderer never inspects the contents. In development, a key that addresses no column in the widget is printed once so typos are visible while building.
|
|
69
69
|
|
|
70
|
+
## Host `mounts`
|
|
71
|
+
|
|
72
|
+
Register a Svelte component from your app so a Custom (`r-mount`) slot in the composer can render it by name. The name is a map key, not a string that becomes code. A miss is a placeholder.
|
|
73
|
+
|
|
74
|
+
```svelte
|
|
75
|
+
<RuleCMSWidget publishedKey={publishedKey} {mounts} />
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const mounts = { 'booking-form': BookingForm };
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Tell the marketer the exact name and the props the component reads. Event handlers still go through `componentProps` at that column's id — authored prop rows cannot become `onClick`. See `__docs__/CONTRACT_mounts.md` and [Mount Your Own Components](https://rulecms.com/docs/widget-mounts).
|
|
83
|
+
|
|
70
84
|
## Develop locally
|
|
71
85
|
|
|
72
86
|
```bash
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ ${t}, ${n}, ${r} { display: none; }
|
|
|
7
7
|
`.trim()}function cn(e){if(!e)throw new Error("Source components plugin is required, but no plugins were provided");const t=e.sourceComponents;if(!t)throw new Error("Source components plugin is required, but was not found in plugins object");if(!t.components)throw new Error("Source components plugin is missing required property: components");if(typeof t.components!="object"||t.components===null||Array.isArray(t.components))throw new Error("Source components plugin components must be an object (Record<string, LibraryComponentEntry>)");return t}let Qa=0;var $a=Pe("<div><!> <!></div>");function eu(e,t){Me(t,!0);let n=ae(t,"isComposeMode",3,!1),r=ae(t,"showDropContainers",3,!1),o=ae(t,"isWithinCollection",3,!1),i=ae(t,"deviceDisplayType",3,"Desktop");const s=`rulecms-vc-${++Qa}`;function l(w,S,E){const b=w&&!E?3:1;return!!(S!=null&&S.length)&&S.length>b}const u=D(()=>{var w;return(((w=t.displayItemList.containerAttributes)==null?void 0:w[an])||[]).join(`;
|
|
8
8
|
`)}),c=D(()=>g(u)?`.${s} {
|
|
9
9
|
${g(u)}
|
|
10
|
-
}`:""),f=D(()=>!n()&&us({containerAttributes:t.displayItemList.containerAttributes,deviceDisplayType:i()})),p=D(()=>cs({containerAttributes:t.displayItemList.containerAttributes,deviceDisplayType:i(),isComposeMode:n()})),a=D(()=>{var E;const w=((E=t.displayItemList.containerAttributes)==null?void 0:E[an])||[],S=fs(g(p));return n()&&!o()||r()||w.length>0||S||l(n(),t.displayItemList.rows,o())}),d=D(()=>[g(u)?s:void 0,g(p).cssClasses].filter(Boolean).join(" ")),y=D(()=>{var S;return{...(((S=t.displayItemList.containerAttributes)==null?void 0:S[an])||[]).some(E=>E.toLowerCase().startsWith("height:"))?{}:{height:o()?"auto":"100%"},display:"flex",flexDirection:"column",...g(p).styles}}),m=D(()=>g(a)?g(d):""),h=D(()=>g(f)?{display:"none"}:g(a)?g(y):{display:"contents"});var _=$a(),A=_e(_);{var P=w=>{var S=ie(),E=q(S);yr(E,()=>"style",!1,(b,I)=>{var T=gr();le(()=>En(T,g(c))),M(I,T)}),M(w,S)};De(A,w=>{g(u)&&w(P)})}var C=Ct(A,2);vr(C,()=>t.children),le(w=>{ht(_,"hidden",g(f)||void 0),St(_,1,Gt(g(m)||void 0)),ne(_,w)},[()=>re(g(h))]),M(e,_),Ne()}var tu=Pe("<div><!></div>");function nu(e,t){Me(t,!0);let n=ae(t,"isComposeMode",3,!1),r=ae(t,"showDropContainers",3,!1),o=ae(t,"isWithinCollection",3,!1),i=ae(t,"deviceDisplayType",3,"Desktop");function s(m,h,_){var P;const A=m&&!_?3:1;return!!((P=h==null?void 0:h.columns)!=null&&P.length)&&h.columns.length>A}const l=D(()=>!n()&&ss({row:t.row,deviceDisplayType:i()})),u=D(()=>r()||is(t.row)||s(n(),t.row,o())),c=D(()=>ls({row:t.row,deviceDisplayType:i(),isComposeMode:n()})),f=D(()=>{var h;const m=ot({deviceDisplayType:i(),componentAttributes:t.row.rowAttributes});return Mn((h=m==null?void 0:m.componentAttributesSpecificToDeviceType)==null?void 0:h[xn])??""}),p=D(()=>g(u)?g(f):""),a=D(()=>g(l)?{display:"none"}:g(u)?g(c):{display:"contents"});var d=tu(),y=_e(d);vr(y,()=>t.children),le(m=>{ht(d,"hidden",g(l)||void 0),St(d,1,Gt(g(p)||void 0)),ne(d,m)},[()=>re(g(a))]),M(e,d),Ne()}const _s=["minWidth","maxWidth","minHeight","maxHeight","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderWidth","borderStyle","borderColor","border","borderRadius","boxShadow","width","height","gap","display","justifyContent","alignItems","flexWrap","alignContent","flexDirection","overflow","overflowX","overflowY","backgroundColor","backgroundImage","backgroundSize","backgroundPosition","backgroundRepeat","opacity","fontFamily","fontSize","fontWeight","fontStyle","color","lineHeight","letterSpacing","textAlign","textDecoration","textTransform"],ru=e=>e!=null&&e!=="",ou=e=>e?_s.reduce((t,n)=>{const r=e[n];return ru(r)&&(t[n]=r),t},{}):{},iu=e=>{if(!e)return;const t={...e};for(const n of _s)delete t[n];return Object.keys(t).length?t:void 0},su=e=>Object.keys(e).length>0,lu=(e,t)=>{const n=(e==null?void 0:e.noContainer)??!1,r=e==null?void 0:e.resolveNoContainer;if(typeof r!="function")return n;try{const o=r(t);if(typeof o=="boolean")return o;console.error(`resolveNoContainer: component "${e==null?void 0:e.id}" returned ${typeof o} instead of a boolean; falling back to noContainer=${n}`)}catch(o){console.error(`resolveNoContainer: component "${e==null?void 0:e.id}" threw; falling back to noContainer=${n}`,o)}return n},au=(e,t)=>{const n=e==null?void 0:e.resolveRendersOwnElement;if(typeof n!="function")return!1;try{const r=n(t);if(typeof r=="boolean")return r;console.error(`resolveRendersOwnElement: component "${e==null?void 0:e.id}" returned ${typeof r} instead of a boolean; falling back to false`)}catch(r){console.error(`resolveRendersOwnElement: component "${e==null?void 0:e.id}" threw; falling back to false`,r)}return!1};var Zr=Pe("<div><!></div>");function bs(e,t){Me(t,!0);const n=D(()=>t.components[mr(t.libraryId,t.componentType)]),r=D(()=>{var _;const h=(_=g(n))==null?void 0:_.card;return h||(console.error(`DisplayComponent: Component with type ${t.componentType}${t.libraryId?` (library "${t.libraryId}")`:""} not found in components`),null)}),o=D(()=>({componentAttributes:t.componentAttributes,styleProps:t.styleProps})),i=D(()=>g(n)?lu(g(n),g(o)):!1),s=D(()=>ou(t.styleProps)),l=D(()=>g(i)?iu(t.styleProps):t.styleProps),u=D(()=>{var h;return Mn((h=t.componentAttributes)==null?void 0:h[xn])}),c=D(()=>g(i)&&su(g(s))),f=D(()=>!g(i)||(g(n)?au(g(n),g(o)):!1)),p=D(()=>!g(c)&&g(f)?g(u):void 0),a=D(()=>({componentAttributes:t.componentAttributes,styleProps:g(l),className:g(p),widgetInstanceProps:t.widgetInstanceProps}));var d=ie(),y=q(d);{var m=h=>{const _=D(()=>g(r));var A=ie(),P=q(A);{var C=E=>{var b=Zr(),I=_e(b);Un(I,()=>g(_),(T,N)=>{N(T,Gn(()=>g(a)))}),le(T=>{St(b,1,Gt(g(u)||void 0)),ne(b,T)},[()=>re(g(s))]),M(E,b)},w=E=>{var b=Zr(),I=_e(b);Un(I,()=>g(_),(T,N)=>{N(T,Gn(()=>g(a)))}),le(()=>St(b,1,Gt(g(u)))),M(E,b)},S=E=>{var b=ie(),I=q(b);Un(I,()=>g(_),(T,N)=>{N(T,Gn(()=>g(a)))}),M(E,b)};De(P,E=>{g(c)?E(C):!g(f)&&g(u)?E(w,1):E(S,-1)})}M(h,A)};De(y,h=>{g(r)&&h(m)})}M(e,d),Ne()}function Pr(e,t){Me(t,!0);let n=ae(t,"isComposeMode",3,!1),r=ae(t,"isWithinCollection",3,!1),o=ae(t,"showDropContainers",3,!1);const i=D(()=>cn(t.plugins).components);function s(p){if(n()&&p.type===In.DroppableBox)return!1;const{componentAttributesBasedOnDevice:a}=er({col:p,deviceDisplayType:t.deviceDisplayType,isComposeMode:n(),sourceComponentsPlugin:cn(t.plugins)}),d=!!a&&a["hide-component-3-resolutions"]==="true";return!(!n()&&d)}function l(p){const{componentAttributesBasedOnDevice:a,componentStyles:d}=er({col:p,deviceDisplayType:t.deviceDisplayType,isComposeMode:n(),sourceComponentsPlugin:cn(t.plugins)});return{componentAttributes:a,styleProps:d}}function u(p){const a=Ar(p.type);if(!(a!=null&&a.length))return null;const d=p.collection??t.widgetCollections[a];if(!d)throw new Error(`DisplayCollection - Collection with ID ${a} not found in widgetCollections. Available collections: ${Object.keys(t.widgetCollections).join(", ")}`);return!d.collectionRows||!rs(d.collectionRows)?null:d.collectionRows}function c(p){return[...t.ancestorColumnIds??[],p]}function f(p){return ds({componentProps:t.componentProps,ancestorColumnIds:t.ancestorColumnIds,columnId:p})}eu(e,{get displayItemList(){return t.displayItemList},get isComposeMode(){return n()},get showDropContainers(){return o()},get isWithinCollection(){return r()},get deviceDisplayType(){return t.deviceDisplayType},children:(p,a)=>{var d=ie(),y=q(d);bn(y,17,()=>t.displayItemList.rows,m=>m.id,(m,h)=>{nu(m,{get row(){return g(h)},get isComposeMode(){return n()},get showDropContainers(){return o()},get isWithinCollection(){return r()},get deviceDisplayType(){return t.deviceDisplayType},children:(_,A)=>{var P=ie(),C=q(P);bn(C,17,()=>g(h).columns,w=>w.id,(w,S)=>{var E=ie(),b=q(E);{var I=N=>{const Y=D(()=>u(g(S)));var O=ie(),X=q(O);{var it=Le=>{{let st=D(()=>c(g(S).id));Pr(Le,{get displayItemList(){return g(Y)},get isComposeMode(){return n()},isWithinCollection:!0,get widgetCollections(){return t.widgetCollections},get showDropContainers(){return o()},get reduxDeviceDisplayType(){return t.reduxDeviceDisplayType},get plugins(){return t.plugins},get deviceDisplayType(){return t.deviceDisplayType},get componentProps(){return t.componentProps},get ancestorColumnIds(){return g(st)}})}},tn=Le=>{{let st=D(()=>l(g(S)).componentAttributes),he=D(()=>l(g(S)).styleProps),nn=D(()=>f(g(S).id));bs(Le,{get componentType(){return g(S).type},get libraryId(){return g(S).libraryId},get componentAttributes(){return g(st)},get components(){return g(i)},get styleProps(){return g(he)},get widgetInstanceProps(){return g(nn)}})}};De(X,Le=>{g(Y)?Le(it):Le(tn,-1)})}M(N,O)},T=D(()=>s(g(S)));De(b,N=>{g(T)&&N(I)})}M(w,E)}),M(_,P)},$$slots:{default:!0}})}),M(p,d)},$$slots:{default:!0}}),Ne()}function wn(e,t){Me(t,!0);var n=ie(),r=q(n);{var o=i=>{Pr(i,{get displayItemList(){return t.displayItemList},get isComposeMode(){return t.isComposeMode},get isWithinCollection(){return t.isWithinCollection},get widgetCollections(){return t.widgetCollections},get showDropContainers(){return t.showDropContainers},get reduxDeviceDisplayType(){return t.reduxDeviceDisplayType},get plugins(){return t.plugins},get deviceDisplayType(){return t.deviceDisplayType},get componentProps(){return t.componentProps},get ancestorColumnIds(){return t.ancestorColumnIds}})};De(r,i=>{var s,l;(l=(s=t.displayItemList)==null?void 0:s.rows)!=null&&l.length&&i(o)})}M(e,n),Ne()}function ws(e,t){var n=ie(),r=q(n);bn(r,16,()=>t.stylesheets??[],o=>o,(o,i)=>{var s=ie(),l=q(s);yr(l,()=>"style",!1,(u,c)=>{ia(u,()=>({"data-rulecms-library-stylesheet":""}));var f=gr();le(()=>En(f,i)),M(c,f)}),M(o,s)}),M(e,n)}let uu=0;var cu=Pe("<div><!></div>"),Jr=Pe("<!> <!>",1);function Cs(e,t){Me(t,!0);const n=["Phone","Tablet","Desktop"],r=`rulecms-bp-${++uu}`,o=D(()=>t.scopeIdInput??r),i=D(()=>vs(t.displayItemList,t.widgetCollections)),s=D(()=>Ja(g(o)));var l=Jr(),u=q(l);{let a=D(()=>{var d;return(d=t.plugins.sourceComponents)==null?void 0:d.stylesheets});ws(u,{get stylesheets(){return g(a)}})}var c=Ct(u,2);{var f=a=>{wn(a,{get displayItemList(){return t.displayItemList},isComposeMode:!1,isWithinCollection:!1,get widgetCollections(){return t.widgetCollections},showDropContainers:!1,reduxDeviceDisplayType:"desktop",deviceDisplayType:"Desktop",get plugins(){return t.plugins},get componentProps(){return t.componentProps}})},p=a=>{var d=Jr(),y=q(d);yr(y,()=>"style",!1,(h,_)=>{var A=gr();le(()=>En(A,g(s))),M(_,A)});var m=Ct(y,2);bn(m,16,()=>n,h=>h,(h,_)=>{var A=cu(),P=_e(A);wn(P,{get displayItemList(){return t.displayItemList},isComposeMode:!1,isWithinCollection:!1,get widgetCollections(){return t.widgetCollections},showDropContainers:!1,reduxDeviceDisplayType:"desktop",get deviceDisplayType(){return _},get plugins(){return t.plugins},get componentProps(){return t.componentProps}}),le(C=>St(A,1,C),[()=>`${g(o)}-${_.toLowerCase()}`]),M(h,A)}),M(a,d)};De(c,a=>{g(i)?a(p,-1):a(f)})}M(e,l),Ne()}function fu(e,t,n){if(e)return"Phone";if(t)return"Tablet";const r=(n==null?void 0:n.toLowerCase())||"desktop";return r==="phone"?"Phone":r==="tablet"?"Tablet":"Desktop"}const du=`(max-width: ${Er})`,pu=`(max-width: ${Tr})`;var hu=Pe("<!> <!>",1);function As(e,t){Me(t,!0);let n=oe("Desktop"),r,o;function i(){W(n,fu((r==null?void 0:r.matches)??!1,(o==null?void 0:o.matches)??!1,t.reduxDeviceDisplayType),!0)}dr(()=>(typeof matchMedia=="function"&&(r=matchMedia(du),o=matchMedia(pu),r.addEventListener("change",i),o.addEventListener("change",i)),i(),()=>{r==null||r.removeEventListener("change",i),o==null||o.removeEventListener("change",i)}));var s=hu(),l=q(s);{var u=f=>{{let p=D(()=>{var a;return(a=t.plugins.sourceComponents)==null?void 0:a.stylesheets});ws(f,{get stylesheets(){return g(p)}})}};De(l,f=>{t.isWithinCollection||f(u)})}var c=Ct(l,2);wn(c,{get displayItemList(){return t.displayItemList},get isComposeMode(){return t.isComposeMode},get isWithinCollection(){return t.isWithinCollection},get widgetCollections(){return t.widgetCollections},get showDropContainers(){return t.showDropContainers},get reduxDeviceDisplayType(){return t.reduxDeviceDisplayType},get deviceDisplayType(){return g(n)},get plugins(){return t.plugins},get componentProps(){return t.componentProps}}),M(e,s),Ne()}function gu(e){const t={};return Object.entries(e).forEach(([n,r])=>{const o={...r};if(o.itemList)try{o.collectionRows=typeof o.itemList=="string"?JSON.parse(o.itemList):o.itemList}catch(s){console.error(`Failed to parse itemList for collection ${n}:`,s),o.collectionRows={rows:[]}}let i=`${o.name}$${n}`;o.parentId&&(i=`${i}@${o.parentId}`),t[i]=o}),t}function vu(e){return typeof e.itemList=="string"?JSON.parse(e.itemList):e.itemList}function kr(e){return{displayItemList:vu(e.widget),widgetCollections:gu(e.childCollections),...e.libraries?{libraries:e.libraries}:{}}}function yu(e){const t=e.registry??en(),n=Dn({displayItemList:e.displayItemList,widgetCollections:e.widgetCollections});return t.resolveSync({registrations:e.libraries,referenced:n})}function mu(e){const t=e.registry??en(),n=Dn({displayItemList:e.displayItemList,widgetCollections:e.widgetCollections});return t.resolve({registrations:e.libraries,referenced:n})}const _u={display:"flex",justifyContent:"center",alignItems:"center",padding:"3rem",color:"#e2e8f0"},bu={display:"flex",alignItems:"center",gap:"1rem"},wu={width:"40px",height:"40px",border:"4px solid #4a5568",borderTopColor:"#63b3ed",borderRadius:"50%",animation:"spin 1s linear infinite"},Qr={padding:"1.5rem",backgroundColor:"#742a2a",border:"1px solid #9b2c2c",borderRadius:"8px",color:"#fed7d7"},$r={fontSize:"16px",fontWeight:"600",marginBottom:"0.5rem",color:"#feb2b2"},eo={fontSize:"14px",color:"#fed7d7"},Cu=`
|
|
10
|
+
}`:""),f=D(()=>!n()&&us({containerAttributes:t.displayItemList.containerAttributes,deviceDisplayType:i()})),p=D(()=>cs({containerAttributes:t.displayItemList.containerAttributes,deviceDisplayType:i(),isComposeMode:n()})),a=D(()=>{var E;const w=((E=t.displayItemList.containerAttributes)==null?void 0:E[an])||[],S=fs(g(p));return n()&&!o()||r()||w.length>0||S||l(n(),t.displayItemList.rows,o())}),d=D(()=>[g(u)?s:void 0,g(p).cssClasses].filter(Boolean).join(" ")),y=D(()=>{var S;return{...(((S=t.displayItemList.containerAttributes)==null?void 0:S[an])||[]).some(E=>E.toLowerCase().startsWith("height:"))?{}:{height:o()?"auto":"100%"},display:"flex",flexDirection:"column",...g(p).styles}}),m=D(()=>g(a)?g(d):""),h=D(()=>g(f)?{display:"none"}:g(a)?g(y):{display:"contents"});var _=$a(),A=_e(_);{var P=w=>{var S=ie(),E=q(S);yr(E,()=>"style",!1,(b,I)=>{var T=gr();le(()=>En(T,g(c))),M(I,T)}),M(w,S)};De(A,w=>{g(u)&&w(P)})}var C=Ct(A,2);vr(C,()=>t.children),le(w=>{ht(_,"hidden",g(f)||void 0),St(_,1,Gt(g(m)||void 0)),ne(_,w)},[()=>re(g(h))]),M(e,_),Ne()}var tu=Pe("<div><!></div>");function nu(e,t){Me(t,!0);let n=ae(t,"isComposeMode",3,!1),r=ae(t,"showDropContainers",3,!1),o=ae(t,"isWithinCollection",3,!1),i=ae(t,"deviceDisplayType",3,"Desktop");function s(m,h,_){var P;const A=m&&!_?3:1;return!!((P=h==null?void 0:h.columns)!=null&&P.length)&&h.columns.length>A}const l=D(()=>!n()&&ss({row:t.row,deviceDisplayType:i()})),u=D(()=>r()||is(t.row)||s(n(),t.row,o())),c=D(()=>ls({row:t.row,deviceDisplayType:i(),isComposeMode:n()})),f=D(()=>{var h;const m=ot({deviceDisplayType:i(),componentAttributes:t.row.rowAttributes});return Mn((h=m==null?void 0:m.componentAttributesSpecificToDeviceType)==null?void 0:h[xn])??""}),p=D(()=>g(u)?g(f):""),a=D(()=>g(l)?{display:"none"}:g(u)?g(c):{display:"contents"});var d=tu(),y=_e(d);vr(y,()=>t.children),le(m=>{ht(d,"hidden",g(l)||void 0),St(d,1,Gt(g(p)||void 0)),ne(d,m)},[()=>re(g(a))]),M(e,d),Ne()}const _s=["minWidth","maxWidth","minHeight","maxHeight","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderWidth","borderStyle","borderColor","border","borderRadius","boxShadow","width","height","gap","display","justifyContent","alignItems","flexWrap","alignContent","flexDirection","overflow","overflowX","overflowY","backgroundColor","backgroundImage","backgroundSize","backgroundPosition","backgroundRepeat","opacity","fontFamily","fontSize","fontWeight","fontStyle","color","lineHeight","letterSpacing","textAlign","textDecoration","textTransform"],ru=e=>e!=null&&e!=="",ou=e=>e?_s.reduce((t,n)=>{const r=e[n];return ru(r)&&(t[n]=r),t},{}):{},iu=e=>{if(!e)return;const t={...e};for(const n of _s)delete t[n];return Object.keys(t).length?t:void 0},su=e=>Object.keys(e).length>0,lu=(e,t)=>{const n=(e==null?void 0:e.noContainer)??!1,r=e==null?void 0:e.resolveNoContainer;if(typeof r!="function")return n;try{const o=r(t);if(typeof o=="boolean")return o;console.error(`resolveNoContainer: component "${e==null?void 0:e.id}" returned ${typeof o} instead of a boolean; falling back to noContainer=${n}`)}catch(o){console.error(`resolveNoContainer: component "${e==null?void 0:e.id}" threw; falling back to noContainer=${n}`,o)}return n},au=(e,t)=>{const n=e==null?void 0:e.resolveRendersOwnElement;if(typeof n!="function")return!1;try{const r=n(t);if(typeof r=="boolean")return r;console.error(`resolveRendersOwnElement: component "${e==null?void 0:e.id}" returned ${typeof r} instead of a boolean; falling back to false`)}catch(r){console.error(`resolveRendersOwnElement: component "${e==null?void 0:e.id}" threw; falling back to false`,r)}return!1};var Zr=Pe("<div><!></div>");function bs(e,t){Me(t,!0);const n=D(()=>t.components[mr(t.libraryId,t.componentType)]),r=D(()=>{var _;const h=(_=g(n))==null?void 0:_.card;return h||(console.error(`DisplayComponent: Component with type ${t.componentType}${t.libraryId?` (library "${t.libraryId}")`:""} not found in components`),null)}),o=D(()=>({componentAttributes:t.componentAttributes,styleProps:t.styleProps})),i=D(()=>g(n)?lu(g(n),g(o)):!1),s=D(()=>ou(t.styleProps)),l=D(()=>g(i)?iu(t.styleProps):t.styleProps),u=D(()=>{var h;return Mn((h=t.componentAttributes)==null?void 0:h[xn])}),c=D(()=>g(i)&&su(g(s))),f=D(()=>!g(i)||(g(n)?au(g(n),g(o)):!1)),p=D(()=>!g(c)&&g(f)?g(u):void 0),a=D(()=>({componentAttributes:t.componentAttributes,styleProps:g(l),className:g(p),widgetInstanceProps:t.widgetInstanceProps,mounts:t.mounts}));var d=ie(),y=q(d);{var m=h=>{const _=D(()=>g(r));var A=ie(),P=q(A);{var C=E=>{var b=Zr(),I=_e(b);Un(I,()=>g(_),(T,N)=>{N(T,Gn(()=>g(a)))}),le(T=>{St(b,1,Gt(g(u)||void 0)),ne(b,T)},[()=>re(g(s))]),M(E,b)},w=E=>{var b=Zr(),I=_e(b);Un(I,()=>g(_),(T,N)=>{N(T,Gn(()=>g(a)))}),le(()=>St(b,1,Gt(g(u)))),M(E,b)},S=E=>{var b=ie(),I=q(b);Un(I,()=>g(_),(T,N)=>{N(T,Gn(()=>g(a)))}),M(E,b)};De(P,E=>{g(c)?E(C):!g(f)&&g(u)?E(w,1):E(S,-1)})}M(h,A)};De(y,h=>{g(r)&&h(m)})}M(e,d),Ne()}function Pr(e,t){Me(t,!0);let n=ae(t,"isComposeMode",3,!1),r=ae(t,"isWithinCollection",3,!1),o=ae(t,"showDropContainers",3,!1);const i=D(()=>cn(t.plugins).components);function s(p){if(n()&&p.type===In.DroppableBox)return!1;const{componentAttributesBasedOnDevice:a}=er({col:p,deviceDisplayType:t.deviceDisplayType,isComposeMode:n(),sourceComponentsPlugin:cn(t.plugins)}),d=!!a&&a["hide-component-3-resolutions"]==="true";return!(!n()&&d)}function l(p){const{componentAttributesBasedOnDevice:a,componentStyles:d}=er({col:p,deviceDisplayType:t.deviceDisplayType,isComposeMode:n(),sourceComponentsPlugin:cn(t.plugins)});return{componentAttributes:a,styleProps:d}}function u(p){const a=Ar(p.type);if(!(a!=null&&a.length))return null;const d=p.collection??t.widgetCollections[a];if(!d)throw new Error(`DisplayCollection - Collection with ID ${a} not found in widgetCollections. Available collections: ${Object.keys(t.widgetCollections).join(", ")}`);return!d.collectionRows||!rs(d.collectionRows)?null:d.collectionRows}function c(p){return[...t.ancestorColumnIds??[],p]}function f(p){return ds({componentProps:t.componentProps,ancestorColumnIds:t.ancestorColumnIds,columnId:p})}eu(e,{get displayItemList(){return t.displayItemList},get isComposeMode(){return n()},get showDropContainers(){return o()},get isWithinCollection(){return r()},get deviceDisplayType(){return t.deviceDisplayType},children:(p,a)=>{var d=ie(),y=q(d);bn(y,17,()=>t.displayItemList.rows,m=>m.id,(m,h)=>{nu(m,{get row(){return g(h)},get isComposeMode(){return n()},get showDropContainers(){return o()},get isWithinCollection(){return r()},get deviceDisplayType(){return t.deviceDisplayType},children:(_,A)=>{var P=ie(),C=q(P);bn(C,17,()=>g(h).columns,w=>w.id,(w,S)=>{var E=ie(),b=q(E);{var I=N=>{const Y=D(()=>u(g(S)));var O=ie(),X=q(O);{var it=Le=>{{let st=D(()=>c(g(S).id));Pr(Le,{get displayItemList(){return g(Y)},get isComposeMode(){return n()},isWithinCollection:!0,get widgetCollections(){return t.widgetCollections},get showDropContainers(){return o()},get reduxDeviceDisplayType(){return t.reduxDeviceDisplayType},get plugins(){return t.plugins},get deviceDisplayType(){return t.deviceDisplayType},get componentProps(){return t.componentProps},get mounts(){return t.mounts},get ancestorColumnIds(){return g(st)}})}},tn=Le=>{{let st=D(()=>l(g(S)).componentAttributes),he=D(()=>l(g(S)).styleProps),nn=D(()=>f(g(S).id));bs(Le,{get componentType(){return g(S).type},get libraryId(){return g(S).libraryId},get componentAttributes(){return g(st)},get components(){return g(i)},get styleProps(){return g(he)},get widgetInstanceProps(){return g(nn)},get mounts(){return t.mounts}})}};De(X,Le=>{g(Y)?Le(it):Le(tn,-1)})}M(N,O)},T=D(()=>s(g(S)));De(b,N=>{g(T)&&N(I)})}M(w,E)}),M(_,P)},$$slots:{default:!0}})}),M(p,d)},$$slots:{default:!0}}),Ne()}function wn(e,t){Me(t,!0);var n=ie(),r=q(n);{var o=i=>{Pr(i,{get displayItemList(){return t.displayItemList},get isComposeMode(){return t.isComposeMode},get isWithinCollection(){return t.isWithinCollection},get widgetCollections(){return t.widgetCollections},get showDropContainers(){return t.showDropContainers},get reduxDeviceDisplayType(){return t.reduxDeviceDisplayType},get plugins(){return t.plugins},get deviceDisplayType(){return t.deviceDisplayType},get componentProps(){return t.componentProps},get mounts(){return t.mounts},get ancestorColumnIds(){return t.ancestorColumnIds}})};De(r,i=>{var s,l;(l=(s=t.displayItemList)==null?void 0:s.rows)!=null&&l.length&&i(o)})}M(e,n),Ne()}function ws(e,t){var n=ie(),r=q(n);bn(r,16,()=>t.stylesheets??[],o=>o,(o,i)=>{var s=ie(),l=q(s);yr(l,()=>"style",!1,(u,c)=>{ia(u,()=>({"data-rulecms-library-stylesheet":""}));var f=gr();le(()=>En(f,i)),M(c,f)}),M(o,s)}),M(e,n)}let uu=0;var cu=Pe("<div><!></div>"),Jr=Pe("<!> <!>",1);function Cs(e,t){Me(t,!0);const n=["Phone","Tablet","Desktop"],r=`rulecms-bp-${++uu}`,o=D(()=>t.scopeIdInput??r),i=D(()=>vs(t.displayItemList,t.widgetCollections)),s=D(()=>Ja(g(o)));var l=Jr(),u=q(l);{let a=D(()=>{var d;return(d=t.plugins.sourceComponents)==null?void 0:d.stylesheets});ws(u,{get stylesheets(){return g(a)}})}var c=Ct(u,2);{var f=a=>{wn(a,{get displayItemList(){return t.displayItemList},isComposeMode:!1,isWithinCollection:!1,get widgetCollections(){return t.widgetCollections},showDropContainers:!1,reduxDeviceDisplayType:"desktop",deviceDisplayType:"Desktop",get plugins(){return t.plugins},get componentProps(){return t.componentProps},get mounts(){return t.mounts}})},p=a=>{var d=Jr(),y=q(d);yr(y,()=>"style",!1,(h,_)=>{var A=gr();le(()=>En(A,g(s))),M(_,A)});var m=Ct(y,2);bn(m,16,()=>n,h=>h,(h,_)=>{var A=cu(),P=_e(A);wn(P,{get displayItemList(){return t.displayItemList},isComposeMode:!1,isWithinCollection:!1,get widgetCollections(){return t.widgetCollections},showDropContainers:!1,reduxDeviceDisplayType:"desktop",get deviceDisplayType(){return _},get plugins(){return t.plugins},get componentProps(){return t.componentProps},get mounts(){return t.mounts}}),le(C=>St(A,1,C),[()=>`${g(o)}-${_.toLowerCase()}`]),M(h,A)}),M(a,d)};De(c,a=>{g(i)?a(p,-1):a(f)})}M(e,l),Ne()}function fu(e,t,n){if(e)return"Phone";if(t)return"Tablet";const r=(n==null?void 0:n.toLowerCase())||"desktop";return r==="phone"?"Phone":r==="tablet"?"Tablet":"Desktop"}const du=`(max-width: ${Er})`,pu=`(max-width: ${Tr})`;var hu=Pe("<!> <!>",1);function As(e,t){Me(t,!0);let n=oe("Desktop"),r,o;function i(){W(n,fu((r==null?void 0:r.matches)??!1,(o==null?void 0:o.matches)??!1,t.reduxDeviceDisplayType),!0)}dr(()=>(typeof matchMedia=="function"&&(r=matchMedia(du),o=matchMedia(pu),r.addEventListener("change",i),o.addEventListener("change",i)),i(),()=>{r==null||r.removeEventListener("change",i),o==null||o.removeEventListener("change",i)}));var s=hu(),l=q(s);{var u=f=>{{let p=D(()=>{var a;return(a=t.plugins.sourceComponents)==null?void 0:a.stylesheets});ws(f,{get stylesheets(){return g(p)}})}};De(l,f=>{t.isWithinCollection||f(u)})}var c=Ct(l,2);wn(c,{get displayItemList(){return t.displayItemList},get isComposeMode(){return t.isComposeMode},get isWithinCollection(){return t.isWithinCollection},get widgetCollections(){return t.widgetCollections},get showDropContainers(){return t.showDropContainers},get reduxDeviceDisplayType(){return t.reduxDeviceDisplayType},get deviceDisplayType(){return g(n)},get plugins(){return t.plugins},get componentProps(){return t.componentProps},get mounts(){return t.mounts}}),M(e,s),Ne()}function gu(e){const t={};return Object.entries(e).forEach(([n,r])=>{const o={...r};if(o.itemList)try{o.collectionRows=typeof o.itemList=="string"?JSON.parse(o.itemList):o.itemList}catch(s){console.error(`Failed to parse itemList for collection ${n}:`,s),o.collectionRows={rows:[]}}let i=`${o.name}$${n}`;o.parentId&&(i=`${i}@${o.parentId}`),t[i]=o}),t}function vu(e){return typeof e.itemList=="string"?JSON.parse(e.itemList):e.itemList}function kr(e){return{displayItemList:vu(e.widget),widgetCollections:gu(e.childCollections),...e.libraries?{libraries:e.libraries}:{}}}function yu(e){const t=e.registry??en(),n=Dn({displayItemList:e.displayItemList,widgetCollections:e.widgetCollections});return t.resolveSync({registrations:e.libraries,referenced:n})}function mu(e){const t=e.registry??en(),n=Dn({displayItemList:e.displayItemList,widgetCollections:e.widgetCollections});return t.resolve({registrations:e.libraries,referenced:n})}const _u={display:"flex",justifyContent:"center",alignItems:"center",padding:"3rem",color:"#e2e8f0"},bu={display:"flex",alignItems:"center",gap:"1rem"},wu={width:"40px",height:"40px",border:"4px solid #4a5568",borderTopColor:"#63b3ed",borderRadius:"50%",animation:"spin 1s linear infinite"},Qr={padding:"1.5rem",backgroundColor:"#742a2a",border:"1px solid #9b2c2c",borderRadius:"8px",color:"#fed7d7"},$r={fontSize:"16px",fontWeight:"600",marginBottom:"0.5rem",color:"#feb2b2"},eo={fontSize:"14px",color:"#fed7d7"},Cu=`
|
|
11
11
|
@keyframes spin {
|
|
12
12
|
from {
|
|
13
13
|
transform: rotate(0deg);
|
|
@@ -16,4 +16,4 @@ ${g(u)}
|
|
|
16
16
|
transform: rotate(360deg);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
`,Au="data-rulecms-published-key";var Su=Pe("<div><div><div></div></div></div>"),Eu=Pe("<div><div>Error Loading Widget</div> <div> </div></div>"),Tu=Pe("<div><div>No Widget Data</div> <div>No widget data available</div></div>"),Iu=Pe('<span style="display: contents"><!></span>');function Du(e,t){Me(t,!0);let n=ae(t,"mode",3,"client-fetch");const r=zn.getContext(Sr);let o=oe(!1),i=oe(null),s=oe(null),l=oe(null);const u=D(()=>n()==="pre-fetched"),c=D(()=>({sourceComponents:g(l)??void 0}));let f=null,p=null,a=!1;function d(){if(!g(s)){W(l,null);return}const b=t.libraries??(r==null?void 0:r.libraries),I=r==null?void 0:r.libraryRegistry,T=yu({displayItemList:g(s).displayItemList,widgetCollections:g(s).widgetCollections,libraries:b,registry:I});if(T){W(l,T,!0);return}mu({displayItemList:g(s).displayItemList,widgetCollections:g(s).widgetCollections,libraries:b,registry:I}).then(N=>{W(l,N,!0)})}function y(){g(s)&&gs({componentProps:t.componentProps,displayItemList:g(s).displayItemList,widgetCollections:g(s).widgetCollections,publishedKey:t.publishedKey})}function m(){if(a||typeof document>"u")return;const b="rulecms-widget-spinner-styles";if(!document.getElementById(b)){const I=document.createElement("style");I.id=b,I.textContent=Cu,document.head.appendChild(I)}a=!0}function h(){const b=t.token??(r==null?void 0:r.token),I=t.endpoint??(r==null?void 0:r.endpoint);if(!t.publishedKey||!b){W(i,t.publishedKey?"Token is required. Provide it either directly as a prop (`token`) or via RuleCMSWidgetProvider.":tt(b)?"Widget key is required":"Published key is required",!0),W(s,null);return}const T=`${t.publishedKey}|${b}`;if(p===T&&g(s)){d();return}f==null||f.abort(),f=new AbortController;const N=f.signal;p=T,W(o,!0),W(i,null);const Y=wr({publishedKey:t.publishedKey,token:b,endpoint:I});fetch(Y,{method:"GET",headers:{"Content-Type":"application/json"},...tt(b)?{cache:"no-store"}:{},signal:N}).then(async O=>{if(O.ok){const X=await O.json();X.success?(W(s,kr(X.data),!0),W(i,null),d(),y()):(W(i,"Failed to fetch widget data"),W(s,null))}else{const X=await O.json().catch(()=>({error:"Unknown error"}));W(i,X.error||`Request failed with status ${O.status}`,!0),W(s,null)}}).catch(O=>{O instanceof DOMException&&O.name==="AbortError"||(console.error("Error fetching widget:",O),W(i,"Failed to fetch widget"),W(s,null))}).finally(()=>{W(o,!1)})}function _(){if(n()==="pre-fetched"){W(s,t.initialData??null,!0),W(o,!1),W(i,null),d(),y();return}m(),h()}dr(()=>(t.publishedKey,t.token,t.endpoint,n(),t.initialData,t.libraries,t.componentProps,zn.untrack(()=>_()),()=>{f==null||f.abort()}));var A=Iu(),P=_e(A);{var C=b=>{var I=Su(),T=_e(I),N=_e(T);le((Y,O,X)=>{ne(I,Y),ne(T,O),ne(N,X)},[()=>re(_u),()=>re(bu),()=>re(wu)]),M(b,I)},w=b=>{var I=Eu(),T=_e(I),N=Ct(T,2),Y=_e(N);le((O,X,it)=>{ne(I,O),ne(T,X),ne(N,it),En(Y,g(i))},[()=>re(Qr),()=>re($r),()=>re(eo)]),M(b,I)},S=b=>{var I=Tu(),T=_e(I),N=Ct(T,2);le((Y,O,X)=>{ne(I,Y),ne(T,O),ne(N,X)},[()=>re(Qr),()=>re($r),()=>re(eo)]),M(b,I)},E=b=>{var I=ie(),T=q(I);{var N=O=>{Cs(O,{get displayItemList(){return g(s).displayItemList},get widgetCollections(){return g(s).widgetCollections},get plugins(){return g(c)},get componentProps(){return t.componentProps}})},Y=O=>{As(O,{get displayItemList(){return g(s).displayItemList},isComposeMode:!1,isWithinCollection:!1,get widgetCollections(){return g(s).widgetCollections},showDropContainers:!1,reduxDeviceDisplayType:"desktop",get plugins(){return g(c)},get componentProps(){return t.componentProps}})};De(T,O=>{g(u)?O(N):O(Y,-1)})}M(b,I)};De(P,b=>{n()!=="pre-fetched"&&g(o)?b(C):n()!=="pre-fetched"&&g(i)?b(w,1):n()!=="pre-fetched"&&!g(s)?b(S,2):g(l)&&g(s)&&b(E,3)})}le(()=>ht(A,"data-rulecms-published-key",t.publishedKey)),M(e,A),Ne()}class Nt extends Error{constructor(n,r){super(n);ge(this,"status");this.name="FetchRuleCMSWidgetError",this.status=r}}async function Pu(e){const{publishedKey:t,token:n,endpoint:r,fetchOptions:o}=e;if(!t)throw new Nt(tt(n)?"Widget key is required":"Published key is required");if(!n)throw new Nt("Token is required");const i=wr({publishedKey:t,token:n,endpoint:r}),s=await fetch(i,{method:"GET",headers:{"Content-Type":"application/json"},...tt(n)?{cache:"no-store"}:{},...o});if(!s.ok){const u=await s.json().catch(()=>({error:"Unknown error"}));throw new Nt(u.error||`Request failed with status ${s.status}`,s.status)}const l=await s.json();if(!l.success)throw new Nt("Failed to fetch widget data");return kr(l.data)}async function ku(e){const{data:t,libraries:n}=e,r=Dn({displayItemList:t.displayItemList,widgetCollections:t.widgetCollections});return en().resolve({registrations:n,referenced:r})}exports.AlignContentTypes=fa;exports.BreakpointVariantRender=Cs;exports.COLLECTION_TYPE_PREFIX=br;exports.COMPONENT_PROPS_PATH_SEPARATOR=Nn;exports.CSS_CLASSES_ATTRIBUTE_NAME=xn;exports.CSS_VARIABLE_NAME_MAX_LENGTH=vi;exports.CSS_VARIABLE_NAME_PATTERN=gi;exports.DEFAULT_CLOUDINARY_CLOUD_NAME=ui;exports.DEFAULT_LIBRARY_ID=Tt;exports.DEFAULT_ROW_GAP=os;exports.DEV_CLIENT_TOKEN_PREFIX=Xo;exports.DEV_WIDGET_API_PATH=$o;exports.DeviceDisplayTypes=da;exports.DisplayComponent=bs;exports.DisplayItemTypes=In;exports.DragItemIdPrefixTypes=_r;exports.EMBEDDED_KEY_SEPARATOR=si;exports.FLEX_LAYOUT_STYLE_KEYS_THAT_DERIVE_DISPLAY=Oi;exports.FetchRuleCMSWidgetError=Nt;exports.HIDE_WIDGET_ATTRIBUTE_NAME=Dr;exports.JustifyContentTypes=$n;exports.PUBLISHED_KEY_SEPARATOR=ii;exports.PUBLISHED_WIDGET_API_PATH=Qo;exports.PageViewTypes=ca;exports.RULECMS_API_ORIGIN=Zo;exports.RULECMS_PUBLISHED_KEY_ATTRIBUTE=Au;exports.RULECMS_WIDGET_CONTEXT_KEY=Sr;exports.RenderComponents=As;exports.RenderComponentsForDevice=wn;exports.RenderComponentsInner=Pr;exports.RuleCMSWidget=Du;exports.RuleCMSWidgetProvider=wa;exports.WIDGET_ATTRIBUTES_IGNORED_IN_COMPOSE_MODE=as;exports.WIDGET_CACHE_API_ORIGIN=Jo;exports.alignContentAllowlist=Li;exports.alignItemsAllowlist=Pi;exports.backgroundPositionAllowlist=Mi;exports.backgroundRepeatAllowlist=Ni;exports.backgroundSizeAllowlist=xi;exports.borderStyleKeywords=Wi;exports.boxSpacingSideKeys=_i;exports.boxSpacingStyleAttributeEntries=Ba;exports.buildCloudinaryBackgroundUrl=hi;exports.buildWidgetFetchUrl=wr;exports.collectComponentInstancePaths=ps;exports.collectReferencedLibraryIds=Dn;exports.composeSourceComponentsPlugin=qo;exports.createComponentLibraryRegistry=en;exports.cssAttrArrayKey=an;exports.defaultPageWidth=ai;exports.deriveDisplayFlexIfNeeded=es;exports.desktopModeWidth=Ca;exports.fetchRuleCMSWidget=Pu;exports.findUnmatchedComponentPropsKeys=hs;exports.flexDirectionAllowlist=Ri;exports.flexWrapAllowlist=ki;exports.fontFamilyAllowlist=Ci;exports.fontStyleAllowlist=Si;exports.fontWeightAllowlist=Ai;exports.formatBackgroundImageStyles=Hi;exports.formatBorderStyles=Gi;exports.formatBoxShadowStyles=Yi;exports.formatBoxSpacingStyles=zi;exports.formatCssColorStyles=qi;exports.formatCssColorValue=Ln;exports.formatCssEnumStyles=Xi;exports.formatCssLengthStyles=Zi;exports.formatCssVariable=Ce;exports.formatCssVariableStyles=Na;exports.formatLineHeightStyles=Ji;exports.formatObjectStyleAttribute=$i;exports.formatOpacityStyles=Qi;exports.formatSpacingSideValue=rt;exports.generatePublishedKey=li;exports.generatePublishedKeyForEmbedded=ma;exports.getCollectionIdForCollectionType=Ar;exports.getColumnAttributes=Ft;exports.getComponentAttributesAndStyles=er;exports.getComponentsPluginFromPlugins=cn;exports.getCssVariableFromLeaf=K;exports.getDefaultDimensionAttributes=ts;exports.getDeviceTypeBasedAttributes=ot;exports.getDragItemId=pa;exports.getDragItemPrefixAndId=ti;exports.getIdAndPrefix=ni;exports.getMergedAttributes=ns;exports.getNameAndInstanceIdFromWidgetKey=ha;exports.getNameFromWidgetKey=ga;exports.getWidgetKeyForCollection=ri;exports.getWidgetKeyForCollectionWithPrefix=va;exports.getWidgetKeyForPublishedCollection=oi;exports.getWidgetKeyForPublishedCollectionWithPrefix=ya;exports.hasBoxShadowLeaf=Bi;exports.hasDeviceDivergentValues=vs;exports.hasInvalidCssVariable=ke;exports.hasItems=rs;exports.incrementVersion=_a;exports.isBackgroundImageValue=yi;exports.isBorderStyleValue=Fi;exports.isBorderValue=Vi;exports.isBoxShadowValue=ji;exports.isBoxSpacingValue=bi;exports.isCloudinaryCloudName=fi;exports.isCloudinaryPublicId=ci;exports.isCloudinaryTransformationString=pi;exports.isCssColorValue=kn;exports.isCssEnumValue=wi;exports.isCssVariableName=Ir;exports.isDevClientToken=tt;exports.isLineHeightValue=Ui;exports.isOpacityValue=Ki;exports.isRowHiddenForDevice=ss;exports.isSafeImageUrl=di;exports.isSpacingSideValue=nt;exports.isWidgetHiddenForDevice=us;exports.justifyContentAllowlist=Di;exports.normalizeCssClasses=Mn;exports.objectStyleAttributeRegistry=Rn;exports.overflowAllowlist=un;exports.phoneModeWidth=Er;exports.prepareRuleCMSWidgetData=kr;exports.resolveKey=mr;exports.resolveRowStyles=ls;exports.resolveWidgetApiOrigin=ei;exports.resolveWidgetContainerStyles=cs;exports.resolveWidgetInstanceProps=ds;exports.resolveWidgetLibraries=ku;exports.rowBasedPropertiesAreAssigned=is;exports.spacingKeywords=Pn;exports.spacingLengthUnits=mi;exports.tabletModeWidth=Tr;exports.textAlignAllowlist=Ei;exports.textDecorationAllowlist=Ti;exports.textTransformAllowlist=Ii;exports.toStyleAttr=re;exports.typeHasPrefix=Cr;exports.warnUnmatchedComponentProps=gs;exports.widgetBasedPropertiesAreAssigned=fs;
|
|
19
|
+
`,Au="data-rulecms-published-key";var Su=Pe("<div><div><div></div></div></div>"),Eu=Pe("<div><div>Error Loading Widget</div> <div> </div></div>"),Tu=Pe("<div><div>No Widget Data</div> <div>No widget data available</div></div>"),Iu=Pe('<span style="display: contents"><!></span>');function Du(e,t){Me(t,!0);let n=ae(t,"mode",3,"client-fetch");const r=zn.getContext(Sr);let o=oe(!1),i=oe(null),s=oe(null),l=oe(null);const u=D(()=>n()==="pre-fetched"),c=D(()=>({sourceComponents:g(l)??void 0}));let f=null,p=null,a=!1;function d(){if(!g(s)){W(l,null);return}const b=t.libraries??(r==null?void 0:r.libraries),I=r==null?void 0:r.libraryRegistry,T=yu({displayItemList:g(s).displayItemList,widgetCollections:g(s).widgetCollections,libraries:b,registry:I});if(T){W(l,T,!0);return}mu({displayItemList:g(s).displayItemList,widgetCollections:g(s).widgetCollections,libraries:b,registry:I}).then(N=>{W(l,N,!0)})}function y(){g(s)&&gs({componentProps:t.componentProps,displayItemList:g(s).displayItemList,widgetCollections:g(s).widgetCollections,publishedKey:t.publishedKey})}function m(){if(a||typeof document>"u")return;const b="rulecms-widget-spinner-styles";if(!document.getElementById(b)){const I=document.createElement("style");I.id=b,I.textContent=Cu,document.head.appendChild(I)}a=!0}function h(){const b=t.token??(r==null?void 0:r.token),I=t.endpoint??(r==null?void 0:r.endpoint);if(!t.publishedKey||!b){W(i,t.publishedKey?"Token is required. Provide it either directly as a prop (`token`) or via RuleCMSWidgetProvider.":tt(b)?"Widget key is required":"Published key is required",!0),W(s,null);return}const T=`${t.publishedKey}|${b}`;if(p===T&&g(s)){d();return}f==null||f.abort(),f=new AbortController;const N=f.signal;p=T,W(o,!0),W(i,null);const Y=wr({publishedKey:t.publishedKey,token:b,endpoint:I});fetch(Y,{method:"GET",headers:{"Content-Type":"application/json"},...tt(b)?{cache:"no-store"}:{},signal:N}).then(async O=>{if(O.ok){const X=await O.json();X.success?(W(s,kr(X.data),!0),W(i,null),d(),y()):(W(i,"Failed to fetch widget data"),W(s,null))}else{const X=await O.json().catch(()=>({error:"Unknown error"}));W(i,X.error||`Request failed with status ${O.status}`,!0),W(s,null)}}).catch(O=>{O instanceof DOMException&&O.name==="AbortError"||(console.error("Error fetching widget:",O),W(i,"Failed to fetch widget"),W(s,null))}).finally(()=>{W(o,!1)})}function _(){if(n()==="pre-fetched"){W(s,t.initialData??null,!0),W(o,!1),W(i,null),d(),y();return}m(),h()}dr(()=>(t.publishedKey,t.token,t.endpoint,n(),t.initialData,t.libraries,t.componentProps,zn.untrack(()=>_()),()=>{f==null||f.abort()}));var A=Iu(),P=_e(A);{var C=b=>{var I=Su(),T=_e(I),N=_e(T);le((Y,O,X)=>{ne(I,Y),ne(T,O),ne(N,X)},[()=>re(_u),()=>re(bu),()=>re(wu)]),M(b,I)},w=b=>{var I=Eu(),T=_e(I),N=Ct(T,2),Y=_e(N);le((O,X,it)=>{ne(I,O),ne(T,X),ne(N,it),En(Y,g(i))},[()=>re(Qr),()=>re($r),()=>re(eo)]),M(b,I)},S=b=>{var I=Tu(),T=_e(I),N=Ct(T,2);le((Y,O,X)=>{ne(I,Y),ne(T,O),ne(N,X)},[()=>re(Qr),()=>re($r),()=>re(eo)]),M(b,I)},E=b=>{var I=ie(),T=q(I);{var N=O=>{Cs(O,{get displayItemList(){return g(s).displayItemList},get widgetCollections(){return g(s).widgetCollections},get plugins(){return g(c)},get componentProps(){return t.componentProps},get mounts(){return t.mounts}})},Y=O=>{As(O,{get displayItemList(){return g(s).displayItemList},isComposeMode:!1,isWithinCollection:!1,get widgetCollections(){return g(s).widgetCollections},showDropContainers:!1,reduxDeviceDisplayType:"desktop",get plugins(){return g(c)},get componentProps(){return t.componentProps},get mounts(){return t.mounts}})};De(T,O=>{g(u)?O(N):O(Y,-1)})}M(b,I)};De(P,b=>{n()!=="pre-fetched"&&g(o)?b(C):n()!=="pre-fetched"&&g(i)?b(w,1):n()!=="pre-fetched"&&!g(s)?b(S,2):g(l)&&g(s)&&b(E,3)})}le(()=>ht(A,"data-rulecms-published-key",t.publishedKey)),M(e,A),Ne()}class Nt extends Error{constructor(n,r){super(n);ge(this,"status");this.name="FetchRuleCMSWidgetError",this.status=r}}async function Pu(e){const{publishedKey:t,token:n,endpoint:r,fetchOptions:o}=e;if(!t)throw new Nt(tt(n)?"Widget key is required":"Published key is required");if(!n)throw new Nt("Token is required");const i=wr({publishedKey:t,token:n,endpoint:r}),s=await fetch(i,{method:"GET",headers:{"Content-Type":"application/json"},...tt(n)?{cache:"no-store"}:{},...o});if(!s.ok){const u=await s.json().catch(()=>({error:"Unknown error"}));throw new Nt(u.error||`Request failed with status ${s.status}`,s.status)}const l=await s.json();if(!l.success)throw new Nt("Failed to fetch widget data");return kr(l.data)}async function ku(e){const{data:t,libraries:n}=e,r=Dn({displayItemList:t.displayItemList,widgetCollections:t.widgetCollections});return en().resolve({registrations:n,referenced:r})}exports.AlignContentTypes=fa;exports.BreakpointVariantRender=Cs;exports.COLLECTION_TYPE_PREFIX=br;exports.COMPONENT_PROPS_PATH_SEPARATOR=Nn;exports.CSS_CLASSES_ATTRIBUTE_NAME=xn;exports.CSS_VARIABLE_NAME_MAX_LENGTH=vi;exports.CSS_VARIABLE_NAME_PATTERN=gi;exports.DEFAULT_CLOUDINARY_CLOUD_NAME=ui;exports.DEFAULT_LIBRARY_ID=Tt;exports.DEFAULT_ROW_GAP=os;exports.DEV_CLIENT_TOKEN_PREFIX=Xo;exports.DEV_WIDGET_API_PATH=$o;exports.DeviceDisplayTypes=da;exports.DisplayComponent=bs;exports.DisplayItemTypes=In;exports.DragItemIdPrefixTypes=_r;exports.EMBEDDED_KEY_SEPARATOR=si;exports.FLEX_LAYOUT_STYLE_KEYS_THAT_DERIVE_DISPLAY=Oi;exports.FetchRuleCMSWidgetError=Nt;exports.HIDE_WIDGET_ATTRIBUTE_NAME=Dr;exports.JustifyContentTypes=$n;exports.PUBLISHED_KEY_SEPARATOR=ii;exports.PUBLISHED_WIDGET_API_PATH=Qo;exports.PageViewTypes=ca;exports.RULECMS_API_ORIGIN=Zo;exports.RULECMS_PUBLISHED_KEY_ATTRIBUTE=Au;exports.RULECMS_WIDGET_CONTEXT_KEY=Sr;exports.RenderComponents=As;exports.RenderComponentsForDevice=wn;exports.RenderComponentsInner=Pr;exports.RuleCMSWidget=Du;exports.RuleCMSWidgetProvider=wa;exports.WIDGET_ATTRIBUTES_IGNORED_IN_COMPOSE_MODE=as;exports.WIDGET_CACHE_API_ORIGIN=Jo;exports.alignContentAllowlist=Li;exports.alignItemsAllowlist=Pi;exports.backgroundPositionAllowlist=Mi;exports.backgroundRepeatAllowlist=Ni;exports.backgroundSizeAllowlist=xi;exports.borderStyleKeywords=Wi;exports.boxSpacingSideKeys=_i;exports.boxSpacingStyleAttributeEntries=Ba;exports.buildCloudinaryBackgroundUrl=hi;exports.buildWidgetFetchUrl=wr;exports.collectComponentInstancePaths=ps;exports.collectReferencedLibraryIds=Dn;exports.composeSourceComponentsPlugin=qo;exports.createComponentLibraryRegistry=en;exports.cssAttrArrayKey=an;exports.defaultPageWidth=ai;exports.deriveDisplayFlexIfNeeded=es;exports.desktopModeWidth=Ca;exports.fetchRuleCMSWidget=Pu;exports.findUnmatchedComponentPropsKeys=hs;exports.flexDirectionAllowlist=Ri;exports.flexWrapAllowlist=ki;exports.fontFamilyAllowlist=Ci;exports.fontStyleAllowlist=Si;exports.fontWeightAllowlist=Ai;exports.formatBackgroundImageStyles=Hi;exports.formatBorderStyles=Gi;exports.formatBoxShadowStyles=Yi;exports.formatBoxSpacingStyles=zi;exports.formatCssColorStyles=qi;exports.formatCssColorValue=Ln;exports.formatCssEnumStyles=Xi;exports.formatCssLengthStyles=Zi;exports.formatCssVariable=Ce;exports.formatCssVariableStyles=Na;exports.formatLineHeightStyles=Ji;exports.formatObjectStyleAttribute=$i;exports.formatOpacityStyles=Qi;exports.formatSpacingSideValue=rt;exports.generatePublishedKey=li;exports.generatePublishedKeyForEmbedded=ma;exports.getCollectionIdForCollectionType=Ar;exports.getColumnAttributes=Ft;exports.getComponentAttributesAndStyles=er;exports.getComponentsPluginFromPlugins=cn;exports.getCssVariableFromLeaf=K;exports.getDefaultDimensionAttributes=ts;exports.getDeviceTypeBasedAttributes=ot;exports.getDragItemId=pa;exports.getDragItemPrefixAndId=ti;exports.getIdAndPrefix=ni;exports.getMergedAttributes=ns;exports.getNameAndInstanceIdFromWidgetKey=ha;exports.getNameFromWidgetKey=ga;exports.getWidgetKeyForCollection=ri;exports.getWidgetKeyForCollectionWithPrefix=va;exports.getWidgetKeyForPublishedCollection=oi;exports.getWidgetKeyForPublishedCollectionWithPrefix=ya;exports.hasBoxShadowLeaf=Bi;exports.hasDeviceDivergentValues=vs;exports.hasInvalidCssVariable=ke;exports.hasItems=rs;exports.incrementVersion=_a;exports.isBackgroundImageValue=yi;exports.isBorderStyleValue=Fi;exports.isBorderValue=Vi;exports.isBoxShadowValue=ji;exports.isBoxSpacingValue=bi;exports.isCloudinaryCloudName=fi;exports.isCloudinaryPublicId=ci;exports.isCloudinaryTransformationString=pi;exports.isCssColorValue=kn;exports.isCssEnumValue=wi;exports.isCssVariableName=Ir;exports.isDevClientToken=tt;exports.isLineHeightValue=Ui;exports.isOpacityValue=Ki;exports.isRowHiddenForDevice=ss;exports.isSafeImageUrl=di;exports.isSpacingSideValue=nt;exports.isWidgetHiddenForDevice=us;exports.justifyContentAllowlist=Di;exports.normalizeCssClasses=Mn;exports.objectStyleAttributeRegistry=Rn;exports.overflowAllowlist=un;exports.phoneModeWidth=Er;exports.prepareRuleCMSWidgetData=kr;exports.resolveKey=mr;exports.resolveRowStyles=ls;exports.resolveWidgetApiOrigin=ei;exports.resolveWidgetContainerStyles=cs;exports.resolveWidgetInstanceProps=ds;exports.resolveWidgetLibraries=ku;exports.rowBasedPropertiesAreAssigned=is;exports.spacingKeywords=Pn;exports.spacingLengthUnits=mi;exports.tabletModeWidth=Tr;exports.textAlignAllowlist=Ei;exports.textDecorationAllowlist=Ti;exports.textTransformAllowlist=Ii;exports.toStyleAttr=re;exports.typeHasPrefix=Cr;exports.warnUnmatchedComponentProps=gs;exports.widgetBasedPropertiesAreAssigned=fs;
|
package/dist/index.d.ts
CHANGED
|
@@ -937,6 +937,12 @@ export declare interface LibraryCardInputs {
|
|
|
937
937
|
};
|
|
938
938
|
className?: string;
|
|
939
939
|
widgetInstanceProps?: WidgetInstanceProps;
|
|
940
|
+
/**
|
|
941
|
+
* Host-supplied map of mount name → Svelte component. Only `r-mount`
|
|
942
|
+
* reads this. Absent in the composer, and absent whenever the host
|
|
943
|
+
* passed no `mounts` on `RuleCMSWidget`.
|
|
944
|
+
*/
|
|
945
|
+
mounts?: MountsMap;
|
|
940
946
|
}
|
|
941
947
|
|
|
942
948
|
export declare type LibraryComponentEntry = {
|
|
@@ -962,6 +968,15 @@ export declare type LineHeightValue = ({
|
|
|
962
968
|
value: number;
|
|
963
969
|
} & CssVariableCarrier) | SpacingSideValue;
|
|
964
970
|
|
|
971
|
+
/**
|
|
972
|
+
* Host-app components `r-mount` can render, keyed by the name an author
|
|
973
|
+
* types in the composer. The name is a map lookup, not a string that
|
|
974
|
+
* becomes code. A miss is a placeholder.
|
|
975
|
+
*/
|
|
976
|
+
export declare type MountsMap = {
|
|
977
|
+
[name: string]: Component;
|
|
978
|
+
};
|
|
979
|
+
|
|
965
980
|
export declare type NoContainerResolverContext = {
|
|
966
981
|
componentAttributes?: {
|
|
967
982
|
[key: string]: any;
|
package/dist/index.js
CHANGED
|
@@ -3940,7 +3940,8 @@ function qa(e, t) {
|
|
|
3940
3940
|
componentAttributes: t.componentAttributes,
|
|
3941
3941
|
styleProps: g(l),
|
|
3942
3942
|
className: g(p),
|
|
3943
|
-
widgetInstanceProps: t.widgetInstanceProps
|
|
3943
|
+
widgetInstanceProps: t.widgetInstanceProps,
|
|
3944
|
+
mounts: t.mounts
|
|
3944
3945
|
}));
|
|
3945
3946
|
var d = oe(), y = q(d);
|
|
3946
3947
|
{
|
|
@@ -4100,6 +4101,9 @@ function qo(e, t) {
|
|
|
4100
4101
|
get componentProps() {
|
|
4101
4102
|
return t.componentProps;
|
|
4102
4103
|
},
|
|
4104
|
+
get mounts() {
|
|
4105
|
+
return t.mounts;
|
|
4106
|
+
},
|
|
4103
4107
|
get ancestorColumnIds() {
|
|
4104
4108
|
return g(nt);
|
|
4105
4109
|
}
|
|
@@ -4126,6 +4130,9 @@ function qo(e, t) {
|
|
|
4126
4130
|
},
|
|
4127
4131
|
get widgetInstanceProps() {
|
|
4128
4132
|
return g($t);
|
|
4133
|
+
},
|
|
4134
|
+
get mounts() {
|
|
4135
|
+
return t.mounts;
|
|
4129
4136
|
}
|
|
4130
4137
|
});
|
|
4131
4138
|
}
|
|
@@ -4183,6 +4190,9 @@ function Un(e, t) {
|
|
|
4183
4190
|
get componentProps() {
|
|
4184
4191
|
return t.componentProps;
|
|
4185
4192
|
},
|
|
4193
|
+
get mounts() {
|
|
4194
|
+
return t.mounts;
|
|
4195
|
+
},
|
|
4186
4196
|
get ancestorColumnIds() {
|
|
4187
4197
|
return t.ancestorColumnIds;
|
|
4188
4198
|
}
|
|
@@ -4249,6 +4259,9 @@ function Ja(e, t) {
|
|
|
4249
4259
|
},
|
|
4250
4260
|
get componentProps() {
|
|
4251
4261
|
return t.componentProps;
|
|
4262
|
+
},
|
|
4263
|
+
get mounts() {
|
|
4264
|
+
return t.mounts;
|
|
4252
4265
|
}
|
|
4253
4266
|
});
|
|
4254
4267
|
}, p = (a) => {
|
|
@@ -4279,6 +4292,9 @@ function Ja(e, t) {
|
|
|
4279
4292
|
},
|
|
4280
4293
|
get componentProps() {
|
|
4281
4294
|
return t.componentProps;
|
|
4295
|
+
},
|
|
4296
|
+
get mounts() {
|
|
4297
|
+
return t.mounts;
|
|
4282
4298
|
}
|
|
4283
4299
|
}), le((C) => wt(A, 1, C), [() => `${g(o)}-${_.toLowerCase()}`]), M(h, A);
|
|
4284
4300
|
}), M(a, d);
|
|
@@ -4355,6 +4371,9 @@ function nu(e, t) {
|
|
|
4355
4371
|
},
|
|
4356
4372
|
get componentProps() {
|
|
4357
4373
|
return t.componentProps;
|
|
4374
|
+
},
|
|
4375
|
+
get mounts() {
|
|
4376
|
+
return t.mounts;
|
|
4358
4377
|
}
|
|
4359
4378
|
}), M(e, s), Me();
|
|
4360
4379
|
}
|
|
@@ -4593,6 +4612,9 @@ function Ru(e, t) {
|
|
|
4593
4612
|
},
|
|
4594
4613
|
get componentProps() {
|
|
4595
4614
|
return t.componentProps;
|
|
4615
|
+
},
|
|
4616
|
+
get mounts() {
|
|
4617
|
+
return t.mounts;
|
|
4596
4618
|
}
|
|
4597
4619
|
});
|
|
4598
4620
|
}, Y = (O) => {
|
|
@@ -4612,6 +4634,9 @@ function Ru(e, t) {
|
|
|
4612
4634
|
},
|
|
4613
4635
|
get componentProps() {
|
|
4614
4636
|
return t.componentProps;
|
|
4637
|
+
},
|
|
4638
|
+
get mounts() {
|
|
4639
|
+
return t.mounts;
|
|
4615
4640
|
}
|
|
4616
4641
|
});
|
|
4617
4642
|
};
|
package/package.json
CHANGED