@blocklet/pages-kit-inner-components 0.7.22 → 0.7.23
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/lib/cjs/add-component.js +13 -13
- package/lib/cjs/chunks/{draft-data-e1KnFlxv.js → draft-data-BYzGfJ7S.js} +1 -1
- package/lib/cjs/chunks/{home-BTdS1u5a.js → home-FbBl1G79.js} +2 -2
- package/lib/cjs/chunks/{index-DoTEfRgc.js → index-B-TdKJtn.js} +20 -20
- package/lib/cjs/chunks/{publish-button-JfvmgBSI.js → publish-button-JUoM34Aa.js} +1 -1
- package/lib/cjs/chunks/site-state-oC_X_C59.js +1 -0
- package/lib/cjs/chunks/state-BBnuCgyl.js +1 -0
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +2 -2
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +1 -1
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/add-component.js +102 -102
- package/lib/es/chunks/{draft-data-DRdPzuGm.js → draft-data-fMhhz4sh.js} +1 -1
- package/lib/es/chunks/{home-D3e7ljVw.js → home-BujeKjPf.js} +3 -3
- package/lib/es/chunks/{index-Dci_IgHn.js → index-BZ1MijZ6.js} +297 -297
- package/lib/es/chunks/{publish-button-CtlD3O0E.js → publish-button-BO4u_Nxb.js} +3 -3
- package/lib/es/chunks/{site-state-NvsHZBJX.js → site-state-D8_lRJeG.js} +510 -494
- package/lib/es/chunks/{state-qDCrgEMQ.js → state-CMRCtF-D.js} +47 -42
- package/lib/es/home.js +3 -3
- package/lib/es/locales.js +2 -0
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +1 -1
- package/lib/es/site-state.js +1 -1
- package/package.json +3 -3
- package/lib/cjs/chunks/site-state-B_SwLwSW.js +0 -1
- package/lib/cjs/chunks/state-DU3L5Lve.js +0 -1
package/lib/cjs/add-component.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),h=require("./chunks/state-BBnuCgyl.js"),K=require("@arcblock/ux/lib/Empty"),O=require("@arcblock/ux/lib/Locale/context"),A=require("@iconify-icon/react"),X=require("@mui/icons-material/Check"),e=require("@mui/material"),N=require("ahooks"),f=require("react"),T=require("./chunks/index-B-TdKJtn.js"),y=require("@arcblock/ux/lib/Theme");require("@blocklet/pages-kit/builtin/color-picker");require("@blocklet/pages-kit/utils/style");require("@emotion/css");require("lodash/without");const m=require("@mui/material/colors");require("@blocklet/pages-kit/builtin/uploader");require("react-use");require("lodash/cloneDeep");require("@dnd-kit/core");require("@dnd-kit/sortable");require("@mui/icons-material");const Y=require("ufo");require("@dnd-kit/utilities");require("@blocklet/pages-kit/contexts/color");require("@mui/lab");require("immer");require("lodash/omit");require("react-router-dom");require("@arcblock/ux/lib/Button");require("is-uri");require("@arcblock/ux/lib/Toast");require("@mui/material/Tooltip");require("@mui/icons-material/KeyboardArrowLeft");const J=require("@mui/material/Box");require("@mui/material/DialogTitle");require("@mui/material/IconButton");require("@mui/material/Dialog");require("@mui/material/useMediaQuery");const Z=require("@emotion/react");require("@mui/material/Alert");require("@mui/material/AlertTitle");require("react-error-boundary");require("lodash/isEmpty");require("yaml");require("@mui/material/Typography");require("joi");const E=require("@blocklet/aigne-hub/api"),ee=require("@blocklet/js-sdk");require("@mui/x-date-pickers");require("@mui/x-date-pickers/AdapterDayjs");require("@mui/x-date-pickers/LocalizationProvider");require("circular-natal-horoscope-js/dist");const te=require("dayjs"),oe=require("dayjs/plugin/timezone"),re=require("dayjs/plugin/utc");require("fast-deep-equal");require("lodash/isNil");require("tz-lookup");require("@mui/icons-material/CheckCircleOutline");require("lodash/uniq");require("lodash/get");require("lodash/set");const D=require("@blocklet/pages-kit/utils/common"),ie=require("@blocklet/pages-kit/components"),S=t=>t&&t.__esModule?t:{default:t},G=S(K),ne=S(X),se=S(J),F=S(te),ae=S(oe),le=S(re);m.red[300],m.pink[300],m.purple[300],m.indigo[300],m.blue[300],m.cyan[300],m.teal[300],m.green[300],m.lime[300],m.yellow[300],m.amber[300],m.orange[300],m.brown[300],m.grey[300],m.blueGrey[300];y.styled(e.Box)`
|
|
2
2
|
.color-item {
|
|
3
3
|
position: relative;
|
|
4
4
|
}
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
top: 0;
|
|
43
43
|
transform: translateY(-50%);
|
|
44
44
|
}
|
|
45
|
-
`;const
|
|
45
|
+
`;const ce=f.createContext({embed:!1}),{Provider:me}=ce;f.createContext(void 0);E.createStatusApi({axios:h.api,path:"/api/ai/status"});E.createStatusApi({axios:h.api,path:"/api/ai/agent-status"});E.createTextCompletionApi({fetch:ee.createFetch(),path:"/api/ai/completions"});F.default.extend(le.default);F.default.extend(ae.default);y.styled(e.Box)`
|
|
46
46
|
flex-grow: 1;
|
|
47
47
|
display: flex;
|
|
48
48
|
flex-direction: column;
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
`;f.createContext({});
|
|
148
|
+
`;f.createContext({});y.styled(e.Box)`
|
|
149
149
|
display: flex;
|
|
150
150
|
flex-direction: column;
|
|
151
151
|
flex: 1;
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
border-radius: 12px;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
`;
|
|
160
|
+
`;y.styled(e.Box)`
|
|
161
161
|
background: #fbfbfb;
|
|
162
162
|
border: 1px solid #f6f6f6;
|
|
163
163
|
border-radius: 4px;
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
color: #25292f;
|
|
179
179
|
cursor: pointer;
|
|
180
180
|
}
|
|
181
|
-
`;
|
|
181
|
+
`;y.styled(se.default)`
|
|
182
182
|
background: #f6f2ff;
|
|
183
183
|
margin-bottom: 20px;
|
|
184
184
|
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
color: #9397a1;
|
|
199
199
|
margin-top: 4px;
|
|
200
200
|
}
|
|
201
|
-
`;
|
|
201
|
+
`;y.styled(e.Box)`
|
|
202
202
|
display: block;
|
|
203
203
|
padding: 16px;
|
|
204
204
|
text-decoration: none;
|
|
@@ -228,11 +228,11 @@
|
|
|
228
228
|
-webkit-line-clamp: 2;
|
|
229
229
|
overflow: hidden;
|
|
230
230
|
}
|
|
231
|
-
`;
|
|
231
|
+
`;Z.css`
|
|
232
232
|
.MuiMenu-root {
|
|
233
233
|
z-index: 13010 !important;
|
|
234
234
|
}
|
|
235
|
-
`;
|
|
235
|
+
`;y.styled(e.Box)`
|
|
236
236
|
display: flex;
|
|
237
237
|
flex-direction: column;
|
|
238
238
|
flex: 1;
|
|
@@ -244,7 +244,7 @@
|
|
|
244
244
|
border-radius: 12px;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
`;
|
|
247
|
+
`;y.styled(e.Box)`
|
|
248
248
|
background: #fbfbfb;
|
|
249
249
|
border: 1px solid #f6f6f6;
|
|
250
250
|
border-radius: 4px;
|
|
@@ -267,7 +267,7 @@
|
|
|
267
267
|
color: #25292f;
|
|
268
268
|
cursor: pointer;
|
|
269
269
|
}
|
|
270
|
-
`;
|
|
270
|
+
`;y.styled(e.Box)`
|
|
271
271
|
> .ai-button {
|
|
272
272
|
display: none;
|
|
273
273
|
z-index: 1;
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
margin: auto;
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
-
`;
|
|
288
|
+
`;y.styled(e.Box)`
|
|
289
289
|
> .language-button {
|
|
290
290
|
display: none;
|
|
291
291
|
z-index: 1;
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
margin: auto;
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
-
`;
|
|
306
|
+
`;y.styled(e.Box)`
|
|
307
307
|
position: relative;
|
|
308
308
|
|
|
309
309
|
.action {
|
|
@@ -326,4 +326,4 @@
|
|
|
326
326
|
display: inline-flex;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
`;D.nextId();const
|
|
329
|
+
`;D.nextId();const de=h.getMountPoint("pages-kit"),pe={type:"default",title:"Section CardList",description:"This is Section CardList",center:!0,dark:!1,background:"",col:3,gap:2,align:"top",textAlign:"left",iconSize:100,padding:"normal",list:[{id:D.nextId(),title:"Simplified Service Delivery",description:"Block Server's Service Gateway makes networking easy with access to load balancing, SSL termination, automatic and customizable URL mapping, and redirects.",image:Y.joinURL(de,"/static/assets/builder.png")}]};function ue({componentId:t,locale:d,components:p}){const{state:{config:{defaultLocale:l}},localState:{customComponentPreviewerProperties:w}}=h.useStore(),n=h.useAllComponents(),C=p||n,x=C?.[t],c=x?.data??(x&&typeof x=="object"&&"component"in x?x.component:void 0),g=c?.renderer;if(g?.type==="component-template"&&c){const b=h.createComponentTemplatePage(c,g),s=d||l||"en",r=h.getProjectIdFromPathnameOrWindow();return o.jsx(T.PageProvider,{page:b,defaultLocale:l,currentLocale:s,children:o.jsx(T.RenderQueueProvider,{children:o.jsx(e.Stack,{spacing:2,sx:{p:1},children:b.sectionIds.map((v,k)=>{const u=b.sections[v];if(!u||u.visibility==="hidden")return null;const B=b.dataSource?.[u.id]?.[s]??(l?b.dataSource?.[u.id]?.[l]:void 0)??{},q=u.properties??{};return o.jsx(T.BlockRenderer,{id:u.id,type:u.component,section:u,config:{...q,...B,locale:s,editing:!0,dev:{mode:"draft",defaultLocale:l,components:C,projectId:r}},page:b,renderIndex:k},u.id)})})})})}return o.jsx(ie.CustomComponentRenderer,{componentId:t,locale:d,dev:{mode:"draft",components:C,defaultLocale:l},properties:w?.[t]??{}})}const L=260,xe=5,H="IGNORE_RENDER_BLOCKLET_TITLE",z=(t,d)=>t?Object.entries(t).map(([p,l])=>({id:p,component:p,name:l?.data?.name||l?.component?.name||p,properties:l?.data||l.component,previewImage:l?.data?.previewImage||null,type:d,blockletId:l?.blockletId,blockletTitle:l?.blockletTitle})):[],W=[{id:"section",name:"Section",properties:T.SectionBlockDefaultProps},{id:"section-card-list",name:"Section Card List",properties:pe},{id:"toc",name:"Toc",properties:T.TocDefaultProps},{id:"iframe",name:"Embed",properties:T.IFrameBlockDefaultProps},{id:"layout-block",name:"Section Layout",properties:{}}].map(t=>({...t,type:"basic",component:t.id}));function Q({state:t,open:d,onClose:p,onSelect:l,defaultTab:w,title:n,componentGroups:C,components:x,multiple:c=!1,defaultSelected:g,emptyText:b}){const{t:s}=O.useLocaleContext(),r=N.useReactive({selectedComponent:null,activeTab:w,searchQuery:""}),v=f.useMemo(()=>C||[{name:"basic",label:s("maker.components.basicGroup"),components:W},t&&{name:"custom",label:s("maker.components.customGroup"),components:z(h.getCustomComponents(t),"custom")},t&&{name:"resource",label:s("maker.components.resourceGroup"),components:z(h.getResourceComponents(t),"resource")}].filter(Boolean),[C,s,t,d]),k=r.activeTab||v[0]?.name,u=()=>{r.selectedComponent&&(l(r.selectedComponent),p())},B=i=>{if(i){if(q(i)){c?r.selectedComponent=r.selectedComponent.filter(a=>a.id!==i.id):r.selectedComponent=null;return}if(c){const a=Array.isArray(r.selectedComponent)?r.selectedComponent:[],j=a.some(M=>M.id===i.id);r.selectedComponent=j?a.filter(M=>M.id!==i.id):[...a,i]}else r.selectedComponent=i}},q=i=>r.selectedComponent?c?r.selectedComponent.some(a=>a.id===i.id):r.selectedComponent.id===i.id:!1,I=v?.length===0,_=f.useMemo(()=>{const i=v.find(a=>a?.name===k)?.components||[];return r.searchQuery?i.filter(a=>a.name.toLowerCase().includes(r.searchQuery.toLowerCase())):i},[k,v,r.searchQuery]);f.useEffect(()=>{r.searchQuery="",d&&g?r.selectedComponent=c?Array.isArray(g)?g:[g]:g:r.selectedComponent=null},[d,g,c]);const R=_?.length===0,P=b||s(k==="resource"?"maker.components.needAddResource":"maker.components.noComponents"),U=f.useMemo(()=>_?_.reduce((i,a)=>{const j=a.blockletId||H,M=a.blockletTitle||s("maker.components.defaultGroup");return i[j]||(i[j]={title:M,components:[]}),i[j].components.push(a),i},{}):{},[_]);return o.jsxs(e.Dialog,{open:d,onClose:p,maxWidth:"lg",fullWidth:!0,slotProps:{paper:{sx:{height:"80vh",maxHeight:"80vh",display:"flex",flexDirection:"column"}}},children:[o.jsxs(e.DialogTitle,{className:"between",sx:{display:"flex",gap:2},children:[o.jsx(e.Box,{children:n||s("maker.components.addComponent")}),o.jsx(e.TextField,{size:"small",placeholder:s("maker.components.searchComponent"),value:r.searchQuery,onChange:i=>r.searchQuery=i.target.value,sx:{flex:1,maxWidth:350},slotProps:{input:{startAdornment:o.jsx(A.Icon,{icon:"tabler:search",style:{marginRight:8}})}}}),o.jsx(e.IconButton,{size:"small",onClick:p,children:o.jsx(e.Box,{component:A.Icon,icon:"tabler:x",sx:{color:"text.primary"}})})]}),o.jsxs(e.DialogContent,{sx:{display:"flex",gap:2,pl:"8px !important",flex:1,overflow:"hidden"},children:[!I&&o.jsx(e.Box,{sx:{width:150,borderRight:1,borderColor:"divider"},children:o.jsx(e.Tabs,{orientation:"vertical",value:k,onChange:(i,a)=>r.activeTab=a,sx:{"& .MuiTab-root":{alignItems:"flex-start",textAlign:"left",minHeight:48,py:1.5,px:2}},children:v.map((i,a)=>o.jsx(e.Tab,{label:i?.label,value:i?.name},a))})}),o.jsx(e.Box,{sx:{flex:1,overflowX:"hidden",overflowY:"auto",pr:1},children:R?o.jsx(G.default,{children:P}):o.jsx($,{wrapperComponent:e.Grid,wrapperComponentProps:{container:!0,spacing:2,sx:R?{height:"100%"}:{}},groups:U,emptyText:P,renderItem:i=>{const a=q(i);return o.jsx(e.Grid,{sx:{width:"100%","& .add-component-card":{boxShadow:"none",border:1,borderColor:a?"primary.main":"grey.200","& .check-container":{display:a?"flex":"none",position:"absolute",right:0,bottom:0,justifyContent:"flex-end",alignItems:"flex-end",width:30,height:30,overflow:"hidden",transition:"all 0.3s ease",color:"white","&::after":{position:"absolute",zIndex:0,display:"block",width:0,height:0,borderTop:"transparent solid 15px",borderLeft:"transparent solid 15px",borderBottom:j=>`solid 15px ${j.palette.primary.main}`,borderRight:j=>`solid 15px ${j.palette.primary.main}`,transition:"all 0.1s ease",content:'""'},"& .check-icon":{position:"relative",zIndex:2,margin:"0 1px 1px 0",fontSize:16,transition:"all 0.2s ease"}}}},size:{xs:12,md:6,lg:4},children:o.jsxs(e.Card,{className:"add-component-card",sx:{position:"relative",width:"100%",cursor:"pointer"},onClick:()=>B(i),children:[o.jsx(e.CardMedia,{sx:{width:"100%",height:L,overflow:"auto",position:"relative"},children:o.jsx(V,{components:x,containerHeight:L,component:i},i.id)}),o.jsx(e.CardContent,{sx:{bgcolor:"background.paper",borderTop:1,borderColor:a?"primary.main":"grey.200"},children:o.jsx(e.Typography,{variant:"body1",noWrap:!0,sx:{fontWeight:"bold"},children:i.name})}),o.jsx(e.Box,{className:"check-container",children:o.jsx(ne.default,{className:"check-icon"})})]})},i.id)}})})]}),o.jsxs(e.DialogActions,{sx:{borderTop:1,borderColor:"divider",p:2},children:[o.jsx(e.Button,{onClick:p,variant:"outlined",children:s("common.cancel")}),o.jsx(e.Button,{onClick:u,variant:"contained",disabled:!r.selectedComponent||c&&Array.isArray(r.selectedComponent)&&r.selectedComponent.length===0,children:c&&Array.isArray(r.selectedComponent)&&r.selectedComponent.length>0?s("common.addMultiple",{count:r.selectedComponent.length}):s("common.add")})]})]})}function V({containerHeight:t,component:d,minScale:p=.1,components:l}){const{locale:w}=O.useLocaleContext(),n=N.useReactive({scale:1,shouldScroll:!1,isVisible:!1,hadInit:!1}),{currentPage:C}=h.useStore(),x=f.useRef(null),c=f.useRef(null),g=f.useRef(0),b=f.useRef(null);f.useEffect(()=>{const q=new IntersectionObserver(([I])=>{n.isVisible=I.isIntersecting},{root:null,rootMargin:"50px",threshold:0});return c.current&&q.observe(c.current),()=>q.disconnect()},[]),f.useEffect(()=>{const q=()=>{if(g.current+=1,g.current>xe){I.disconnect();return}if(!d.previewImage&&x.current){const _=x.current.scrollHeight,R=t/_;R<p?(n.scale=p,n.shouldScroll=!0):R<1?(n.scale=R,n.shouldScroll=!1):(n.scale=1,n.shouldScroll=!1)}b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{n.hadInit=!0},200)},I=new ResizeObserver(()=>{setTimeout(q,20)});return x.current&&n.isVisible&&I.observe(x.current),()=>{I.disconnect()}},[t,p,n.isVisible,d]);const{id:s,type:r,component:v,properties:k,previewImage:u}=d,B=f.useMemo(()=>n.isVisible?u?o.jsx(e.Box,{component:"img",loading:"lazy",src:h.getImageAbsoluteUrl(u),alt:d.name,sx:{width:"100%",height:"100%",objectFit:"cover",borderRadius:1,cursor:"pointer"}},s):r==="basic"?o.jsx(T.BlockRenderer,{id:s,type:v,section:k,config:{...k,locale:w,editing:!1,dev:{mode:"draft"}},page:C},s):o.jsx(ue,{componentId:s,locale:w,components:l},s):null,[s,r,v,k,w,u,n.isVisible]);return o.jsx(e.Box,{ref:c,sx:{position:"relative",width:"100%",height:"100%",overflowX:"hidden",overflowY:n.shouldScroll?"auto":"hidden",transition:"all 0.3s ease"},children:o.jsxs(e.Box,{sx:{transform:`scale(${n.scale})`,transformOrigin:"top left",width:`${100/n.scale}%`,height:n.hadInit&&n.shouldScroll?"100%":`${100/n.scale}%`},children:[!n.hadInit&&o.jsx(e.Skeleton,{variant:"rectangular",width:"100%",height:"100%"}),o.jsx(e.Box,{ref:x,sx:{width:"100%",height:u?"100%":"auto",pointerEvents:"none",opacity:n.hadInit?1:0},children:B})]})})}function $({groups:t,emptyText:d,renderItem:p,wrapperComponent:l=e.Box,wrapperComponentProps:w={display:"inline-flex",flexWrap:"wrap",gap:1}}){return o.jsx(e.Box,{children:Object.keys(t).length>0?Object.entries(t).map(([n,{title:C,components:x}])=>o.jsxs(e.Box,{sx:{mb:3},children:[n!==H&&o.jsxs(e.Typography,{className:"blocklet-title",variant:"subtitle2",sx:{mb:2,fontWeight:500,color:"text.primary",display:"flex",alignItems:"center",gap:1},children:[o.jsx(e.Box,{component:"span",sx:{width:4,height:20,backgroundColor:"primary.main",borderRadius:1,display:"inline-block"}}),C]}),o.jsx(l,{...w,children:x.map(c=>p(c))})]},n)):o.jsx(G.default,{children:d})})}exports.AddComponent=Q;exports.AutoScaledComponentRenderer=V;exports.BASIC_COMPONENT_LIST=W;exports.GroupedComponentsList=$;exports.default=Q;exports.formatComponent=z;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("./state-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("./state-BBnuCgyl.js");function n({children:e}){const r=t.useProjectId();return s.jsx(t.StoreProvider,{url:t.getWssURL(r??""),name:"root",waitingSynced:!0,children:s.jsx(o,{children:e})})}function o({children:e}){const{state:r}=t.useStore();return e({state:r})}exports.default=n;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),w=require("./state-
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),w=require("./state-BBnuCgyl.js"),V=require("@arcblock/ux/lib/Locale/context"),ne=require("@arcblock/ux/lib/Result"),I=require("@arcblock/ux/lib/Theme"),oe=require("@blocklet/pages-kit/builtin/page/header"),re=require("@blocklet/pages-kit/contexts/color"),W=require("@blocklet/pages-kit/utils/data-source"),se=require("@blocklet/pages-kit/utils/route"),ae=require("@blocklet/ui-react/lib/Header"),ie=require("@emotion/css"),T=require("@emotion/react"),j=require("@mui/material"),L=require("ahooks"),ce=require("isomorphic-dompurify"),le=require("lodash/cloneDeep"),ue=require("lodash/isEmpty"),de=require("lodash/isEqual"),p=require("react"),pe=require("react-helmet"),P=require("react-router-dom"),$=require("react-use"),S=require("ufo"),v=require("./index-B-TdKJtn.js"),ge=require("@blocklet/ui-react/lib/Footer");require("webfontloader");const z=require("./session-BZ3-x8Ef.js"),R=t=>t&&t.__esModule?t:{default:t},A=R(ne),me=R(ae),he=R(ce),E=R(le),fe=R(ue),G=R(de),xe=R(ge),je=I.styled(j.Box)`
|
|
2
2
|
display: contents;
|
|
3
3
|
& > div > div > .MuiContainer-root {
|
|
4
4
|
max-width: unset;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
font-family: ${o};
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
`})}function N(t){return t!=null}function Se(){const[t]=P.useSearchParams(),{session:n}=z.useSessionContext(),s=z.useIsRoleOrMultiTenant("owner","admin","pagesEditor","member"),r=p.useMemo(()=>{const o=t.get("mode");return v.STATE_MODES.includes(o)?o:"production"},[t]);return r==="draft"&&(!s||!n.user)?e.jsx(A.default,{status:"403"}):e.jsx(Y,{mode:r})}function Y({mode:t}){if(t!=="draft"){const n=window.__PAGE_STATE__;return n?e.jsx(_,{mode:t,state:n}):e.jsx(qe,{mode:t,children:({state:s})=>e.jsx(_,{mode:t,state:s})})}return e.jsx(Ce,{children:({state:n})=>e.jsx(_,{mode:t,state:n})})}const Re=p.lazy(()=>Promise.resolve().then(()=>require("./publish-button-
|
|
30
|
+
`})}function N(t){return t!=null}function Se(){const[t]=P.useSearchParams(),{session:n}=z.useSessionContext(),s=z.useIsRoleOrMultiTenant("owner","admin","pagesEditor","member"),r=p.useMemo(()=>{const o=t.get("mode");return v.STATE_MODES.includes(o)?o:"production"},[t]);return r==="draft"&&(!s||!n.user)?e.jsx(A.default,{status:"403"}):e.jsx(Y,{mode:r})}function Y({mode:t}){if(t!=="draft"){const n=window.__PAGE_STATE__;return n?e.jsx(_,{mode:t,state:n}):e.jsx(qe,{mode:t,children:({state:s})=>e.jsx(_,{mode:t,state:s})})}return e.jsx(Ce,{children:({state:n})=>e.jsx(_,{mode:t,state:n})})}const Re=p.lazy(()=>Promise.resolve().then(()=>require("./publish-button-JUoM34Aa.js"))),Ce=p.lazy(()=>Promise.resolve().then(()=>require("./draft-data-BYzGfJ7S.js")));function qe({mode:t,children:n}){const r=document.querySelector('meta[property="pages:version"]')?.content,o=w.useProjectId(),i=p.useMemo(()=>{if(r==="{{pagesPublishedAt}}"){const u=localStorage.getItem(w.getProjectPageVersionKey(o??""));return Number(u)?Number(u):new Date().getTime()}return Number(r)},[r]),{loading:d,value:l}=$.useAsync(()=>v.getPages({mode:t,version:i}),[t,i]);return d?e.jsx(K,{}):l?n({state:l}):null}function _({mode:t,state:n}){const{t:s,locale:r}=V.useLocaleContext(),[o]=P.useSearchParams(),i=w.useProjectId(),d=w.useProjectSlug(),l=o.get("hiddenBadge")==="true",u=o.get("showPublish")==="true",{pageIds:g,pages:c,routeIds:x,routes:m,supportedLocales:h,config:{defaultLocale:b},resources:C}=n,y=w.getAllComponents(n),k=p.useMemo(()=>h?.some(f=>f.locale===r)?r:void 0,[r,h]),H=Object.values(m||{}).find(f=>f?.path==="/")||Object.values(c).find(f=>f?.slug==="/")?void 0:Object.values(c)[0],te=p.useMemo(()=>t==="production"?g?.map(f=>{const a=c[f];return a&&{id:a.id,path:S.joinURL("/",d||i||"",a.slug),isLinkToPage:v.isLinkToPage(a)}}).filter(N):x?.map(f=>{const a=m[f];return a?{id:a.id,path:S.joinURL("/",d||i||"",a.path,`?mode=${t}&showPublish=true`)}:null}).filter(N),[g,c,t,m,x,i,d]),M=([...f])=>(t!=="production"&&u&&f.unshift(e.jsx(p.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(Re,{ref:{current:null},mode:"production",state:n})})),f);return e.jsxs(v.Provider,{value:{pages:te},children:[e.jsxs(P.Routes,{children:[H&&e.jsx(P.Route,{index:!0,element:e.jsx(P.Navigate,{to:S.joinURL("/",k||"",H.slug)})}),x?.map(f=>{const a=m?.[f];if(!a||!a.displayTemplateId)return null;const B=c[a.displayTemplateId];if(!B)return null;let D=[];return a.params&&a.params.length>0&&(D=se.generateParamCombinations({basePath:a.path,params:a.params,routeId:a.id,paramsOptions:a.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]})?.map(U=>{const F=U.paramOptionIds.join("-");return e.jsx(P.Route,{path:S.joinURL(":projectIdOrSlug?",U.path),element:e.jsx(O,{mode:t,components:y,page:B,locale:k,defaultLocale:b,headerAddons:M,state:n,pageData:a.dataSource?.pathDataMappings?.[F]?.dataCache?.[k||b||"en"]})},F)})),D.push(e.jsx(P.Route,{path:S.joinURL(":projectIdOrSlug?",a.path),element:e.jsx(O,{mode:t,components:y,page:B,locale:k,defaultLocale:b,headerAddons:M,state:n,pageData:a.dataSource?.pathDataMappings?.[a.id]?.dataCache?.[k||b||"en"]})},a.id)),D}),g?.map(f=>{const a=c[f];return!a||!v.isLinkToPage(a)?null:e.jsx(P.Route,{path:S.joinURL(":projectIdOrSlug?",a.slug),element:e.jsx(q,{mode:t,components:y,page:a,locale:k,defaultLocale:b,headerAddons:M})},a.id)}),C?.pages&&Object.values(C?.pages)?.map(({blockletId:f,page:a})=>e.jsx(P.Route,{path:S.joinURL("/",`@${f}`,a.slug),element:e.jsx(q,{mode:t,components:y,page:a,locale:k,defaultLocale:b,headerAddons:M})},a.id)),e.jsx(P.Route,{path:"*",element:e.jsx(j.Box,{sx:{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(A.default,{status:404,extra:e.jsx(ee,{href:"/",children:s("common.back")}),sx:{bgcolor:"transparent",width:"100%",height:"100%"}})})})]}),t!=="production"&&!l&&e.jsx(Pe,{sx:{bgcolor:"info.light"},children:t}),e.jsx(ke,{})]})}function O({mode:t,pageData:n,components:s,page:r,locale:o,defaultLocale:i,headerAddons:d,state:l}){const u=L.useReactive({page:null});L.useDeepCompareEffect(()=>{const c=r||null;c?u.page=E.default(c):u.page=null},[r,u]);const g=p.useRef(void 0);return p.useEffect(()=>{G.default(n,g.current)||n&&u.page&&(W.setPageDataSource(u.page,l,o,n),g.current=E.default(n))},[u.page,n,o,l]),u.page?e.jsx(q,{mode:t,components:s,page:u.page,locale:o,defaultLocale:i,headerAddons:d}):null}function Ie({mode:t,state:n,path:s,pageData:r}){const{t:o,locale:i}=V.useLocaleContext(),{pages:d,supportedLocales:l,config:{defaultLocale:u},resources:g}=n,c=Object.values(d).find(y=>y?.slug===s),x=Object.values(g?.pages||{}).find(y=>y.page.slug===s),m=p.useMemo(()=>l?.some(y=>y.locale===i)?i:void 0,[i,l]),h=L.useReactive({page:null});p.useEffect(()=>{const y=c||x?.page||null;y?h.page=E.default(y):h.page=null},[c,x]);const b=p.useRef(void 0);if(p.useEffect(()=>{G.default(r,b.current)||r&&h.page&&(W.setPageDataSource(h.page,n,m,r),b.current=E.default(r))},[{}]),!c&&!x?.page)return e.jsx(j.Box,{sx:{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(A.default,{style:{background:"inherit"},status:404,extra:e.jsx(ee,{href:"/",children:o("common.back")})})});const C=w.getAllComponents(n);return h.page?e.jsx(q,{mode:t,components:C,page:h.page,locale:m,defaultLocale:u}):null}function q({mode:t,components:n,page:s,locale:r,defaultLocale:o,headerAddons:i}){const d=re.useColorConvert(),l=s.locales?.[r]??s.locales?.[o]??{},u=l.title||window.blocklet?.appName,g=l.description||window.blocklet?.appDescription,c=w.autoResizeImage(w.getImageAbsoluteUrl(l.image),540);return e.jsxs(v.PageProvider,{page:s,defaultLocale:o,currentLocale:r,children:[e.jsx(T.Global,{styles:T.css`
|
|
31
31
|
body {
|
|
32
32
|
background-color: ${d(!l.backgroundColor||l.backgroundColor==="transparent"?"background.default":l.backgroundColor)} !important;
|
|
33
33
|
}
|