@blocklet/pages-kit-inner-components 0.5.53 → 0.5.55

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/es/theme.js CHANGED
@@ -1,12 +1,14 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { ConfigProvider as f } from "@arcblock/ux/lib/Config";
3
- import { Icon as y } from "@iconify-icon/react";
4
- import g from "@iconify-icons/tabler/chevron-down";
5
- import { listItemIconClasses as z, switchClasses as v, svgIconClasses as l, sliderClasses as n, outlinedInputClasses as d, inputBaseClasses as t, filledInputClasses as m, inputLabelClasses as s, inputClasses as a, selectClasses as S, autocompleteClasses as p, Box as M } from "@mui/material";
6
- import { S as b } from "./chunks/session-CVblGhSp.js";
7
- import { translations as c } from "./locales.js";
8
- var x;
9
- const o = ((x = window.blocklet) == null ? void 0 : x.prefix) || "/", $ = o.endsWith("/") ? `${o}admin` : `${o}/admin`, h = {
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { ConfigProvider as h } from "@arcblock/ux/lib/Config";
3
+ import { Icon as $ } from "@iconify-icon/react";
4
+ import y from "@iconify-icons/tabler/chevron-down";
5
+ import { listItemIconClasses as g, switchClasses as z, svgIconClasses as r, sliderClasses as o, outlinedInputClasses as m, inputBaseClasses as t, filledInputClasses as u, inputLabelClasses as s, inputClasses as a, selectClasses as v, autocompleteClasses as p, Box as S } from "@mui/material";
6
+ import { useMemo as M } from "react";
7
+ import { useLocation as I } from "react-router-dom";
8
+ import { S as C } from "./chunks/session-CVblGhSp.js";
9
+ import { translations as O } from "./locales.js";
10
+ var f;
11
+ const l = ((f = window.blocklet) == null ? void 0 : f.prefix) || "/", T = l.endsWith("/") ? `${l}admin` : `${l}/admin`, b = {
10
12
  fontSize: "5rem",
11
13
  "@media (max-width: 1536px)": {
12
14
  fontSize: "5rem"
@@ -21,12 +23,12 @@ const o = ((x = window.blocklet) == null ? void 0 : x.prefix) || "/", $ = o.ends
21
23
  fontSize: "2rem"
22
24
  }
23
25
  };
24
- function u(e) {
25
- return /* @__PURE__ */ r(M, { ...e, component: y, icon: g });
26
+ function x(e) {
27
+ return /* @__PURE__ */ n(S, { ...e, component: $, icon: y });
26
28
  }
27
- const I = {
29
+ const L = {
28
30
  typography: {
29
- big: { ...h },
31
+ big: { ...b },
30
32
  button: {
31
33
  // @ts-ignore
32
34
  textTransform: "none",
@@ -83,10 +85,10 @@ const I = {
83
85
  styleOverrides: {
84
86
  root: {
85
87
  padding: 4,
86
- [`.${l.fontSizeMedium}`]: {
88
+ [`.${r.fontSizeMedium}`]: {
87
89
  fontSize: "1.25rem"
88
90
  },
89
- [`.${l.fontSizeSmall}`]: {
91
+ [`.${r.fontSizeSmall}`]: {
90
92
  fontSize: "1.125rem"
91
93
  }
92
94
  }
@@ -96,10 +98,10 @@ const I = {
96
98
  styleOverrides: {
97
99
  root: {
98
100
  padding: 4,
99
- [`.${l.fontSizeMedium}`]: {
101
+ [`.${r.fontSizeMedium}`]: {
100
102
  fontSize: "1.25rem"
101
103
  },
102
- [`.${l.fontSizeSmall}`]: {
104
+ [`.${r.fontSizeSmall}`]: {
103
105
  fontSize: "1.125rem"
104
106
  }
105
107
  }
@@ -111,7 +113,7 @@ const I = {
111
113
  height: 28,
112
114
  width: 48,
113
115
  padding: 8,
114
- [`&.${v.sizeSmall}`]: {
116
+ [`&.${z.sizeSmall}`]: {
115
117
  height: 26,
116
118
  width: 40,
117
119
  padding: 8
@@ -123,7 +125,7 @@ const I = {
123
125
  }
124
126
  },
125
127
  MuiAutocomplete: {
126
- defaultProps: { popupIcon: /* @__PURE__ */ r(u, { fontSize: 14 }) },
128
+ defaultProps: { popupIcon: /* @__PURE__ */ n(x, { fontSize: 14 }) },
127
129
  variants: [
128
130
  {
129
131
  props: {},
@@ -176,7 +178,7 @@ const I = {
176
178
  [`&.${t.hiddenLabel}`]: {
177
179
  mt: 0,
178
180
  pt: 0,
179
- [`.${S.select}.${a.input}:focus`]: {
181
+ [`.${v.select}.${a.input}:focus`]: {
180
182
  bgcolor: "transparent"
181
183
  }
182
184
  }
@@ -194,7 +196,7 @@ const I = {
194
196
  }
195
197
  },
196
198
  // filled
197
- [`.${m.root}`]: {
199
+ [`.${u.root}`]: {
198
200
  ":before,:after": { display: "none" },
199
201
  [`.${t.input}`]: {
200
202
  pb: 0.5,
@@ -231,7 +233,7 @@ const I = {
231
233
  }
232
234
  },
233
235
  // outlined
234
- [`.${d.root}`]: {
236
+ [`.${m.root}`]: {
235
237
  [`.${t.input}`]: {
236
238
  py: 1.25,
237
239
  px: 1,
@@ -302,12 +304,12 @@ const I = {
302
304
  select: {
303
305
  display: "flex",
304
306
  alignItems: "center",
305
- [`.${z.root}`]: {
307
+ [`.${g.root}`]: {
306
308
  minWidth: 20
307
309
  }
308
310
  }
309
311
  },
310
- defaultProps: { variant: "filled", IconComponent: u },
312
+ defaultProps: { variant: "filled", IconComponent: x },
311
313
  variants: [
312
314
  {
313
315
  props: {},
@@ -316,7 +318,7 @@ const I = {
316
318
  borderRadius: 1,
317
319
  lineHeight: "1.5rem",
318
320
  // filled
319
- [`&.${m.root}`]: {
321
+ [`&.${u.root}`]: {
320
322
  ":before,:after": { display: "none" },
321
323
  [`.${t.input}`]: {
322
324
  py: 0.5,
@@ -327,7 +329,7 @@ const I = {
327
329
  }
328
330
  },
329
331
  // outlined
330
- [`&.${d.root}`]: {
332
+ [`&.${m.root}`]: {
331
333
  [`.${t.input}`]: {
332
334
  py: 0.5,
333
335
  borderRadius: 1,
@@ -347,16 +349,16 @@ const I = {
347
349
  props: {},
348
350
  style: ({ theme: e }) => e.unstable_sx({
349
351
  height: 3,
350
- [`.${n.track}`]: {
352
+ [`.${o.track}`]: {
351
353
  borderWidth: 0
352
354
  },
353
- [`.${n.thumb}`]: {
355
+ [`.${o.thumb}`]: {
354
356
  width: 16,
355
357
  height: 16
356
358
  },
357
- [`&.${n.sizeSmall}`]: {
359
+ [`&.${o.sizeSmall}`]: {
358
360
  height: 2,
359
- [`.${n.thumb}`]: {
361
+ [`.${o.thumb}`]: {
360
362
  width: 12,
361
363
  height: 12
362
364
  }
@@ -452,36 +454,32 @@ const I = {
452
454
  styleOverrides: {}
453
455
  }
454
456
  }
455
- }, C = {
457
+ }, _ = {
456
458
  typography: {
457
459
  // @ts-ignore
458
- big: { ...h },
460
+ big: { ...b },
459
461
  button: {
460
462
  // @ts-ignore
461
463
  textTransform: "none",
462
464
  WebkitTextTransform: "none"
463
465
  }
464
466
  }
465
- }, B = ({ children: e }) => /* @__PURE__ */ r(
466
- f,
467
- {
468
- theme: I,
469
- translations: c,
470
- fallbackLocale: "en",
471
- injectFirst: !0,
472
- children: /* @__PURE__ */ r(b, { serviceHost: o, protectedRoutes: [`${$}/*`], children: e })
473
- }
474
- ), H = ({ children: e }) => /* @__PURE__ */ r(
475
- f,
476
- {
477
- theme: C,
478
- translations: c,
479
- fallbackLocale: "en",
480
- injectFirst: !0,
481
- children: /* @__PURE__ */ r(b, { serviceHost: o, protectedRoutes: [`${$}/*`], children: e })
482
- }
483
- );
467
+ }, U = ({
468
+ children: e,
469
+ isDashboard: i = !1
470
+ }) => {
471
+ const d = I().pathname.startsWith("/admin/maker") || i, c = M(() => d ? L : _, [d]);
472
+ return /* @__PURE__ */ n(
473
+ h,
474
+ {
475
+ theme: c,
476
+ translations: O,
477
+ fallbackLocale: "en",
478
+ injectFirst: !0,
479
+ children: /* @__PURE__ */ n(C, { serviceHost: l, protectedRoutes: [`${T}/*`], children: e })
480
+ }
481
+ );
482
+ };
484
483
  export {
485
- B as DashboardProvider,
486
- H as PageProvider
484
+ U as PagesKitThemeProvider
487
485
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/pages-kit-inner-components",
3
- "version": "0.5.53",
3
+ "version": "0.5.55",
4
4
  "description": "Pages Kit inner components library",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -204,8 +204,8 @@
204
204
  "yaml": "^2.5.0",
205
205
  "yjs": "^13.6.18",
206
206
  "zustand": "^4.5.5",
207
- "@blocklet/pages-kit": "^0.5.53",
208
- "@blocklet/pages-kit-block-studio": "^0.5.53"
207
+ "@blocklet/pages-kit": "^0.5.55",
208
+ "@blocklet/pages-kit-block-studio": "^0.5.55"
209
209
  },
210
210
  "devDependencies": {
211
211
  "@trivago/prettier-plugin-sort-imports": "^5.2.1",
@@ -1,38 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),R=require("./state-BVdbNJCA.js"),X=require("@arcblock/ux/lib/Locale/context"),ue=require("@arcblock/ux/lib/Result"),de=require("@blocklet/pages-kit/builtin/page/header"),pe=require("@blocklet/pages-kit/contexts/color"),Z=require("@blocklet/pages-kit/utils/data-source"),ge=require("@blocklet/pages-kit/utils/route"),me=require("@blocklet/ui-react/lib/Header"),fe=require("@emotion/css"),V=require("@emotion/react"),he=require("@emotion/styled"),y=require("@mui/material"),ee=require("ahooks"),xe=require("isomorphic-dompurify"),je=require("lodash/cloneDeep"),be=require("lodash/isEmpty"),ye=require("lodash/isEqual"),g=require("react"),ve=require("react-helmet"),w=require("react-router-dom"),te=require("react-use"),_=require("ufo"),E=require("./array-BqHuYyfx.js"),W=require("@arcblock/ux/lib/Theme"),Pe=require("@blocklet/ui-react/lib/Footer");require("webfontloader");const Q=require("./session-BA7Qrcia.js"),q=t=>t&&t.__esModule?t:{default:t},ne=q(ue),we=q(me),oe=q(he),ke=q(xe),z=q(je),Se=q(be),re=q(ye),Re=q(Pe),qe=W.styled(Re.default,{shouldForwardProp:t=>!!t})`
2
- & > div > .MuiContainer-root {
3
- max-width: unset;
4
- }
5
- `;function Ce({meta:t,...o}){const a=W.useTheme();return e.jsx(qe,{...o,meta:t,theme:a||{}})}function se(t){return e.jsx(y.Box,{display:"flex",flex:1,height:"100%",alignItems:"center",justifyContent:"center",...t,children:e.jsx(y.CircularProgress,{size:30})})}function _e(t){return e.jsx(Ee,{...t})}const Ee=W.styled(y.Box)`
6
- position: fixed;
7
- left: 0;
8
- top: 0;
9
- z-index: 999999999999;
10
- width: 80px;
11
- font-size: 12px;
12
- text-align: center;
13
- opacity: 0.7;
14
- transform: translateX(-23%) translateY(70%) rotate(-45deg);
15
- pointer-events: none;
16
- `,Ie=`Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
17
- sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`;function Me({titleFontFamily:t,descriptionFontFamily:o}){var n;const a=y.useTheme(),i=(n=a==null?void 0:a.typography)==null?void 0:n.fontFamily;g.useEffect(()=>{},[t,o]);const c=`${i}, ${Ie}`;return e.jsx(V.Global,{styles:V.css`
18
- #app {
19
- font-family: ${c};
20
-
21
- .page-kit-section__title {
22
- font-family: ${c};
23
- }
24
-
25
- .page-kit-section__description {
26
- font-family: ${c};
27
- }
28
- }
29
- `})}function Te(){const[t]=w.useSearchParams(),{session:o}=Q.useSessionContext(),a=Q.useIsRoleOrMultiTenant("owner","admin","pagesEditor","member"),i=g.useMemo(()=>{const n=t.get("mode");return E.STATE_MODES.includes(n)?n:"production"},[t]),c=i==="production"?i:o.user?a?i:"production":null;return c?e.jsx(ae,{mode:c}):null}function ae({mode:t}){if(t!=="draft"){const o=window.__PAGE_STATE__;return o?e.jsx(N,{mode:t,state:o}):e.jsx(Le,{mode:t,children:({state:a})=>e.jsx(N,{mode:t,state:a})})}return e.jsx(Be,{children:({state:o})=>e.jsx(N,{mode:t,state:o})})}const Be=g.lazy(()=>Promise.resolve().then(()=>require("./draft-data-CuZfaQ4s.js")));function Le({mode:t,children:o}){const a=document.querySelector('meta[property="pages:version"]'),i=a==null?void 0:a.content,c=R.useProjectId(),n=g.useMemo(()=>{if(i==="{{pagesPublishedAt}}"){const u=localStorage.getItem(R.getProjectPageVersionKey(c??""));return Number(u)?Number(u):new Date().getTime()}return Number(i)},[i]),{loading:m,value:r}=te.useAsync(()=>E.getPages({mode:t,version:n}),[t,n]);return m?e.jsx(se,{}):r?o({state:r}):null}function N({mode:t,state:o}){const{t:a,locale:i}=X.useLocaleContext(),[c]=w.useSearchParams(),n=R.useProjectId(),m=R.useProjectSlug(),r=c.get("hiddenBadge")==="true",u=c.get("showPublish")==="true",{pageIds:f,pages:l,routeIds:p,routes:h,supportedLocales:j,config:{defaultLocale:b},resources:I}=o,x=R.getAllComponents(o),k=g.useMemo(()=>j!=null&&j.some(d=>d.locale===i)?i:void 0,[i,j]),L=Object.values(h||{}).find(d=>(d==null?void 0:d.path)==="/")||Object.values(l).find(d=>(d==null?void 0:d.slug)==="/")?void 0:Object.values(l)[0],U=g.useMemo(()=>t==="production"?f.map(d=>{const s=l[d];return s&&{id:s.id,path:_.joinURL("/",m||n||"",s.slug)}}).filter(E.nonNullable):p.map(d=>{const s=h[d];return s?{id:s.id,path:_.joinURL("/",m||n||"",s.path,`?mode=${t}&showPublish=true`)}:null}).filter(E.nonNullable),[f,l,t,h,p,n,m]),C=([...d])=>(t!=="production"&&u&&d.unshift(e.jsx(g.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(De,{mode:"production",state:o})})),d);return e.jsxs(E.Provider,{value:{pages:U},children:[e.jsxs(w.Routes,{children:[L&&e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:_.joinURL("/",k||"",L.slug)})}),p==null?void 0:p.map(d=>{var P,v,S,A;const s=h==null?void 0:h[d];if(!s||!s.displayTemplateId)return null;const M=l[s.displayTemplateId];if(!M)return null;let T=[];if(s.params&&s.params.length>0){const B=ge.generateParamCombinations({basePath:s.path,params:s.params,routeId:s.id,paramsOptions:s.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});T=B==null?void 0:B.map(O=>{var F,Y,K,J;const D=O.paramOptionIds.join("-");return e.jsx(w.Route,{path:_.joinURL(":projectIdOrSlug?",O.path),element:e.jsx(G,{mode:t,components:x,page:M,locale:k,defaultLocale:b,headerAddons:C,state:o,pageData:(J=(K=(Y=(F=s.dataSource)==null?void 0:F.pathDataMappings)==null?void 0:Y[D])==null?void 0:K.dataCache)==null?void 0:J[k||b||"en"]})},D)})}return T.push(e.jsx(w.Route,{path:_.joinURL(":projectIdOrSlug?",s.path),element:e.jsx(G,{mode:t,components:x,page:M,locale:k,defaultLocale:b,headerAddons:C,state:o,pageData:(A=(S=(v=(P=s.dataSource)==null?void 0:P.pathDataMappings)==null?void 0:v[s.id])==null?void 0:S.dataCache)==null?void 0:A[k||b||"en"]})},s.id)),T}),f.map(d=>{const s=l[d];return s?e.jsx(w.Route,{path:_.joinURL(":projectIdOrSlug?",s.slug),element:e.jsx(H,{mode:t,components:x,page:s,locale:k,defaultLocale:b,headerAddons:C})},s.id):null}),I.pages&&Object.values(I.pages).map(({blockletId:d,page:s})=>e.jsx(w.Route,{path:_.joinURL("/",`@${d}`,s.slug),element:e.jsx(H,{mode:t,components:x,page:s,locale:k,defaultLocale:b,headerAddons:C})},s.id)),e.jsx(w.Route,{path:"*",element:e.jsx(y.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:e.jsx(ne.default,{status:404,extra:e.jsx(le,{href:"/",children:a("common.back")}),sx:{bgcolor:"transparent",width:"100%",height:"100%"}})})})]}),t!=="production"&&!r&&e.jsx(_e,{sx:{bgcolor:"info.light"},children:t}),e.jsx(Me,{})]})}function G({mode:t,pageData:o,components:a,page:i,locale:c,defaultLocale:n,headerAddons:m,state:r}){const u=ee.useReactive({page:null});g.useEffect(()=>{const l=i||null;l?u.page=z.default(l):u.page=null},[i,JSON.stringify(i),u]);const f=g.useRef();return g.useEffect(()=>{re.default(o,f.current)||o&&u.page&&(Z.setPageDataSource(u.page,r,c,o),f.current=z.default(o))},[u.page,o,c,r]),u.page?e.jsx(H,{mode:t,components:a,page:u.page,locale:c,defaultLocale:n,headerAddons:m}):null}function Oe({mode:t,state:o,path:a,pageData:i}){const{t:c,locale:n}=X.useLocaleContext(),{pages:m,supportedLocales:r,config:{defaultLocale:u},resources:f}=o,l=Object.values(m).find(x=>(x==null?void 0:x.slug)===a),p=Object.values(f.pages||{}).find(x=>x.page.slug===a),h=g.useMemo(()=>r!=null&&r.some(x=>x.locale===n)?n:void 0,[n,r]),j=ee.useReactive({page:null});g.useEffect(()=>{const x=l||(p==null?void 0:p.page)||null;x?j.page=z.default(x):j.page=null},[l,p]);const b=g.useRef();if(g.useEffect(()=>{re.default(i,b.current)||i&&j.page&&(Z.setPageDataSource(j.page,o,h,i),b.current=z.default(i))},[{}]),!l&&!(p!=null&&p.page))return e.jsx(y.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:e.jsx(ne.default,{style:{background:"inherit"},status:404,extra:e.jsx(le,{href:"/",children:c("common.back")})})});const I=R.getAllComponents(o);return j.page?e.jsx(H,{mode:t,components:I,page:j.page,locale:h,defaultLocale:u}):null}function H({mode:t,components:o,page:a,locale:i,defaultLocale:c,headerAddons:n}){var k,$,L,U,C,d,s,M,T;const m=pe.useColorConvert(),r=((k=a.locales)==null?void 0:k[i])??(($=a.locales)==null?void 0:$[c])??{},u=r.title||((L=window.blocklet)==null?void 0:L.appName),f=r.description||((U=window.blocklet)==null?void 0:U.appDescription),l=R.autoResizeImage(R.getImageAbsoluteUrl(r.image),540),{logo:p,brand:h,description:j,...b}=de.useHeaderState(),I=g.useMemo(()=>P=>{var S;let v=(n==null?void 0:n(P))??P;return v=((S=b.addons)==null?void 0:S.call(b,v))??v,v},[b.addons,n]),x=(C=r.header)!=null&&C.translucent?ce:ie;return e.jsxs(E.PageProvider,{page:a,defaultLocale:c,currentLocale:i,children:[e.jsx(V.Global,{styles:V.css`
30
- body {
31
- background-color: ${m(!r.backgroundColor||r.backgroundColor==="transparent"?"background.default":r.backgroundColor)} !important;
32
- }
33
- `}),e.jsx(x,{hideNavMenu:!!((d=r.header)!=null&&d.hideNavMenus),translucentTextColor:(s=r.header)==null?void 0:s.translucentTextColor,...p?{logo:p}:{},...h?{brand:h}:{},...j?{description:j}:{},className:fe.cx(((M=r.header)==null?void 0:M.sticky)&&"sticky","page-header"),maxWidth:!1,addons:I}),e.jsx(w.ScrollRestoration,{}),e.jsxs(ve.Helmet,{children:[e.jsx("title",{children:u}),e.jsx("meta",{name:"og:title",content:u}),e.jsx("meta",{name:"og:description",content:f}),e.jsx("meta",{name:"og:image",content:l}),e.jsx("meta",{name:"twitter:image:src",content:l}),e.jsx("meta",{name:"twitter:image",content:l}),e.jsx("meta",{property:"twitter:description",content:f}),e.jsx("meta",{property:"twitter:title",content:u}),e.jsx("meta",{name:"description",content:f})]}),e.jsx(y.Stack,{flexGrow:1,className:"PageView-root",sx:{"& .BlockBase-root:first-child":{pt:"0 !important"}},children:a.sectionIds.map(P=>{var B,O,D,F;const v=a.sections[P];if(!v||v.visibility==="hidden")return null;const S=(O=(B=a.dataSource)==null?void 0:B[P])==null?void 0:O[i],A=((F=(D=a.dataSource)==null?void 0:D[P])==null?void 0:F[c])??{};return e.jsx(E.BlockRenderer,{id:P,type:v.component,mode:t,section:v,config:{...Se.default(S)?A:S,locale:i,dev:t==="draft"?{mode:t,components:o,defaultLocale:c}:{mode:t,defaultLocale:c}},page:a},P)})}),!((T=r.footer)!=null&&T.hidden)&&e.jsx(Ce,{})]})}const De=g.lazy(()=>Promise.resolve().then(()=>require("./publish-button-1xmfwN7o.js"))),ie=oe.default(we.default)`
34
- &.sticky {
35
- position: sticky;
36
- top: 0;
37
- }
38
- `;function Fe({logo:t}){const[o,a]=g.useState(),i=y.useMediaQuery(n=>n.breakpoints.down("sm")),{value:c}=te.useAsync(()=>{var r,u;const n=new URL(i?((r=window==null?void 0:window.blocklet)==null?void 0:r.appLogo)||"/.well-known/service/blocklet/logo":((u=window==null?void 0:window.blocklet)==null?void 0:u.appLogoRect)||"/.well-known/service/blocklet/logo-rect",window.location.origin);n.searchParams.delete("imageFilter"),n.searchParams.delete("f");const m=n.toString();return new Promise(f=>{fetch(m).then(l=>{const p=l.headers.get("content-type");p!=null&&p.includes("svg")&&l.text().then(h=>{a(h),f(null)}),f(l.url)})})},[i]);if(t)return t;if(o)return e.jsx(y.Box,{sx:{filter:"initial !important"},dangerouslySetInnerHTML:{__html:ke.default.sanitize(o)}});if(c){const n=new URL(c);n.searchParams.set("imageFilter","convert"),n.searchParams.set("f","png"),n.searchParams.set("h","80");const m=n.toString();return e.jsx("img",{src:m,alt:"logo"})}return null}function ce({logo:t,translucentTextColor:o,...a}){const[i,c]=g.useState(0),n=y.useTheme(),m=800;g.useEffect(()=>{const l=document.getElementById("app");if(!l)return;let p=!1;const h=()=>{p||(requestAnimationFrame(()=>{c(l.scrollTop),p=!1}),p=!0)};return l.addEventListener("scroll",h,{passive:!0}),c(l.scrollTop),()=>{l.removeEventListener("scroll",h)}},[]);let r=Math.min(i/m,1),u="";r>.1?(r=Math.max(r,.6),u=y.alpha(n.palette.text.primary,r)):u=o||"#EEEEEE";const f=r<.7;return e.jsx(ie,{logo:e.jsx(Fe,{logo:t}),...a,sx:{position:"fixed !important",top:0,left:0,right:0,zIndex:n.zIndex.appBar,backgroundColor:"transparent !important","&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:-1,backgroundColor:y.alpha(n.palette.background.default,r),backdropFilter:r>=.6?"blur(10px)":"blur(0px)",transition:"backgroundColor 0.3s ease-in-out"},transition:"color 0.3s ease-in-out",".navmenu-root>.navmenu-sub>span,\n .navmenu-root>.navmenu-item,\n .header-addons>button,\n .header-addons>a,\n .header-addons>div>button":{color:`${u} !important`},".header-logo":{color:`${u} !important`},"& .navmenu--horizontal":{bgcolor:"transparent !important"},".header-logo > div":{filter:`invert(${f?1:0})`,transition:"filter 0.3s ease-in-out"}}})}const le=oe.default(y.Button)``;exports.Home=Te;exports.HomeView=ae;exports.Loading=se;exports.PageRoutes=N;exports.PageView=H;exports.PageViewByPath=Oe;exports.PageViewWithDataSource=G;exports.TranslucentHeader=ce;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),F=require("./state-BVdbNJCA.js"),W=require("@arcblock/ux/lib/Locale/context"),ee=require("@arcblock/ux/lib/Toast"),te=require("@blocklet/pages-kit/utils/route"),O=require("@mui/icons-material"),J=require("@mui/lab"),s=require("@mui/material"),se=require("immer"),ne=require("lodash/difference"),l=require("react"),ie=require("react-use"),re=require("./home-CQTuGad2.js"),U=require("./array-BqHuYyfx.js"),G=r=>r&&r.__esModule?r:{default:r},$=G(ee),H=G(ne);function oe(r){const[j,k]=l.useState(!1);return e.jsx(J.LoadingButton,{...r,loading:r.loading||j,onClick:u=>{var b;const p=(b=r.onClick)==null?void 0:b.call(r,u);p instanceof Promise&&(k(!0),p.finally(()=>{k(!1)}))}})}const ae=s.createSvgIcon(e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M7.75732 16.2426L16.2426 7.75736",stroke:"#4B5563",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M16.2426 16.2426L7.75732 7.75735",stroke:"#4B5563",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Close");function le(){const[r,j]=l.useState(),k=l.useMemo(()=>r?e.jsx(s.Dialog,{...r}):null,[r]),u=l.useCallback(()=>{j(void 0)},[]),p=l.useCallback(({title:b,content:d,cancelText:S="Cancel",okText:f="Ok",onOk:g,onClose:c,okIcon:P,okColor:w="primary",cancelColor:y="primary",DialogContentProps:A,form:E,...z})=>{j({...z,open:!0,children:e.jsxs("form",{onSubmit:v=>v.preventDefault(),children:[b&&e.jsxs(s.DialogTitle,{className:"between",zIndex:"appBar",bgcolor:"background.paper",sx:{borderBottom:v=>`1px solid ${v.palette.divider}`},children:[e.jsx(s.Box,{children:b}),e.jsx(s.IconButton,{size:"small",onClick:async()=>{u(),c==null||c()},children:e.jsx(ae,{})})]}),d&&e.jsx(s.DialogContent,{...A,sx:{mt:-3,...A==null?void 0:A.sx},children:e.jsx(s.Box,{pt:3,children:d})}),e.jsxs(s.DialogActions,{children:[e.jsx(s.Button,{variant:"outlined",color:y||"primary",onClick:c??u,children:S}),e.jsx(oe,{variant:"contained",color:w||"primary",startIcon:P,loadingPosition:P?"start":"center",onClick:async()=>{await(g==null?void 0:g()),u()},type:"submit",children:f})]})]}),onClose:c??u})},[u]);return{dialog:k,showDialog:p,closeDialog:u}}const ce=l.forwardRef(({mode:r,state:j},k)=>{const{t:u}=W.useLocaleContext(),[p,b]=l.useState(!1),{dialog:d,showDialog:S}=le(),f=F.useProjectId(),g=l.useCallback(P=>{let w=[];S({title:u("maker.publishToProduction"),content:e.jsxs(s.Box,{sx:{minWidth:300},children:[e.jsx(s.Alert,{color:"warning",icon:e.jsx(O.Warning,{}),children:u("maker.publishToProductionTip")}),e.jsx(s.Box,{maxHeight:"50vh",overflow:"auto",mt:2,children:e.jsx(de,{state:j,toMode:r,onChange:y=>w=y,defaultRouteIds:P})})]}),okText:u("maker.publish"),cancelText:u("common.cancel"),onOk:async()=>{if((w==null?void 0:w.length)===0){const y=u("maker.publishSelectPagesMessage");throw $.default.error(y),new Error(y)}localStorage.setItem(F.getProjectPageVersionKey(f??""),String(new Date().getTime())),b(!0);try{await U.publishPages({mode:r,routes:w}),$.default.success(u("maker.publishSuccessMessage"))}catch(y){throw $.default.error(y.message),y}finally{b(!1)}}})},[r,j,u,f,S]);l.useImperativeHandle(k,()=>({openPublishDialog:g}));const c=l.useCallback(()=>{g()},[g]);return e.jsxs(e.Fragment,{children:[e.jsx(J.LoadingButton,{color:"primary",variant:"contained",size:"small",sx:{mr:1},onClick:c,loading:p,disabled:p,children:u("maker.publish")}),d]})});function ue({routePathInfo:r,checked:j,onClick:k,route:u}){var d,S,f,g,c;const{t:p}=W.useLocaleContext(),b=!((d=r.routeMetaData)!=null&&d.publishedAt)||((S=r.routeMetaData)==null?void 0:S.updatedAt)&&new Date((f=r.routeMetaData)==null?void 0:f.updatedAt)>new Date((g=r.routeMetaData)==null?void 0:g.publishedAt);return e.jsx(s.ListItem,{sx:{pl:4,pr:3},disablePadding:!0,secondaryAction:e.jsxs(s.Box,{display:"flex",alignItems:"center",sx:{minWidth:"auto"},children:[b&&e.jsx(s.Box,{mr:.35,className:"visible",color:"warning.main",sx:{display:"flex",alignItems:"center"},title:p("maker.pages.needPublish"),children:e.jsx(s.Tooltip,{title:p("maker.pages.needPublish"),children:e.jsx(O.Sync,{fontSize:"small",sx:{fontSize:"16px"}})})}),(!((c=r.routeMetaData)!=null&&c.isPublic)||!u.isPublic)&&e.jsx(s.Box,{className:"visible",color:"warning.main",children:e.jsx(s.Tooltip,{title:p("maker.pages.notPublic"),children:e.jsx(O.VisibilityOff,{fontSize:"small",sx:{fontSize:"16px"}})})})]}),children:e.jsxs(s.ListItemButton,{onClick:k,dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:j,tabIndex:-1})}),e.jsx(s.ListItemText,{primary:r.path,primaryTypographyProps:{fontSize:"0.8rem",fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pr:1}})]})})}function de({state:r,toMode:j,onChange:k,defaultRouteIds:u}){const{t:p,locale:b}=W.useLocaleContext(),[d,S]=l.useState(!1),[f,g]=l.useState(()=>u?Object.fromEntries(u.filter(t=>!t.includes("-")).map(t=>[t,!0])):{}),[c,P]=l.useState({}),[w,y]=l.useState(()=>u?Object.fromEntries(u.filter(t=>t.includes("-")).map(t=>[t,!0])):{}),[A,E]=l.useState({}),{loading:z,error:v,value:x}=ie.useAsync(()=>U.getPages({mode:j}),[j]);if(v)throw v;const D=l.useMemo(()=>r.routeIds||[],[r]),I=l.useMemo(()=>(x==null?void 0:x.pageIds)||[],[x]),T=l.useMemo(()=>!D||!r.routes?[]:JSON.parse(JSON.stringify(D)).sort((o,i)=>{var h,m;const n=(h=r.routes)==null?void 0:h[o],a=(m=r.routes)==null?void 0:m[i];return n!=null&&n.publishedAt&&new Date(n.publishedAt).getTime()<new Date(n.updatedAt).getTime()?-1:a!=null&&a.publishedAt&&new Date(a.publishedAt).getTime()<new Date(a.updatedAt).getTime()?1:new Date((n==null?void 0:n.updatedAt)??"").getTime()-new Date((a==null?void 0:a.updatedAt)??"").getTime()}),[r,D]),q=l.useMemo(()=>{if(!T)return[];if(!c)return T;const t=[...T].filter(o=>!c[o]);return Object.values(c).forEach(o=>{o.forEach(i=>{t.push(`${i.originalRouteId}-${i.paramOptionIds.join("-")}`)})}),t},[T,c]),B=l.useMemo(()=>!x||!I||!q?[]:H.default(I,q),[q,x,I]),C=l.useMemo(()=>D?[...D].concat(B):B,[D,B]),_=l.useCallback(()=>{const t={};T==null||T.forEach(o=>{var n;const i=(n=r.routes)==null?void 0:n[o];if(i&&i.params&&i.params.length>0&&i.paramsOptions&&i.paramsOptions.length>0){const a=te.generateParamCombinations({basePath:i.path,params:i.params,routeId:i.id,paramsOptions:i.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});a.length>0&&(t[i.id]=a)}}),P(t)},[T,r.routes]);l.useEffect(()=>{_()},[_]),l.useEffect(()=>{E(t=>{const o={...t};return Object.keys(c).forEach(i=>{var n;c[i]&&((n=c[i])==null?void 0:n.length)>0&&o[i]===void 0&&(o[i]=!0)}),o})},[c]);const K=l.useRef(!0);l.useEffect(()=>{y(t=>{const o={...t};return Object.keys(c).length===0||(Object.keys(c).forEach(i=>{const n=c[i]||[],a=d||!!f[i];n.forEach(h=>{const m=`${i}-${h.paramOptionIds.join("-")}`;K.current?o[m]=a||t[m]||!1:o[m]=a})}),K.current=!1),o})},[f,c,d]);const Q=(t,o)=>{o.stopPropagation(),E(i=>{const n={...i};return n[t]=!n[t],n})},N=l.useCallback(t=>{g(o=>{const i=se.produce(o,n=>{d?(Object.assign(n,Object.fromEntries(C.map(a=>[a,!0]))),delete n[t]):n[t]?(delete n[t],B.includes(t)&&(D||[]).filter(a=>{var h,m;return((h=r.pages[a])==null?void 0:h.slug)===((m=x==null?void 0:x.pages[t])==null?void 0:m.slug)}).forEach(a=>{delete n[a]})):(n[t]=!0,D&&D.includes(t)&&B.filter(a=>{var h,m;return((h=x==null?void 0:x.pages[a])==null?void 0:h.slug)===((m=r.pages[t])==null?void 0:m.slug)}).forEach(a=>{n[a]=!0}))});return S(H.default(C,Object.keys(i)).length===0),i})},[d,C,B,r,x,D]),X=l.useCallback((t,o)=>{const i=`${t}-${o.paramOptionIds.join("-")}`;y(n=>{var m;const a={...n};a[i]=!a[i];const h=((m=c[t])==null?void 0:m.every(L=>a[`${t}-${L.paramOptionIds.join("-")}`]))??!1;return g(L=>{if(h&&!L[t])return{...L,[t]:!0};if(!h&&L[t]){const R={...L};return delete R[t],R}return L}),a})},[c]),Y=l.useCallback(()=>{S(t=>(t&&g({}),!t))},[]);return l.useEffect(()=>{const t=d?C:Object.keys(f),o=Object.entries(w).filter(([,n])=>n).map(([n])=>n).filter(n=>n!==void 0),i=Array.from(new Set([...t,...o]));k(d?null:i)},[d,f,w,C,k]),z?e.jsx(re.Loading,{sx:{my:4}}):e.jsxs(s.List,{disablePadding:!0,sx:{maxWidth:700},children:[e.jsx(s.ListItem,{sx:{position:"sticky",top:0,bgcolor:"background.paper",zIndex:1},disablePadding:!0,children:e.jsxs(s.ListItemButton,{onClick:Y,dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:d,tabIndex:-1})}),e.jsx(s.ListItemText,{primary:p("common.all")})]})}),T.map(t=>{var L,R;const o=(L=r.routes)==null?void 0:L[t];if(!o)return null;const i=!1,n=c&&c[t]&&((R=c[t])==null?void 0:R.length)>0,a=A[t]!==!1,h=c[t]||[],m=!o.publishedAt||o.updatedAt&&new Date(o.updatedAt).getTime()>new Date(o.publishedAt).getTime();return e.jsxs(s.Box,{children:[e.jsx(s.ListItem,{sx:{pr:4},disablePadding:!0,secondaryAction:e.jsxs(s.Box,{sx:{display:"flex",alignItems:"center"},children:[m&&e.jsx(s.Tooltip,{title:p("maker.pages.needPublish"),children:e.jsx(O.Sync,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),!o.isPublic&&e.jsx(s.Tooltip,{title:p("maker.pages.notPublic"),children:e.jsx(O.VisibilityOff,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),i,n&&e.jsx(s.Box,{onClick:M=>Q(t,M),sx:{display:"inline-flex",alignItems:"center",mr:.35,cursor:"pointer",color:"info.main"},children:a?e.jsx(O.KeyboardArrowDown,{fontSize:"small",sx:{fontSize:"18px"}}):e.jsx(O.KeyboardArrowRight,{fontSize:"small",sx:{fontSize:"18px"}})})]}),children:e.jsxs(s.ListItemButton,{onClick:()=>N(t),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:d||!!f[t],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:o.path,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})}),n&&e.jsx(s.Collapse,{in:a,children:e.jsx(s.Box,{children:h.map(M=>{const V=`${t}-${M.paramOptionIds.join("-")}`,Z=w[V]||!1;return e.jsx(ue,{routePathInfo:M,checked:d||Z,onClick:()=>X(t,M),route:o},V)})})})]},t)}),B.map(t=>{var i,n;const o=x==null?void 0:x.pages[t];return o?e.jsx(s.ListItem,{disablePadding:!0,secondaryAction:e.jsx(s.Chip,{color:"warning",label:"deleted",size:"small"}),children:e.jsxs(s.ListItemButton,{onClick:()=>N(t),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:d||!!f[t],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:o.slug,secondary:(n=(i=o.locales)==null?void 0:i[b])==null?void 0:n.title,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})},t):null})]})}exports.default=ce;