@blocklet/pages-kit-inner-components 0.4.43 → 0.4.44
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/_chunks/{draft-data-kZlleQ4E.js → draft-data-CMqq2YH1.js} +1 -1
- package/lib/cjs/_chunks/{home-Ce3-4w2I.js → home-BFxAZSGy.js} +3 -3
- package/lib/cjs/_chunks/{publish-button-NBzp4nrV.js → publish-button-DFR8IHQq.js} +1 -1
- package/lib/cjs/_chunks/state-BjeG4kYg.js +1 -0
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/setting.js +3 -3
- package/lib/es/_chunks/{draft-data-CkmH99IX.js → draft-data-vlK5oTGT.js} +1 -1
- package/lib/es/_chunks/{home-DDJ3wLld.js → home-BTLUdaL7.js} +3 -3
- package/lib/es/_chunks/{publish-button-Ca4oEKdb.js → publish-button-BWD3lOEM.js} +2 -2
- package/lib/es/_chunks/{state-kKXkQecK.js → state-DqChB5ys.js} +90 -89
- package/lib/es/home.js +2 -2
- package/lib/es/setting.js +525 -523
- package/package.json +3 -3
- package/lib/cjs/_chunks/state-B6B5oPws.js +0 -1
|
@@ -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-BjeG4kYg.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";var Ve=Object.create;var pe=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var Xe=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of De(t))!Ke.call(e,r)&&r!==o&&pe(e,r,{get:()=>t[r],enumerable:!(i=Ge(t,r))||i.enumerable});return e};var xe=(e,t,o)=>(o=e!=null?Ve(Je(e)):{},Xe(t||!e||!e.__esModule?pe(o,"default",{value:e,enumerable:!0}):o,e));const n=require("react/jsx-runtime"),w=require("./state-
|
|
1
|
+
"use strict";var Ve=Object.create;var pe=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var Xe=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of De(t))!Ke.call(e,r)&&r!==o&&pe(e,r,{get:()=>t[r],enumerable:!(i=Ge(t,r))||i.enumerable});return e};var xe=(e,t,o)=>(o=e!=null?Ve(Je(e)):{},Xe(t||!e||!e.__esModule?pe(o,"default",{value:e,enumerable:!0}):o,e));const n=require("react/jsx-runtime"),w=require("./state-BjeG4kYg.js"),ke=require("@arcblock/ux/lib/Locale/context"),Ye=require("@arcblock/ux/lib/Result"),Qe=require("@blocklet/pages-kit/builtin/page/header"),Ze=require("@blocklet/ui-react/lib/Header"),_=require("@emotion/css"),Q=require("@emotion/react"),et=require("@emotion/styled"),p=require("@mui/material"),$e=require("ahooks"),tt=require("isomorphic-dompurify"),A=require("lodash"),nt=require("lodash/isEmpty"),g=require("react"),ot=require("react-helmet"),B=require("react-router-dom"),U=require("react-use"),P=require("ufo");require("@mui/icons-material");const K=require("@blocklet/ai-runtime/components"),rt=require("@mui/utils"),it=require("lodash/pick"),st=require("react-error-boundary"),ee=require("@iconify/react"),at=require("react-markdown"),ct=require("remark-gfm"),lt=require("@mui/lab"),$=require("@arcblock/ux/lib/Theme"),dt=require("@arcblock/react-hooks/lib/useBrowser"),ut=require("@arcblock/ux/lib/Colors"),re=require("@blocklet/pages-kit/components"),mt=require("@mui/material/useMediaQuery"),Se=require("@iconify-icon/react"),pt=require("@arcblock/ux/lib/Screenshot"),xt=require("lodash/omit"),ft=require("@arcblock/ux/lib/Button"),ht=require("is-uri"),X=require("pathe"),gt=require("@blocklet/embed/message"),bt=require("lodash/isEqual"),yt=require("@blocklet/embed/react"),jt=require("react-twitter-embed"),wt=require("@blocklet/ui-react/lib/Footer"),_t=require("webfontloader"),vt=require("@arcblock/did-connect/lib/Session"),S=e=>e&&e.__esModule?e:{default:e},Ce=S(Ye),kt=S(Ze),Be=S(et),$t=S(tt),St=S(nt),Ie=S(g),ie=S(it),Ct=S(at),Bt=S(ct),It=S(dt),fe=S(ut),Ne=S(mt),Nt=S(pt),q=S(xt),Pt=S(ft),te=S(ht),Rt=S(bt),Tt=S(wt),qt=S(_t);function Et(e,t,o,i){e.locales||(e.locales={}),e.locales[o]=e.locales[o]||{},e.locales[o].title=i.title??e.locales[o].title,e.locales[o].image=i.image??e.locales[o].image,e.locales[o].description=i.description??e.locales[o].description,Object.entries(i.sectionsData).forEach(([r,s])=>{var c,l,d,m;const a=Object.values(e.sections).find(u=>u.id===r||u.name===r);if(a&&a.isTemplateSection)if(a.locales=a.locales||{},a.locales[o]=a.locales[o]||{},a.component==="custom-component"){const u=(c=a.config)==null?void 0:c.componentId;if(!u)return;const f=((l=t.components[u])==null?void 0:l.data)||((m=(d=t.resources.components)==null?void 0:d[u])==null?void 0:m.component);if(!f)return;a.locales[o].properties=a.locales[o].properties||{},Object.entries(s||{}).forEach(([x,y])=>{var h,v;const j=((h=f==null?void 0:f.properties)==null?void 0:h[x])||Object.values((f==null?void 0:f.properties)||{}).find(b=>{var k;return((k=b.data)==null?void 0:k.key)===x});j&&(a.locales[o].properties[(v=j.data)==null?void 0:v.id]={value:y})})}else a.locales[o]={...a.locales[o],...s||{}}})}const zt=g.forwardRef(({onClick:e,...t},o)=>{const[i,r]=g.useState(!1),s=g.useCallback(async a=>{try{r(!0),await(e==null?void 0:e(a))}finally{r(!1)}},[e]);return n.jsx(lt.LoadingButton,{ref:o,...t,loading:t.loading||i,onClick:s})});function Wt({tip:e,tipSucceed:t,title:o,titleSucceed:i,icon:r,iconSucceed:s,autoReset:a,placement:c="top",...l}){const[d,m]=g.useState(!1),[u,f]=g.useState(),x=g.useRef(),y=()=>{f(void 0),a&&(x.current=window.setTimeout(()=>{m(!1)},3e3))},j=()=>{clearTimeout(x.current)},h=d?s:r,v=u?n.jsx(p.Box,{color:"error",children:u.message}):d&&t||e,b=d?i:o;return n.jsx(p.Tooltip,{title:v,disableInteractive:!0,placement:c,onClose:y,onOpen:j,children:n.jsx("span",{children:n.jsx(zt,{startIcon:h&&(typeof h=="string"?n.jsx(ee.Icon,{icon:h}):h),loadingPosition:h?"start":void 0,...l,onClick:async k=>{if(l.onClick)try{await l.onClick(k),m(!0)}catch(N){f(N)}},children:b})})})}const Lt=Ie.default.lazy(()=>import("react-syntax-highlighter").then(e=>({default:e.Prism}))),At=p.styled(e=>n.jsx(Ct.default,{...e,remarkPlugins:[Bt.default],components:{pre:Ot,code:({node:t,inline:o,className:i,children:r,...s})=>{if(!r)return null;const a=/language-(\w+)/.exec(i||"");return o?n.jsx(p.Box,{component:"code",className:i,...s,children:r}):n.jsx(p.Box,{component:Lt,language:a==null?void 0:a[1],...s,sx:{borderRadius:1},children:String(r).replace(/\n$/,"")})},table:({className:t,children:o})=>n.jsx(p.Box,{sx:{overflow:"auto",my:1},children:n.jsx("table",{className:t,children:o})})}}))`
|
|
2
2
|
width: 100%;
|
|
3
3
|
overflow: hidden;
|
|
4
4
|
word-break: break-word;
|
|
@@ -530,11 +530,11 @@
|
|
|
530
530
|
font-family: ${JSON.stringify(t)}, ${_e};
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
|
-
`})}const{SessionProvider:uo,SessionContext:Qn,SessionConsumer:mo,withSession:po}=vt.createAuthServiceSessionContext();function ce(){return g.useContext(Qn)}function Zn(...e){var o;const{session:t}=ce();return e.includes((o=t.user)==null?void 0:o.role)}function eo(...e){var i;const{session:t}=ce(),o=Zn(...e);return((i=window.blocklet)==null?void 0:i.tenantMode)==="multiple"?!!t.user:o}function to(e){return e!=null}function no(){const[e]=B.useSearchParams(),{session:t}=ce(),o=eo("owner","admin","pagesEditor","member"),i=g.useMemo(()=>{const s=e.get("mode");return An.includes(s)?s:"production"},[e]),r=i==="production"?i:t.user?o?i:"production":null;return r?n.jsx(Oe,{mode:r}):null}function Oe({mode:e}){if(e!=="draft"){const t=window.__PAGE_STATE__;return t?n.jsx(Y,{mode:e,state:t}):n.jsx(ro,{mode:e,children:({state:o})=>n.jsx(Y,{mode:e,state:o})})}return n.jsx(oo,{children:({state:t})=>n.jsx(Y,{mode:e,state:t})})}const oo=g.lazy(()=>Promise.resolve().then(()=>require("./draft-data-
|
|
533
|
+
`})}const{SessionProvider:uo,SessionContext:Qn,SessionConsumer:mo,withSession:po}=vt.createAuthServiceSessionContext();function ce(){return g.useContext(Qn)}function Zn(...e){var o;const{session:t}=ce();return e.includes((o=t.user)==null?void 0:o.role)}function eo(...e){var i;const{session:t}=ce(),o=Zn(...e);return((i=window.blocklet)==null?void 0:i.tenantMode)==="multiple"?!!t.user:o}function to(e){return e!=null}function no(){const[e]=B.useSearchParams(),{session:t}=ce(),o=eo("owner","admin","pagesEditor","member"),i=g.useMemo(()=>{const s=e.get("mode");return An.includes(s)?s:"production"},[e]),r=i==="production"?i:t.user?o?i:"production":null;return r?n.jsx(Oe,{mode:r}):null}function Oe({mode:e}){if(e!=="draft"){const t=window.__PAGE_STATE__;return t?n.jsx(Y,{mode:e,state:t}):n.jsx(ro,{mode:e,children:({state:o})=>n.jsx(Y,{mode:e,state:o})})}return n.jsx(oo,{children:({state:t})=>n.jsx(Y,{mode:e,state:t})})}const oo=g.lazy(()=>Promise.resolve().then(()=>require("./draft-data-CMqq2YH1.js")));function ro({mode:e,children:t}){const o=document.querySelector('meta[property="pages:version"]'),i=o==null?void 0:o.content,r=w.useProjectId(),s=g.useMemo(()=>{if(i==="{{pagesPublishedAt}}"){const l=localStorage.getItem(w.getProjectPageVersionKey(r??""));return Number(l)?Number(l):new Date().getTime()}return Number(i)},[i]),{loading:a,value:c}=U.useAsync(()=>Le({mode:e,version:s}),[e,s]);return a?n.jsx(Ae,{}):c?t({state:c}):null}function Y({mode:e,state:t}){var y,j,h,v;const{t:o,locale:i}=ke.useLocaleContext(),{pageIds:r,pages:s,supportedLocales:a,config:{defaultLocale:c},resources:l}=t,d=w.getAllComponents(t),m=g.useMemo(()=>a!=null&&a.some(b=>b.locale===i)?i:void 0,[i,a]),u=Object.values(s).find(b=>(b==null?void 0:b.slug)==="/")?void 0:Object.values(s)[0],f=g.useMemo(()=>r.map(b=>{const k=s[b];return k&&{id:k.id,path:P.joinURL("/",m||"",k.slug,e!=="production"?`?mode=${e}`:"")}}).filter(to),[r,s,m,e]),x=([...b])=>(e!=="production"&&b.unshift(n.jsx(g.Suspense,{fallback:n.jsx("div",{}),children:n.jsx(so,{mode:"production",state:t})})),b);return n.jsxs(en,{value:{pages:f},children:[n.jsxs(B.Routes,{children:[u&&n.jsx(B.Route,{index:!0,element:n.jsx(B.Navigate,{to:P.joinURL("/",m||"",u.slug)})}),r.map(b=>{const k=s[b];return k?n.jsx(B.Route,{path:P.joinURL(":projectIdOrSlug?",k.slug),element:n.jsx(Z,{mode:e,components:d,page:k,locale:m,defaultLocale:c,headerAddons:x})},k.id):null}),l.pages&&Object.values(l.pages).map(({blockletId:b,page:k})=>n.jsx(B.Route,{path:P.joinURL("/",`@${b}`,k.slug),element:n.jsx(Z,{mode:e,components:d,page:k,locale:m,defaultLocale:c,headerAddons:x})},k.id)),n.jsx(B.Route,{path:"*",element:n.jsx(p.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:n.jsx(Ce.default,{style:{background:"inherit"},status:404,extra:n.jsx(Me,{href:"/",children:o("common.back")})})})})]}),e!=="production"&&n.jsx(Jn,{sx:{bgcolor:"info.light"},children:e}),n.jsx(Yn,{titleFontFamily:(j=(y=t.config)==null?void 0:y.fontFamily)==null?void 0:j.title,descriptionFontFamily:(v=(h=t.config)==null?void 0:h.fontFamily)==null?void 0:v.description})]})}function io({mode:e,state:t,path:o,pageData:i}){const{t:r,locale:s}=ke.useLocaleContext(),{pages:a,supportedLocales:c,config:{defaultLocale:l},resources:d}=t,m=Object.values(a).find(h=>(h==null?void 0:h.slug)===o),u=Object.values(d.pages||{}).find(h=>h.page.slug===o),f=g.useMemo(()=>c!=null&&c.some(h=>h.locale===s)?s:void 0,[s,c]),x=$e.useReactive({page:null});g.useEffect(()=>{const h=m||(u==null?void 0:u.page)||null;h?x.page=A.cloneDeep(h):x.page=null},[m,u]);const y=g.useRef();if(g.useEffect(()=>{A.isEqual(i,y.current)||i&&x.page&&(Et(x.page,t,f,i),y.current=A.cloneDeep(i))},[{}]),!m&&!(u!=null&&u.page))return n.jsx(p.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:n.jsx(Ce.default,{style:{background:"inherit"},status:404,extra:n.jsx(Me,{href:"/",children:r("common.back")})})});const j=w.getAllComponents(t);return x.page?n.jsx(Z,{mode:e,components:j,page:x.page,locale:f,defaultLocale:l}):null}function Z({mode:e,components:t,page:o,locale:i,defaultLocale:r,headerAddons:s}){var h,v,b,k,N,W,J,le,de;const a=((h=o.locales)==null?void 0:h[i])??((v=o.locales)==null?void 0:v[r])??{},c=a.title||((b=window.blocklet)==null?void 0:b.appName),l=a.description||((k=window.blocklet)==null?void 0:k.appDescription),d=w.autoResizeImage(w.getImageAbsoluteUrl(a.image),540),{logo:m,brand:u,description:f,...x}=Qe.useHeaderState(),y=g.useMemo(()=>E=>{var L;let C=(s==null?void 0:s(E))??E;return C=((L=x.addons)==null?void 0:L.call(x,C))??C,C},[x.addons,s]),j=(N=a.header)!=null&&N.translucent?He:Ue;return n.jsxs(n.Fragment,{children:[!!a.backgroundColor&&n.jsx(Q.Global,{styles:Q.css`
|
|
534
534
|
body {
|
|
535
535
|
background-color: ${a.backgroundColor} !important;
|
|
536
536
|
}
|
|
537
|
-
`}),n.jsx(j,{hideNavMenu:!!((W=a.header)!=null&&W.hideNavMenus),translucentTextColor:(J=a.header)==null?void 0:J.translucentTextColor,...m?{logo:m}:{},...u?{brand:u}:{},...f?{description:f}:{},className:_.cx(((le=a.header)==null?void 0:le.sticky)&&"sticky","page-header"),maxWidth:!1,addons:y}),n.jsx(B.ScrollRestoration,{}),n.jsxs(ot.Helmet,{children:[n.jsx("title",{children:c}),n.jsx("meta",{name:"og:title",content:c}),n.jsx("meta",{name:"og:description",content:l}),n.jsx("meta",{name:"og:image",content:d}),n.jsx("meta",{name:"twitter:image:src",content:d}),n.jsx("meta",{name:"twitter:image",content:d}),n.jsx("meta",{property:"twitter:description",content:l}),n.jsx("meta",{property:"twitter:title",content:c}),n.jsx("meta",{name:"description",content:l})]}),n.jsx(p.Stack,{flexGrow:1,children:o.sectionIds.map(E=>{var ue,me;const C=o.sections[E];if(!C||C.visibility==="hidden")return null;const L=(ue=C.locales)==null?void 0:ue[i],Fe=((me=C.locales)==null?void 0:me[r])??{};return n.jsx(Vn,{id:E,type:C.component,mode:e,section:C,config:{...St.default(L)?Fe:L,locale:i,dev:e==="draft"?{mode:e,components:t,defaultLocale:r}:{mode:e}}},E)})}),!((de=a.footer)!=null&&de.hidden)&&n.jsx(Dn,{})]})}const so=g.lazy(()=>Promise.resolve().then(()=>require("./publish-button-
|
|
537
|
+
`}),n.jsx(j,{hideNavMenu:!!((W=a.header)!=null&&W.hideNavMenus),translucentTextColor:(J=a.header)==null?void 0:J.translucentTextColor,...m?{logo:m}:{},...u?{brand:u}:{},...f?{description:f}:{},className:_.cx(((le=a.header)==null?void 0:le.sticky)&&"sticky","page-header"),maxWidth:!1,addons:y}),n.jsx(B.ScrollRestoration,{}),n.jsxs(ot.Helmet,{children:[n.jsx("title",{children:c}),n.jsx("meta",{name:"og:title",content:c}),n.jsx("meta",{name:"og:description",content:l}),n.jsx("meta",{name:"og:image",content:d}),n.jsx("meta",{name:"twitter:image:src",content:d}),n.jsx("meta",{name:"twitter:image",content:d}),n.jsx("meta",{property:"twitter:description",content:l}),n.jsx("meta",{property:"twitter:title",content:c}),n.jsx("meta",{name:"description",content:l})]}),n.jsx(p.Stack,{flexGrow:1,children:o.sectionIds.map(E=>{var ue,me;const C=o.sections[E];if(!C||C.visibility==="hidden")return null;const L=(ue=C.locales)==null?void 0:ue[i],Fe=((me=C.locales)==null?void 0:me[r])??{};return n.jsx(Vn,{id:E,type:C.component,mode:e,section:C,config:{...St.default(L)?Fe:L,locale:i,dev:e==="draft"?{mode:e,components:t,defaultLocale:r}:{mode:e}}},E)})}),!((de=a.footer)!=null&&de.hidden)&&n.jsx(Dn,{})]})}const so=g.lazy(()=>Promise.resolve().then(()=>require("./publish-button-DFR8IHQq.js"))),Ue=Be.default(kt.default)`
|
|
538
538
|
&.sticky {
|
|
539
539
|
position: sticky;
|
|
540
540
|
top: 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./state-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./state-BjeG4kYg.js"),q=require("@arcblock/ux/lib/Locale/context"),O=require("@arcblock/ux/lib/Toast"),S=require("@mui/icons-material"),E=require("@mui/lab"),s=require("@mui/material"),W=require("immer"),z=require("lodash/difference"),c=require("react"),_=require("react-use"),C=require("./home-BFxAZSGy.js"),M=t=>t&&t.__esModule?t:{default:t},A=M(O),D=M(z);function N(t){const[d,b]=c.useState(!1);return e.jsx(E.LoadingButton,{...t,loading:t.loading||d,onClick:i=>{var h;const m=(h=t.onClick)==null?void 0:h.call(t,i);m instanceof Promise&&(b(!0),m.finally(()=>{b(!1)}))}})}const R=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 F(){const[t,d]=c.useState(),b=c.useMemo(()=>t?e.jsx(s.Dialog,{...t}):null,[t]),i=c.useCallback(()=>{d(void 0)},[]),m=c.useCallback(({title:h,content:g,cancelText:T="Cancel",okText:p="Ok",onOk:f,onClose:k,okIcon:L,okColor:n="primary",cancelColor:y="primary",DialogContentProps:u,form:x,...I})=>{d({...I,open:!0,children:e.jsxs("form",{onSubmit:P=>P.preventDefault(),children:[h&&e.jsxs(s.DialogTitle,{className:"between",zIndex:"appBar",bgcolor:"background.paper",sx:{borderBottom:"1px solid #E5E7EB"},children:[e.jsx(s.Box,{children:h}),e.jsx(s.IconButton,{size:"small",onClick:async()=>{i(),k==null||k()},children:e.jsx(R,{})})]}),g&&e.jsx(s.DialogContent,{...u,sx:{mt:-3,...u==null?void 0:u.sx},children:e.jsx(s.Box,{pt:3,children:g})}),e.jsxs(s.DialogActions,{children:[e.jsx(s.Button,{variant:"outlined",color:y||"primary",onClick:k??i,children:T}),e.jsx(N,{variant:"contained",color:n||"primary",startIcon:L,loadingPosition:L?"start":"center",onClick:async()=>{await(f==null?void 0:f()),i()},type:"submit",children:p})]})]}),onClose:k??i})},[i]);return{dialog:b,showDialog:m,closeDialog:i}}const H=c.forwardRef(({mode:t,state:d},b)=>{const{t:i}=q.useLocaleContext(),[m,h]=c.useState(!1),{dialog:g,showDialog:T}=F(),p=v.useProjectId(),f=c.useCallback(L=>{let n=[];T({title:i("maker.publishToProduction"),content:e.jsxs(s.Box,{sx:{minWidth:300},children:[e.jsx(s.Alert,{color:"warning",icon:e.jsx(S.Warning,{}),children:i("maker.publishToProductionTip")}),e.jsx(s.Box,{maxHeight:"50vh",overflow:"auto",mt:2,children:e.jsx(J,{state:d,toMode:t,onChange:y=>n=y,defaultPageIds:L})})]}),okText:i("maker.publish"),cancelText:i("common.cancel"),onOk:async()=>{var y,u;if((n==null?void 0:n.length)===0){const x=i("maker.publishSelectPagesMessage");throw A.default.error(x),new Error(x)}for(const x of n??d.pageIds){const I=d.pages[x];if(I){const P=(u=(y=v.checkPage(i,I,d))==null?void 0:y[0])==null?void 0:u.message;if(P)throw A.default.error(P),new Error(P)}}localStorage.setItem(v.getProjectPageVersionKey(p??""),String(new Date().getTime())),h(!0);try{await C.publishPages({mode:t,pages:n}),A.default.success(i("maker.publishSuccessMessage"))}catch(x){throw A.default.error(x.message),x}finally{h(!1)}}})},[t,d,i,p,T]);c.useImperativeHandle(b,()=>({openPublishDialog:f}));const k=c.useCallback(()=>{f()},[f]);return e.jsxs(e.Fragment,{children:[e.jsx(E.LoadingButton,{color:"primary",variant:"contained",size:"small",sx:{mr:2},onClick:k,loading:m,disabled:m,children:i("maker.publishToProduction")}),g]})});function J({state:t,toMode:d,onChange:b,defaultPageIds:i}){const{t:m,locale:h}=q.useLocaleContext(),[g,T]=c.useState(!1),[p,f]=c.useState(()=>i?Object.fromEntries(i.map(r=>[r,!0])):{}),{loading:k,error:L,value:n}=_.useAsync(()=>C.getPages({mode:d}),[d]);if(L)throw L;const y=c.useMemo(()=>JSON.parse(JSON.stringify(t.pageIds)).sort((a,j)=>{const o=t.pages[a],l=t.pages[j];return o!=null&&o.publishedAt&&new Date(o.publishedAt).getTime()<new Date(o.updatedAt).getTime()?-1:l!=null&&l.publishedAt&&new Date(l.publishedAt).getTime()<new Date(l.updatedAt).getTime()?1:new Date((o==null?void 0:o.updatedAt)??"").getTime()-new Date((l==null?void 0:l.updatedAt)??"").getTime()}),[t]),u=c.useMemo(()=>n?D.default(n.pageIds,t.pageIds):[],[t,n]),x=c.useMemo(()=>[...t.pageIds].concat(u),[t,u]),I=c.useCallback(r=>{f(a=>{const j=W.produce(a,o=>{g?(Object.assign(o,Object.fromEntries(x.map(l=>[l,!0]))),delete o[r]):o[r]?(delete o[r],u.includes(r)&&t.pageIds.filter(l=>{var w,B;return((w=t.pages[l])==null?void 0:w.slug)===((B=n==null?void 0:n.pages[r])==null?void 0:B.slug)}).forEach(l=>{delete o[l]})):(o[r]=!0,t.pageIds.includes(r)&&u.filter(l=>{var w,B;return((w=n==null?void 0:n.pages[l])==null?void 0:w.slug)===((B=t.pages[r])==null?void 0:B.slug)}).forEach(l=>{o[l]=!0}))});return T(D.default(x,Object.keys(j)).length===0),j})},[g,x,u,t,n]),P=c.useCallback(()=>{T(r=>(r&&f({}),!r))},[p]);return c.useEffect(()=>{b(g?null:Object.keys(p))},[g,p,b]),k?e.jsx(C.Loading,{sx:{my:4}}):e.jsxs(s.List,{disablePadding:!0,sx:{maxWidth:500},children:[e.jsx(s.ListItem,{sx:{position:"sticky",top:0,bgcolor:"background.paper",zIndex:1},disablePadding:!0,children:e.jsxs(s.ListItemButton,{onClick:P,dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:g,tabIndex:-1})}),e.jsx(s.ListItemText,{primary:m("common.all")})]})}),y.map(r=>{var l,w;const a=t.pages[r];if(!a)return null;const j=v.checkPage(m,a,t),o=!a.publishedAt||a.updatedAt&&new Date(a.updatedAt).getTime()>new Date(a.publishedAt).getTime();return e.jsx(s.ListItem,{disablePadding:!0,secondaryAction:e.jsxs(e.Fragment,{children:[o&&e.jsx(s.Tooltip,{title:m("maker.pages.needPublish"),children:e.jsx(S.Sync,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),!a.isPublic&&e.jsx(s.Tooltip,{title:m("maker.pages.notPublic"),children:e.jsx(S.VisibilityOff,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),j&&e.jsx(v.PageErrorTip,{errors:j,children:e.jsx(S.Warning,{sx:{color:"error.dark",mr:.35}})})]}),children:e.jsxs(s.ListItemButton,{onClick:()=>I(r),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:g||!!p[r],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:a.slug,secondary:(w=(l=a.locales)==null?void 0:l[h])==null?void 0:w.title,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})},r)}),u.map(r=>{var j,o;const a=n==null?void 0:n.pages[r];return a?e.jsx(s.ListItem,{disablePadding:!0,secondaryAction:e.jsx(s.Chip,{color:"warning",label:"deleted",size:"small"}),children:e.jsxs(s.ListItemButton,{onClick:()=>I(r),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:g||!!p[r],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:a.slug,secondary:(o=(j=a.locales)==null?void 0:j[h])==null?void 0:o.title,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})},r):null})]})}exports.default=H;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const P=require("react/jsx-runtime"),E=require("@mui/material"),Q=require("gradient-parser"),X=require("tinycolor2"),j=require("ufo"),Y=require("@blocklet/js-sdk"),Z=require("lodash/isEmpty"),H=require("yaml"),W=require("@syncedstore/core"),ee=require("@syncedstore/react"),te=require("ahooks"),C=require("immer"),ne=require("js-cookie"),oe=require("lodash/debounce"),re=require("nanoid"),d=require("react"),N=require("react-router-dom"),se=require("y-indexeddb"),ce=require("y-websocket"),ie=require("yjs"),y=e=>e&&e.__esModule?e:{default:e};function ae(e){if(e&&e.__esModule)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const u=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,u.get?u:{enumerable:!0,get:()=>e[i]})}}return n.default=e,Object.freeze(n)}const ue=y(Q),de=y(X),le=y(Z),fe=ae(H),me=y(W),pe=y(ne),F=y(oe);function V(){const{pathname:e}=window.location,n=e.match(/\/admin\/(maker|previewer)\/([^/]+)/),i=n==null?void 0:n[2],u=window.__PROJECT_ID__;if(!i&&!u)throw new Error("Unable to get projectId from pathname");return i||u}function ge(e){return`${e}:pages:version`}function Se(e,n){return n==="yaml"?le.default(e)?"":fe.stringify(e,{indent:2}):n==="json"?JSON.parse(JSON.stringify(e||"{}")):n==="array"?JSON.parse(JSON.stringify(e||"[]")):e}function we({error:e}){return P.jsx(E.Box,{children:P.jsx(E.Alert,{severity:"error",children:e.message})})}var T;const v=((T=window.blocklet)==null?void 0:T.prefix)||"/",O=Y.createAxios({timeout:200*1e3}),he=window.location.protocol==="https:"?"wss":"ws",Pe=e=>j.joinURL(`${he}://${window.location.hostname}`,v,`api/${e}/ws/pages`),je="z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";var $;($=blocklet==null?void 0:blocklet.componentMountPoints.find(e=>e.did===je))!=null&&$.mountPoint||j.joinURL(v,"/image-bin");function ye(e){return e&&!/^(https?:\/\/|\/)/.test(e)?window.location.origin+j.joinURL(v,"uploads",e):e}const ke=window.innerWidth<=750;function be(e,n,i){if(!e||/\.gif/.test(e))return e;const u=(ke?n/1.5:n)*(i==="quality"?1.5:1);return Ie(e,{imageFilter:"resize",w:u,f:"webp"})}function Ie(e,n){return!e||!n?e:j.withQuery(e,n)}function z(e){if(e!=null&&e.trim())try{return ue.default.parse(e),!0}catch{return!1}return!1}function Ee(e){return typeof e!="string"?!1:!!(z(e)||de.default(e).isValid())}async function xe(e){return O.get(`/api/projects/${e}`).then(n=>n.data)}async function Ce(e){return O.post(`/api/projects/${e.id}/update`,e).then(n=>n.data)}const _e=500,_=re.customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789",16),B=d.createContext(null);function ve({url:e,name:n,children:i,waitingSynced:u}){const[f,l]=d.useState(!1),S=L(),k=`${S}:MakerLocalState`,t=`${S}:${n}`,[r,o]=te.useLocalStorageState(k,{defaultValue:{},listenStorageChange:!0}),s=d.useRef(r);s.current=r;const a=d.useMemo(()=>me.default({pages:{},pageIds:[],components:{},supportedLocales:[],config:{},resources:{}}),[]),c=d.useMemo(()=>W.getYjsDoc(a),[a]);d.useMemo(()=>new se.IndexeddbPersistence(t,c),[t,c]);const w=d.useMemo(()=>new ce.WebsocketProvider(e,t,c,{params:{token:pe.default.get("login_token")}}),[e,t,c]),b=d.useMemo(()=>new ie.UndoManager([c.getArray("pageIds"),c.getMap("pages"),c.getArray("supportedLocales"),c.getMap("config")],{doc:c}),[c]),[I,x]=d.useState(null),[A,q]=d.useState(!1),[M,R]=d.useState(void 0),D=d.useCallback(async()=>{if(S){q(!0);try{const m=await xe(S);x(m)}catch(m){console.error("Failed to fetch project:",m)}finally{q(!1)}}},[S]),U=d.useCallback(async(m,p)=>{var h;if(R(void 0),!!S){p!=null&&p.optimisticUpdate&&I&&x(g=>({...g,...m}));try{const g=await Ce({...m});x(g)}catch(g){console.error("Failed to update project:",g),p!=null&&p.optimisticUpdate&&x(I),R((h=g==null?void 0:g.response)==null?void 0:h.data)}}},[S,I]);d.useEffect(()=>{S&&D()},[S,D]);const K=d.useMemo(()=>({doc:c,state:a,localState:r,setLocalState:m=>o(typeof m=="function"?p=>m(p??{}):m),undoManager:b,projectState:{project:I,isLoadingProject:A,error:M},updateProject:U}),[c,a,JSON.stringify(r),o,b,I,A,U,M]);return d.useEffect(()=>{b.on("stack-item-added",({stackItem:m})=>{const{currentPageId:p,currentLocale:h,pages:g}=s.current;m.meta.set("localState",{currentPageId:p,currentLocale:h,pages:g})}),b.on("stack-item-popped",({stackItem:m})=>{const p=m.meta.get("localState");p&&o(h=>({...h,...p}))})},[b,o]),d.useEffect(()=>{w.awareness.setLocalState(r)},[w,r]),d.useEffect(()=>{w.once("synced",()=>l(!0));const m=()=>{o(g=>({...g,networkStatus:void 0}))},p=()=>{o(g=>({...g,networkStatus:"offline"}))},h=F.default(({status:g})=>{g==="connected"?m():g==="disconnected"&&p()},_e);return w.on("status",h),window.addEventListener("online",m),window.addEventListener("offline",p),()=>{w.off("status",h),window.removeEventListener("online",m),window.removeEventListener("offline",p)}},[w,o]),u&&!f?null:P.jsx(B.Provider,{value:K,children:i})}const G=()=>{const e=d.useContext(B);if(!e)throw new Error("Context is null");const n=ee.useSyncedStore(e.state),{setLocalState:i,localState:u}=e,f=N.useNavigate(),l=L(),S=d.useMemo(()=>({setCurrentSectionId:(t,r)=>{var o,s;t===u.currentPageId&&r===((s=(o=u.pages)==null?void 0:o[t])==null?void 0:s.currentSectionId)||(f(j.joinURL("/admin/maker",l??"","pages",t)),i(a=>C.produce(a,c=>{var w;c.currentPageId=t,c.currentComponentId=void 0,c.componentDebugProps={},r!==void 0&&(c.pages??(c.pages={}),(w=c.pages)[t]??(w[t]={}),c.pages[t].currentSectionId=r??void 0),r?window.sessionStorage.setItem("iframe_show_id",`"${r}"`):window.sessionStorage.removeItem("iframe_show_id")})))},setCurrentComponentId:t=>{t!==u.currentComponentId&&(f(j.joinURL("/admin/maker",l??"","components",t)),i(r=>C.produce(r,o=>{o.currentComponentId=t,o.componentDebugProps={}})))},setComponentDebugProps:(()=>{const t={},r=F.default(()=>{i(o=>C.produce(o,s=>{s.componentDebugProps={...s==null?void 0:s.componentDebugProps,...t},Object.keys(t).forEach(a=>delete t[a])}))},5);return o=>{Object.assign(t,o),r()}})()}),[i,f,l]),k=d.useMemo(()=>({addPage:(t,r)=>{const o=(t==null?void 0:t.id)??_(),s={...t,id:o,createdAt:(t==null?void 0:t.createdAt)??new Date().toISOString(),updatedAt:(t==null?void 0:t.updatedAt)??new Date().toISOString(),publishedAt:new Date(0).toISOString(),slug:(t==null?void 0:t.slug)??`/${o}`,sections:(t==null?void 0:t.sections)??{},sectionIds:(t==null?void 0:t.sectionIds)??[],isPublic:(t==null?void 0:t.isPublic)??!0,isTemplate:(t==null?void 0:t.isTemplate)??!1};return e.doc.transact(()=>{n.pages[s.id]=s,n.pageIds.splice(r??n.pageIds.length,0,s.id)}),s},deletePage:t=>{const r=n.pageIds.indexOf(t);r!==-1&&e.doc.transact(()=>{n.pageIds.splice(r,1),delete n.pages[t]})},movePage:(t,r)=>{const{pageIds:o}=n,s=o.indexOf(t);s>=0&&o.splice(r,0,...o.splice(s,1))},addSection:(t,r,o)=>{const s=n.pages[t];if(!s)throw new Error(`Page ${t} is not exists`);const a={...r,id:r.id??_(),isTemplateSection:r.isTemplateSection??!1};return e.doc.transact(()=>{s.sections[a.id]=a,s.sectionIds.splice(o??s.sectionIds.length,0,a.id)}),a},deleteSection:(t,r)=>{const o=n.pages[t];if(!o)throw new Error(`Page ${t} is not exists`);const s=o.sectionIds.indexOf(r);s!==-1&&e.doc.transact(()=>{o.sectionIds.splice(s,1),delete o.sections[r]})},toggleSectionVisibility:(t,r,o)=>{const s=n.pages[t];if(!s)throw new Error(`Page ${t} is not exists`);const a=s.sections[r];a&&(a.visibility=o)},moveSection:(t,r,o)=>{const s=n.pages[t];if(!s)throw new Error(`Page ${t} is not exists`);const{sectionIds:a}=s,c=a.indexOf(r);c>=0&&a.splice(o,0,...a.splice(c,1))}}),[n,e.doc]);return{...e,state:n,actions:k,localActions:S,get currentPage(){const{localState:{currentPageId:t}}=e;return t?n.pages[t]:void 0},get currentSection(){var s,a,c;const{localState:{currentPageId:t,...r}}=e;if(!t)return;const o=(a=(s=r.pages)==null?void 0:s[t])==null?void 0:a.currentSectionId;if(o)return(c=n.pages[t])==null?void 0:c.sections[o]}}},L=()=>{const{projectId:e}=N.useParams();return e??V()};function Oe(e){var u,f;const{resources:n}=e;if(!n.components)return{};const i={};return(f=(u=window==null?void 0:window.blocklet)==null?void 0:u.componentMountPoints)==null||f.forEach(l=>{i[l.did]=l}),Object.fromEntries(Object.entries(n.components).map(([l,{blockletId:S,component:k}])=>{var t;return[l,{data:k,blockletId:S,blockletTitle:((t=i[S])==null?void 0:t.title)||S}]}))}function Le(e){const{components:n}=e;return n||{}}function J(e){return{...Oe(e),...Le(e)}}const Ae=()=>J(G().state),qe=[/\.\./,/<[^>]*>/,/%[0-9a-f]{2}/i,/[<>'"%;{}()\\]/,/\x00/,/\n|\r|\t|\v|\f/,/[^a-zA-Z0-9-_@/]/];function Me(e,n,i){const u=[];{let f;n.slug?n.slug.startsWith("/")?n.slug!=="/"&&n.slug.endsWith("/")?f=e("maker.properties.pathCheckEndWithoutSlash"):/\/{2,}/.test(n.slug)?f=e("maker.properties.pathCheckConsecutiveSlash"):/\s/.test(n.slug)?f=e("maker.properties.pathCheckWhitespace"):qe.some(l=>l.test(n.slug))?f=e("maker.properties.pathCheckInvalid"):Object.values(i.pages).some(l=>(l==null?void 0:l.id)!==n.id&&(l==null?void 0:l.slug)===n.slug)&&(f=e("maker.properties.pathCheckAlreadyExist")):f=e("maker.properties.pathCheckStartWithSlash"):f=e("maker.properties.pathCheckRequired"),f&&u.push({path:["path"],message:f})}return u.length>0?u:null}function Re({errors:e,...n}){return e!=null&&e.length?P.jsx(E.Tooltip,{...n,title:P.jsx(E.Box,{children:e.map((i,u)=>P.jsx(E.Box,{children:i.message},u))})}):null}exports.ErrorView=we;exports.PageErrorTip=Re;exports.StoreProvider=ve;exports.api=O;exports.autoResizeImage=be;exports.checkPage=Me;exports.getAllComponents=J;exports.getImageAbsoluteUrl=ye;exports.getProjectIdFromPathnameOrWindow=V;exports.getProjectPageVersionKey=ge;exports.getWssURL=Pe;exports.isColorString=Ee;exports.isGradient=z;exports.nextId=_;exports.transformValue=Se;exports.useAllComponents=Ae;exports.useProjectId=L;exports.useStore=G;
|
package/lib/cjs/home.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("react/jsx-runtime");require("./_chunks/state-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("react/jsx-runtime");require("./_chunks/state-BjeG4kYg.js");const e=require("./_chunks/home-BFxAZSGy.js");require("@arcblock/ux/lib/Locale/context");require("@arcblock/ux/lib/Result");require("@blocklet/pages-kit/builtin/page/header");require("@blocklet/ui-react/lib/Header");require("@emotion/css");require("@emotion/react");require("@emotion/styled");require("@mui/material");require("ahooks");require("isomorphic-dompurify");require("lodash");require("lodash/isEmpty");require("react");require("react-helmet");require("react-router-dom");require("react-use");require("ufo");exports.HomeView=e.HomeView;exports.PageRoutes=e.PageRoutes;exports.PageView=e.PageView;exports.PageViewByPath=e.PageViewByPath;exports.TranslucentHeader=e.TranslucentHeader;exports.default=e.Home;
|
package/lib/cjs/setting.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ve=Object.create;var ye=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Ne=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var Ue=(t,s,o,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let u of qe(s))!Ee.call(t,u)&&u!==o&&ye(t,u,{get:()=>s[u],enumerable:!(l=Fe(s,u))||l.enumerable});return t};var We=(t,s,o)=>(o=t!=null?Ve(Ne(t)):{},Ue(s||!t||!t.__esModule?ye(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),T=require("./_chunks/state-B6B5oPws.js"),Ke=require("@arcblock/ux/lib/Empty"),_=require("@arcblock/ux/lib/Locale/context"),ie=require("@blocklet/code-editor"),Me=require("@mui/icons-material/AddRounded"),Le=require("@mui/icons-material/ArrowDownward"),He=require("@mui/icons-material/ArrowUpward"),Je=require("@mui/icons-material/DeleteOutline"),r=require("@mui/material"),Ye=require("lodash/sortBy"),I=require("react"),ne=require("react-use"),$e=require("@arcblock/ux/lib/Theme"),Ge=require("@emotion/css"),re=require("ahooks"),Qe=require("gradient-parser");require("lodash/without");const Xe=require("tinycolor2"),D=require("@mui/material/colors"),z=require("./uploader.js"),Ze=require("@iconify-icon/react"),et=require("lodash/isEmpty"),tt=require("lodash/set"),rt=require("yaml");require("lodash");const st=require("@arcblock/ux/lib/Toast"),ee=require("@blocklet/pages-kit/components"),ae=require("@mui/base"),A=require("@mui/icons-material"),ge=require("@mui/material/styles"),M=require("@syncedstore/core"),lt=require("lodash/assign"),ot=require("lodash/has"),it=require("lodash/isNil"),nt=require("lodash/isObject"),at=require("lodash/keyBy"),ct=require("lodash/omit"),ut=require("lodash/pick"),dt=require("lodash/reduce"),V=require("material-ui-popup-state/hooks"),pt=require("react-error-boundary"),se=require("react-dnd"),R=t=>t&&t.__esModule?t:{default:t};function xt(t){if(t&&t.__esModule)return t;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(s,o,l.get?l:{enumerable:!0,get:()=>t[o]})}}return s.default=t,Object.freeze(s)}const Q=R(Ke),mt=R(Me),ft=R(Le),ht=R(He),jt=R(Je),F=R(Ye),ve=R(Qe),bt=R(Xe),we=R(et),Ie=R(tt),le=xt(rt),ke=R(st),yt=R(lt),gt=R(ot),G=R(it),vt=R(nt),kt=R(at),St=R(ct),Pt=R(ut),wt=R(dt);function It({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:t,...l,children:e.jsx(jt.default,{fontSize:"small"})})}function Ct({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(ht.default,{fontSize:"small"})})}function Bt({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(ft.default,{fontSize:"small"})})}function Tt({label:t,value:s,onChange:o,disabled:l=!1,itemLabel:u="",emptyHeight:h=40,property:d,renderItem:x,...k}){const{t:m,locale:v}=_.useLocaleContext(),j=ne.useUpdate(),i=I.useCallback(b=>{o(T.transformValue(b,d.type))},[o,d.type]),n=I.useMemo(()=>Array.isArray(s)?s:[],[s]),a=I.useCallback(()=>{const b=[...n,""];i(b),j()},[n,i,j]),p=I.useCallback(()=>{if(!d||!d.subProperties)return a();const b={};F.default(Object.values(d.subProperties),"index").forEach(({data:O})=>{var E,U;if(!O.key)return;const q=((U=(E=O.locales)==null?void 0:E[v])==null?void 0:U.defaultValue)??"";b[O.key]=q});const B=[...n,b];i(B),j()},[n,i,j,d,v,a]),f=I.useCallback(b=>{try{const w=JSON.parse(b);Array.isArray(w)?i(w):console.error("JSON解析结果不是数组")}catch(w){console.error("JSON解析错误:",w)}},[i]),S=I.useCallback(b=>{const w=n.filter((B,O)=>O!==b);i(w),j()},[n,i,j]),c=I.useCallback(b=>{if(b<=0)return;const w=[...n],B=w[b];w[b]=w[b-1],w[b-1]=B,i(w),j()},[n,i,j]),y=I.useCallback(b=>{if(b>=n.length-1)return;const w=[...n],B=w[b];w[b]=w[b+1],w[b+1]=B,i(w),j()},[n,i,j]),g=I.useCallback((b,w)=>{const B=[...n];B[b]=w,i(B)},[n,i]),P=d&&d.subProperties&&Object.keys(d.subProperties).length>0,C=I.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:b})=>e.jsx(r.Typography,{variant:"body1",sx:{bgcolor:"action.hover",borderRadius:"50%",width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:b+1})},{field:"content",headerName:"",renderCell:({row:b,index:w})=>x&&P?x({item:b,index:w,property:d,onChange:B=>g(w,B)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:b,placeholder:u||`${m("item")} ${w+1}`,onChange:B=>g(w,B.target.value),...k})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:b})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(Ct,{disabled:l||b===0,onClick:()=>c(b)}),e.jsx(Bt,{disabled:l||b===n.length-1,onClick:()=>y(b)}),e.jsx(It,{disabled:l,onClick:()=>S(b)})]})}],[x,P,d,g,u,m,l,k,S,c,y,n.length]);return P?e.jsxs(r.Stack,{width:"100%",gap:1,children:[t&&e.jsx(r.FormLabel,{children:t}),n.length>0?e.jsx(r.TableContainer,{component:r.Paper,variant:"outlined",sx:{borderRadius:1,mb:1},children:e.jsxs(r.Table,{size:"small",sx:{"& .MuiTableCell-root":{py:.25,px:1,whiteSpace:"nowrap"},"& .MuiTableCell-head":{backgroundColor:"action.hover",py:.25,px:1},borderCollapse:"collapse"},children:[e.jsx(r.TableHead,{sx:{display:"none"},children:e.jsx(r.TableRow,{children:C.map(b=>e.jsx(r.TableCell,{width:b.width,align:b.align||"left",sx:{fontWeight:"bold"},children:b.renderHeader?b.renderHeader():b.headerName},b.field))})}),e.jsx(r.TableBody,{children:n.map((b,w,B)=>e.jsx(r.TableRow,{sx:{borderBottom:w<B.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:C.map(O=>e.jsx(r.TableCell,{width:O.width,align:O.align||"left",sx:{borderBottom:"none"},children:O.renderCell({row:b,index:w,onChange:q=>g(w,q)})},`${w}-${O.field}`))},w))})]})}):e.jsx(Q.default,{style:{fontSize:12,height:h},children:m("maker.properties.arrayEmpty")}),e.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:l,startIcon:e.jsx(mt.default,{}),onClick:p,children:m("maker.properties.addArrayItem")})]}):e.jsxs(r.Stack,{width:"100%",gap:1,children:[t&&e.jsx(r.FormLabel,{children:t}),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,minHeight:150},children:e.jsx(ie.CodeEditor,{keyId:d.id,locale:v,language:"json",value:JSON.stringify(n,null,2),onChange:b=>f(b||"")},d.id)})]})}D.red[300],D.pink[300],D.purple[300],D.indigo[300],D.blue[300],D.cyan[300],D.teal[300],D.green[300],D.lime[300],D.yellow[300],D.amber[300],D.orange[300],D.brown[300],D.grey[300],D.blueGrey[300];const Ot=I.forwardRef(function({showMarkdown:s,markdown:o,onMarkdownChange:l,showUploader:u,value:h,meta:d,onChange:x,...k},m){const[v,j]=I.useState("");I.useEffect(()=>{j(h||"")},[h,j]);const i=async()=>{if(v!==h){const a=T.getImageAbsoluteUrl(v);if(!a){x(v,void 0);return}const p=await z.getImageSize(a).catch(()=>z.getVideoSize(a)).catch(()=>{});x(v,{...p,filename:v})}};ne.useDebounce(()=>{v!==h&&x(v)},300,[v]),I.useImperativeHandle(m,()=>({submit:i}));const n={};return u&&(n.InputProps={sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mx:.5},children:e.jsx(z.UploaderButton,{onChange:async({response:a})=>{var c;const p=(c=a==null?void 0:a.data)==null?void 0:c.filename,f=T.getImageAbsoluteUrl(p)||"";let S={};f&&(S=await z.getImageSize(f).catch(()=>z.getVideoSize(f)).catch(()=>{})),x(p,{...S,filename:p})}})})}),e.jsx(r.TextField,{size:"small",fullWidth:!0,...k,label:e.jsxs(r.Stack,{direction:"row",spacing:1,alignItems:"center",children:[k.label,s&&e.jsxs(e.Fragment,{children:[" (",e.jsx(r.FormControlLabel,{checked:o,label:e.jsx(r.Box,{component:Ze.Icon,icon:"tabler:markdown",sx:{verticalAlign:"middle"}}),labelPlacement:"start",control:e.jsx(r.Switch,{size:"small"}),sx:{ml:.25,pr:1},onChange:(a,p)=>l==null?void 0:l(p)}),")"]})]}),InputLabelProps:{shrink:!0,...k.InputLabelProps},value:v,onChange:a=>j(a.target.value),...n,onKeyDown:a=>{a.keyCode!==229&&a.key==="Enter"&&i()}})}),Rt=I.lazy(()=>import("react-best-gradient-color-picker"));function _t(t){try{const o=ve.default.parse(t).map(u=>{const h=u.colorStops.map(d=>{if(d.type!=="rgba"){const x=bt.default(d.value).toRgb();return{...d,value:[x.r,x.g,x.b,x.a],type:"rgba"}}return d});return{...u,colorStops:h}});return ve.default.stringify(o)}catch{return T.isColorString(t)?t:""}}function Dt({color:t,sx:s={},...o}){T.isColorString(t);const l={};return T.isGradient(t)?l.backgroundImage=t:l.backgroundColor=t,e.jsx(r.Box,{sx:{...s,width:"100%",paddingBottom:"100%",cursor:"pointer",transition:"opacity 0.2s",border:"1px solid #ccc",borderRadius:.5,"&:hover":{opacity:.75},...l},...o})}const zt=I.forwardRef(function({onSave:s},o){const l=re.useReactive({value:""}),{t:u}=_.useLocaleContext(),h={};l.value?T.isGradient(l.value)?h.backgroundImage=l.value:h.backgroundColor=l.value:h.border="1px solid #ccc";const[d,{setFalse:x,setTrue:k}]=re.useBoolean(!1),m=I.useCallback(()=>{x()},[x]),v=()=>{s({value:l.value},m)};return I.useImperativeHandle(o,()=>({open({value:j}={value:""}){l.value=j,k()},close(){m()}})),e.jsxs(r.Dialog,{open:d,onClose:m,hideBackdrop:!0,children:[e.jsx(r.DialogTitle,{children:u("maker.configBackground")}),e.jsx(r.DialogContent,{sx:{width:600},children:e.jsxs(r.Box,{width:"100%",display:"flex",children:[e.jsx(r.Box,{flex:1,mr:1,sx:h,children:!l.value&&e.jsx(Q.default,{children:u("error.notConfig")})}),e.jsx(I.Suspense,{children:e.jsx(Rt,{width:200,height:200,value:_t(l.value),onChange:j=>{l.value=j},hidePresets:!0,hideAdvancedSliders:!0,hideColorGuide:!0,hideInputType:!0})})]})}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{variant:"outlined",size:"small",onClick:m,children:u("common.cancel")}),e.jsx(r.Button,{variant:"contained",size:"small",onClick:v,children:u("maker.save")})]})]})});$e.styled(r.Box)`
|
|
1
|
+
"use strict";var Ve=Object.create;var ye=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Ne=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var Ue=(t,s,o,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let u of qe(s))!Ee.call(t,u)&&u!==o&&ye(t,u,{get:()=>s[u],enumerable:!(l=Fe(s,u))||l.enumerable});return t};var We=(t,s,o)=>(o=t!=null?Ve(Ne(t)):{},Ue(s||!t||!t.__esModule?ye(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),T=require("./_chunks/state-BjeG4kYg.js"),Ke=require("@arcblock/ux/lib/Empty"),_=require("@arcblock/ux/lib/Locale/context"),ie=require("@blocklet/code-editor"),Me=require("@mui/icons-material/AddRounded"),Le=require("@mui/icons-material/ArrowDownward"),He=require("@mui/icons-material/ArrowUpward"),Je=require("@mui/icons-material/DeleteOutline"),r=require("@mui/material"),Ye=require("lodash/sortBy"),I=require("react"),ne=require("react-use"),$e=require("@arcblock/ux/lib/Theme"),Ge=require("@emotion/css"),re=require("ahooks"),Qe=require("gradient-parser");require("lodash/without");const Xe=require("tinycolor2"),D=require("@mui/material/colors"),z=require("./uploader.js"),Ze=require("@iconify-icon/react"),et=require("lodash/isEmpty"),tt=require("lodash/set"),rt=require("yaml");require("lodash");const st=require("@arcblock/ux/lib/Toast"),ee=require("@blocklet/pages-kit/components"),ce=require("@mui/base"),A=require("@mui/icons-material"),ge=require("@mui/material/styles"),M=require("@syncedstore/core"),lt=require("lodash/assign"),ot=require("lodash/has"),it=require("lodash/isNil"),nt=require("lodash/isObject"),ct=require("lodash/keyBy"),at=require("lodash/omit"),ut=require("lodash/pick"),dt=require("lodash/reduce"),V=require("material-ui-popup-state/hooks"),pt=require("react-error-boundary"),se=require("react-dnd"),R=t=>t&&t.__esModule?t:{default:t};function xt(t){if(t&&t.__esModule)return t;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(s,o,l.get?l:{enumerable:!0,get:()=>t[o]})}}return s.default=t,Object.freeze(s)}const Q=R(Ke),mt=R(Me),ft=R(Le),ht=R(He),jt=R(Je),F=R(Ye),ve=R(Qe),bt=R(Xe),we=R(et),Ie=R(tt),le=xt(rt),ke=R(st),yt=R(lt),gt=R(ot),G=R(it),vt=R(nt),kt=R(ct),St=R(at),Pt=R(ut),wt=R(dt);function It({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:t,...l,children:e.jsx(jt.default,{fontSize:"small"})})}function Ct({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(ht.default,{fontSize:"small"})})}function Bt({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(ft.default,{fontSize:"small"})})}function Tt({label:t,value:s,onChange:o,disabled:l=!1,itemLabel:u="",emptyHeight:m=40,property:d,renderItem:x,...k}){const{t:f,locale:v}=_.useLocaleContext(),j=ne.useUpdate(),i=I.useCallback(b=>{o(T.transformValue(b,d.type))},[o,d.type]),n=I.useMemo(()=>Array.isArray(s)?s:[],[s]),c=I.useCallback(()=>{const b=[...n,""];i(b),j()},[n,i,j]),p=I.useCallback(()=>{if(!d||!d.subProperties)return c();const b={};F.default(Object.values(d.subProperties),"index").forEach(({data:O})=>{var E,U;if(!O.key)return;const q=((U=(E=O.locales)==null?void 0:E[v])==null?void 0:U.defaultValue)??"";b[O.key]=q});const B=[...n,b];i(B),j()},[n,i,j,d,v,c]),h=I.useCallback(b=>{try{const w=JSON.parse(b);Array.isArray(w)?i(w):console.error("JSON解析结果不是数组")}catch(w){console.error("JSON解析错误:",w)}},[i]),S=I.useCallback(b=>{const w=n.filter((B,O)=>O!==b);i(w),j()},[n,i,j]),a=I.useCallback(b=>{if(b<=0)return;const w=[...n],B=w[b];w[b]=w[b-1],w[b-1]=B,i(w),j()},[n,i,j]),y=I.useCallback(b=>{if(b>=n.length-1)return;const w=[...n],B=w[b];w[b]=w[b+1],w[b+1]=B,i(w),j()},[n,i,j]),g=I.useCallback((b,w)=>{const B=[...n];B[b]=w,i(B)},[n,i]),P=d&&d.subProperties&&Object.keys(d.subProperties).length>0,C=I.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:b})=>e.jsx(r.Typography,{variant:"body1",sx:{bgcolor:"action.hover",borderRadius:"50%",width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:b+1})},{field:"content",headerName:"",renderCell:({row:b,index:w})=>x&&P?x({item:b,index:w,property:d,onChange:B=>g(w,B)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:b,placeholder:u||`${f("item")} ${w+1}`,onChange:B=>g(w,B.target.value),...k})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:b})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(Ct,{disabled:l||b===0,onClick:()=>a(b)}),e.jsx(Bt,{disabled:l||b===n.length-1,onClick:()=>y(b)}),e.jsx(It,{disabled:l,onClick:()=>S(b)})]})}],[x,P,d,g,u,f,l,k,S,a,y,n.length]);return P?e.jsxs(r.Stack,{width:"100%",gap:1,children:[t&&e.jsx(r.FormLabel,{children:t}),n.length>0?e.jsx(r.TableContainer,{component:r.Paper,variant:"outlined",sx:{borderRadius:1,mb:1},children:e.jsxs(r.Table,{size:"small",sx:{"& .MuiTableCell-root":{py:.25,px:1,whiteSpace:"nowrap"},"& .MuiTableCell-head":{backgroundColor:"action.hover",py:.25,px:1},borderCollapse:"collapse"},children:[e.jsx(r.TableHead,{sx:{display:"none"},children:e.jsx(r.TableRow,{children:C.map(b=>e.jsx(r.TableCell,{width:b.width,align:b.align||"left",sx:{fontWeight:"bold"},children:b.renderHeader?b.renderHeader():b.headerName},b.field))})}),e.jsx(r.TableBody,{children:n.map((b,w,B)=>e.jsx(r.TableRow,{sx:{borderBottom:w<B.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:C.map(O=>e.jsx(r.TableCell,{width:O.width,align:O.align||"left",sx:{borderBottom:"none"},children:O.renderCell({row:b,index:w,onChange:q=>g(w,q)})},`${w}-${O.field}`))},w))})]})}):e.jsx(Q.default,{style:{fontSize:12,height:m},children:f("maker.properties.arrayEmpty")}),e.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:l,startIcon:e.jsx(mt.default,{}),onClick:p,children:f("maker.properties.addArrayItem")})]}):e.jsxs(r.Stack,{width:"100%",gap:1,children:[t&&e.jsx(r.FormLabel,{children:t}),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,minHeight:150},children:e.jsx(ie.CodeEditor,{keyId:d.id,locale:v,language:"json",value:JSON.stringify(n,null,2),onChange:b=>h(b||"")},d.id)})]})}D.red[300],D.pink[300],D.purple[300],D.indigo[300],D.blue[300],D.cyan[300],D.teal[300],D.green[300],D.lime[300],D.yellow[300],D.amber[300],D.orange[300],D.brown[300],D.grey[300],D.blueGrey[300];const Ot=I.forwardRef(function({showMarkdown:s,markdown:o,onMarkdownChange:l,showUploader:u,value:m,meta:d,onChange:x,...k},f){const[v,j]=I.useState("");I.useEffect(()=>{j(m||"")},[m,j]);const i=async()=>{if(v!==m){const c=T.getImageAbsoluteUrl(v);if(!c){x(v,void 0);return}const p=await z.getImageSize(c).catch(()=>z.getVideoSize(c)).catch(()=>{});x(v,{...p,filename:v})}};ne.useDebounce(()=>{v!==m&&x(v)},300,[v]),I.useImperativeHandle(f,()=>({submit:i}));const n={};return u&&(n.InputProps={sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mx:.5},children:e.jsx(z.UploaderButton,{onChange:async({response:c})=>{var a;const p=(a=c==null?void 0:c.data)==null?void 0:a.filename,h=T.getImageAbsoluteUrl(p)||"";let S={};h&&(S=await z.getImageSize(h).catch(()=>z.getVideoSize(h)).catch(()=>{})),x(p,{...S,filename:p})}})})}),e.jsx(r.TextField,{size:"small",fullWidth:!0,...k,label:e.jsxs(r.Stack,{direction:"row",spacing:1,alignItems:"center",children:[k.label,s&&e.jsxs(e.Fragment,{children:[" (",e.jsx(r.FormControlLabel,{checked:o,label:e.jsx(r.Box,{component:Ze.Icon,icon:"tabler:markdown",sx:{verticalAlign:"middle"}}),labelPlacement:"start",control:e.jsx(r.Switch,{size:"small"}),sx:{ml:.25,pr:1},onChange:(c,p)=>l==null?void 0:l(p)}),")"]})]}),InputLabelProps:{shrink:!0,...k.InputLabelProps},value:v,onChange:c=>j(c.target.value),...n,onKeyDown:c=>{c.keyCode!==229&&c.key==="Enter"&&i()}})}),Rt=I.lazy(()=>import("react-best-gradient-color-picker"));function _t(t){try{const o=ve.default.parse(t).map(u=>{const m=u.colorStops.map(d=>{if(d.type!=="rgba"){const x=bt.default(d.value).toRgb();return{...d,value:[x.r,x.g,x.b,x.a],type:"rgba"}}return d});return{...u,colorStops:m}});return ve.default.stringify(o)}catch{return T.isColorString(t)?t:""}}function Dt({color:t,sx:s={},...o}){T.isColorString(t);const l={};return T.isGradient(t)?l.backgroundImage=t:l.backgroundColor=t,e.jsx(r.Box,{sx:{...s,width:"100%",paddingBottom:"100%",cursor:"pointer",transition:"opacity 0.2s",border:"1px solid #ccc",borderRadius:.5,"&:hover":{opacity:.75},...l},...o})}const zt=I.forwardRef(function({onSave:s},o){const l=re.useReactive({value:""}),{t:u}=_.useLocaleContext(),m={};l.value?T.isGradient(l.value)?m.backgroundImage=l.value:m.backgroundColor=l.value:m.border="1px solid #ccc";const[d,{setFalse:x,setTrue:k}]=re.useBoolean(!1),f=I.useCallback(()=>{x()},[x]),v=()=>{s({value:l.value},f)};return I.useImperativeHandle(o,()=>({open({value:j}={value:""}){l.value=j,k()},close(){f()}})),e.jsxs(r.Dialog,{open:d,onClose:f,hideBackdrop:!0,children:[e.jsx(r.DialogTitle,{children:u("maker.configBackground")}),e.jsx(r.DialogContent,{sx:{width:600},children:e.jsxs(r.Box,{width:"100%",display:"flex",children:[e.jsx(r.Box,{flex:1,mr:1,sx:m,children:!l.value&&e.jsx(Q.default,{children:u("error.notConfig")})}),e.jsx(I.Suspense,{children:e.jsx(Rt,{width:200,height:200,value:_t(l.value),onChange:j=>{l.value=j},hidePresets:!0,hideAdvancedSliders:!0,hideColorGuide:!0,hideInputType:!0})})]})}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{variant:"outlined",size:"small",onClick:f,children:u("common.cancel")}),e.jsx(r.Button,{variant:"contained",size:"small",onClick:v,children:u("maker.save")})]})]})});$e.styled(r.Box)`
|
|
2
2
|
.color-item {
|
|
3
3
|
position: relative;
|
|
4
4
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
top: 0;
|
|
19
19
|
right: 0;
|
|
20
20
|
}
|
|
21
|
-
`;function At({value:t,onChange:s,...o}){const l=I.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(Ot,{...o,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(Dt,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{var u;(u=l.current)==null||u.open({value:t??""})}})})}}),e.jsx(zt,{ref:l,onSave:({value:u},h)=>{s(u),h()}})]})}function Vt({label:t,value:s,onChange:o,property:l,component:u,defaultLocale:h,allComponents:d,PropertyValueField:x,onUpload:k}){const{locale:m}=_.useLocaleContext(),v=I.useRef(null);if(!we.default(l.subProperties)){const i=F.default(Object.values(l.subProperties||{}),"index").filter(n=>n.data.visible!==!1&&n.data.key);return e.jsxs(r.Stack,{width:"100%",children:[e.jsx(r.FormLabel,{sx:{px:.25,py:.5},children:t}),e.jsx(r.Box,{children:e.jsx(r.Box,{sx:{position:"relative"},children:i.map((n,a)=>{const{data:p}=n,f=p.key??p.id,S=a===i.length-1;let c=null;try{s&&typeof s=="object"?c=s[f]:typeof s=="string"&&(c=(l.type==="yaml"?le.parse(s||""):JSON.parse(s||"{}"))[f])}catch{}c==null&&(p.locales&&m&&p.locales[m]?c=p.locales[m].defaultValue:p.locales&&h&&p.locales[h]&&(c=p.locales[h].defaultValue));const y=P=>{try{let C={};if(typeof s=="string")try{C=l.type==="yaml"?le.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(C={...s});Ie.default(C,f,P);const b=T.transformValue(C,l.type);o==null||o(b)}catch(C){console.error("Error updating property:",C)}},g=8;return e.jsxs(r.Box,{sx:{mb:S?0:1,display:"flex",flexDirection:"row"},children:[e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:g,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:g,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!S&&e.jsx(r.Box,{sx:{position:"absolute",left:g,top:16,bottom:-8,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsx(r.Box,{sx:{flexGrow:1},children:e.jsx(x,{component:u,property:p,value:c,onChange:y,size:"small",fullWidth:!0,defaultLocale:h,allComponents:d})})]},p.id)})})})]})}return e.jsx(r.Stack,{width:"100%",gap:2,children:e.jsxs(r.Stack,{sx:{width:"100%",position:"relative",pt:1,pb:"6px",px:"1px",minHeight:50,".monaco-editor,.overflow-guard":{borderRadius:1}},children:[e.jsx(r.FormLabel,{sx:{position:"absolute",left:0,top:0,transform:"translate(0px, -7px) scale(0.75)"},children:t}),e.jsx(ie.CodeEditor,{keyId:l.id,locale:m,language:l.type==="yaml"?"yaml":"json",value:typeof s=="string"?s:"",onChange:i=>{o==null||o(i)},onUpload:i=>{v.current=i,k&&k(i)}},l.id),e.jsx(r.Box,{component:"fieldset",sx:{pointerEvents:"none",position:"absolute",left:0,top:-5,width:"100%",height:"100%",border:1,borderColor:"rgba(0, 0, 0, 0.23)",borderRadius:1,px:1,py:0},children:e.jsx(r.Box,{component:"legend",sx:{fontSize:"0.75em"},children:e.jsx(r.Box,{component:"span",sx:{opacity:0},children:t})})})]})})}const Se=["string","multiline","json","yaml","component","custom","url"];function Ce({disabled:t,list:s,renderItem:o,...l}){const u=I.useRef(null),h=I.useId(),d=re.useUpdate(),x=F.default(Object.entries(s),n=>n[1].index).map(n=>n[0]),k=I.useRef(x),m=I.useCallback(n=>{k.current=n,d()},[d]),v=I.useCallback(({index:n},{index:a})=>{const p=[...k.current];p.splice(a,0,...p.splice(n,1)),m(p)},[m]);I.useEffect(()=>{m(x)},[x.join("-")]);const[{isOver:j},i]=se.useDrop({accept:h,collect:n=>({isOver:n.isOver()}),canDrop:()=>!t,drop:()=>{var p;const n=()=>{k.current.forEach((f,S)=>{const c=s[f];c&&(c.index=S)})},a=(p=M.getYjsValue(s))==null?void 0:p.doc;a?a.transact(()=>{n()}):n()}});return I.useEffect(()=>{j||m(x)},[j]),i(u),e.jsx(r.Box,{...l,ref:u,className:Ge.cx(j&&"isDragging"),children:k.current.map((n,a)=>e.jsx(Ft,{type:h,disabled:t,id:n,index:a,itemIndex:p=>k.current.indexOf(p),move:v,children:p=>{const f=s[n];return f?o(f.data,a,p):null}},n))})}function Ft({disabled:t,id:s,index:o,type:l,children:u,itemIndex:h,move:d}){const x=I.useRef(),[{isDragging:k},m,v]=se.useDrag({type:l,item:()=>({id:s}),canDrag:()=>!t,collect:i=>({isDragging:i.isDragging()})}),[,j]=se.useDrop({accept:l,canDrop:()=>!t,hover(i,n){var g;if(!x.current)return;const a=h(i.id),p=o;if(a===p)return;const f=(g=x.current)==null?void 0:g.getBoundingClientRect(),S=(f.bottom-f.top)/2,y=n.getClientOffset().y-f.top;a<p&&y<S||a>p&&y>S||d({id:i.id,index:a},{id:s,index:o})}});return typeof u=="function"?u({isDragging:k,drag:m,drop:i=>(x.current=i,j(i)),preview:v}):(m(j(v(x))),e.jsx(r.Box,{ref:x,children:u}))}function qt({drop:t,preview:s,drag:o,disabled:l,isDragging:u,children:h,onDelete:d,onVisibilityChange:x,visible:k=!0,actions:m,alwaysShowActions:v=!1}){const{t:j}=_.useLocaleContext();return e.jsx(r.Box,{ref:t,sx:{":hover .hover-visible":{maxWidth:"100%"},opacity:k?1:.5},children:e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsx(r.Box,{ref:s,sx:{flex:1,borderRadius:.5,bgcolor:u?"action.hover":"background.paper",opacity:.9999},children:h}),!l&&e.jsx(r.Box,{className:v?"":"hover-visible",sx:{maxWidth:v?"100%":0,overflow:"hidden",position:"absolute",right:2,top:2,transition:"max-width 0.3s ease-in-out"},children:e.jsxs(r.Stack,{direction:"row",sx:{bgcolor:i=>r.alpha(i.palette.grey[200],.9),borderRadius:1,p:.5,[`.${r.buttonClasses.root}`]:{minWidth:24,width:24,height:24,p:0}},children:[m,x&&e.jsx(r.Tooltip,{title:j(k?"hideParameter":"showParameter"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>x(!k),children:k?e.jsx(A.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(A.VisibilityRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),d&&e.jsx(r.Tooltip,{title:j("delete"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:d,children:e.jsx(A.DeleteOutlineRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),e.jsx(r.Tooltip,{title:j("dragSort"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{ref:o,children:e.jsx(A.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function Nt({label:t,value:s,onChange:o}){const[l,u]=I.useState(!1);return e.jsxs(r.Stack,{gap:1,children:[e.jsx(r.TextField,{label:t,size:"small",value:s,onChange:h=>o==null?void 0:o(h.target.value),InputProps:{endAdornment:e.jsx(z.UploaderButton,{onChange:({response:h})=>{var x;const d=(x=h==null?void 0:h.data)==null?void 0:x.filename;d&&(o==null||o(d))}})}}),s&&e.jsx(r.Box,{component:"img",sx:{objectFit:"contain",borderRadius:1,cursor:"pointer"},src:T.getImageAbsoluteUrl(s),alt:t,maxWidth:100,maxHeight:100,width:"100%",onClick:()=>u(!0)}),e.jsx(r.Dialog,{open:l,onClose:()=>u(!1),children:e.jsx(r.Box,{component:"img",sx:{objectFit:"contain"},src:T.getImageAbsoluteUrl(s),alt:t})})]})}function oe(t,s=""){return wt.default(t,(o,l,u)=>{const h=s?`${s}.${u}`:u;return vt.default(l)?yt.default(o,oe(l,h)):o[h]=l,o},{})}const Et=[{value:"string",label:"Text"},{value:"multiline",label:"Text (Multiline)"},{value:"number",label:"Number"},{value:"decimal",label:"Decimal"},{value:"boolean",label:"Boolean"},{value:"color",label:"Color"},{value:"url",label:"URL (Upload)"},{value:"json",label:"JSON"},{value:"yaml",label:"YAML"},{value:"array",label:"Array"},{value:"component",label:"Component"},{value:"custom",label:"Custom (Render by a Component)"}];function Z(t,s,o){return!t||!o?!1:Object.values(t).some(({data:l})=>l.id!==s&&l.key===o)}function Be(t,s){var o;return!t||!s?!1:((o=t[s])==null?void 0:o.data.visible)??!0}function Ut({componentId:t}){const{state:{components:s}}=T.useStore(),o=s[t],l=o==null?void 0:o.data;return l?e.jsx(r.Stack,{maxHeight:"100%",overflow:"auto",children:e.jsx(r.Box,{p:2,children:e.jsx(pt.ErrorBoundary,{FallbackComponent:T.ErrorView,resetKeys:[t],children:e.jsx(Wt,{value:l})})})}):null}function Wt({value:t}){var k,m,v;const{t:s}=_.useLocaleContext(),{localState:{currentLocale:o,componentDebugProps:l},state:{config:{defaultLocale:u}},localActions:{setComponentDebugProps:h}}=T.useStore(),d=M.getYjsValue(t).doc,x=T.useAllComponents();return e.jsx(r.Stack,{height:"100%",children:e.jsxs(r.Stack,{gap:2,children:[e.jsx(Te,{config:t}),e.jsx(Re,{config:t,currentLocale:o,defaultLocale:u,allComponents:x,onUpdateConfig:j=>{d.transact(()=>{j(t)})}}),e.jsxs(r.Stack,{gap:2,direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(r.Typography,{variant:"subtitle1",children:s("renderer")}),e.jsxs(r.TextField,{hiddenLabel:!0,size:"small",select:!0,SelectProps:{autoWidth:!0},value:((k=t.renderer)==null?void 0:k.type)||"react-component",onChange:j=>{d.transact(()=>{const i=j.target.value;t.renderer??(t.renderer={type:i}),t.renderer.type=i})},children:[e.jsx(r.MenuItem,{value:"react-component",children:"React Component"}),e.jsx(r.MenuItem,{value:"component",children:"Custom Component"})]})]}),((m=t.renderer)==null?void 0:m.type)==="component"?e.jsx($t,{value:t}):((v=t.renderer)==null?void 0:v.type)==="react-component"?e.jsx(Yt,{value:t}):null,e.jsx(Ae,{config:t,currentLocale:o,defaultLocale:u,allComponents:x,onChange:({key:j,value:i})=>{h({[j]:i.value})},props:{...l}})]})})}function Te({config:t}){const{t:s}=_.useLocaleContext();return e.jsx(z.UploaderProvider,{children:e.jsxs(r.Stack,{gap:2,children:[e.jsx(r.Typography,{variant:"subtitle1",children:s("basicInfo")}),e.jsx(r.TextField,{label:s("name"),size:"small",value:t.name||"",onChange:o=>t.name=o.target.value}),e.jsx(r.TextField,{label:s("description"),size:"small",multiline:!0,minRows:2,maxRows:10,inputProps:{maxLength:200},value:t.description||"",onChange:o=>t.description=o.target.value}),e.jsx(r.Autocomplete,{size:"small",options:[],multiple:!0,freeSolo:!0,value:t.tags??[],onChange:(o,l)=>t.tags=l,renderInput:o=>e.jsx(r.TextField,{label:s("tags"),...o})}),e.jsx(Nt,{label:s("previewImage"),value:t.previewImage||"",onChange:o=>t.previewImage=o})]})})}function Oe({data:t,params:s,visible:o,config:l,currentLocale:u,defaultLocale:h,allComponents:d,onUpdateConfig:x}){var v,j,i,n,a,p;const{t:k}=_.useLocaleContext(),m=I.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?Ht:N,[t.type]);return e.jsx(qt,{preview:s.preview,drop:s.drop,drag:s.drag,isDragging:s.isDragging,onDelete:()=>{x(f=>{if(f.properties){const c=Object.entries(f.properties).sort(([,g],[,P])=>g.index-P.index);delete f.properties[t.id],c.filter(([g])=>g!==t.id).forEach(([,g],P)=>{g.index=P})}})},visible:o,onVisibilityChange:f=>{x(S=>{const c=S.properties[t.id].data;c.visible=f})},alwaysShowActions:!0,children:e.jsxs(r.Stack,{direction:"column",gap:2,children:[e.jsx(r.TextField,{label:k("key"),size:"small",required:!0,sx:{width:"calc(100% - 80px - 8px)",flex:1,"& .MuiOutlinedInput-root":{borderColor:t.key?Z(l.properties,t.id,t.key)?"warning.main":void 0:"error.main"},"& .MuiFormLabel-root":{color:t.key?Z(l.properties,t.id,t.key)?"warning.main":"text.secondary":"error.main"},"& .MuiFormLabel-root.Mui-focused":{color:t.key?Z(l.properties,t.id,t.key)?"warning.main":"primary.main":"error.main"}},value:t.key||"",onChange:f=>{x(S=>{const c=S.properties[t.id].data;c.key=f.target.value.trim()})},InputProps:{endAdornment:!t.key||t.key&&Z(l.properties,t.id,t.key)?e.jsx(r.InputAdornment,{position:"end",sx:{width:16,ml:0},children:e.jsx(r.Tooltip,{title:t.key?k("duplicateKey"):k("requiredKey"),children:e.jsx(A.InfoRounded,{sx:{color:t.key?"warning.main":"error.main",fontSize:16}})})}):null}}),e.jsxs(r.Stack,{direction:"row",gap:1,children:[e.jsx(r.TextField,{label:k("label"),size:"small",sx:{flex:1},value:(((j=(v=t.locales)==null?void 0:v[u])==null?void 0:j.name)??((n=(i=t.locales)==null?void 0:i[h])==null?void 0:n.name))||"",onChange:f=>{x(S=>{var y;const c=S.properties[t.id].data;c.locales??(c.locales={}),(y=c.locales)[u]??(y[u]={}),c.locales[u].name=f.target.value})}}),e.jsx(r.TextField,{label:k("type"),size:"small",select:!0,sx:{flex:1},value:t.type==="string"&&t.multiline?"multiline":t.type||"string",onChange:f=>{x(S=>{const c=S.properties[t.id].data;if(c.locales)for(const g of Object.keys(c.locales))c.locales[g].defaultValue=void 0;const y=f.target.value;y==="multiline"?(c.type="string",c.multiline=!0):(typeof c.multiline<"u"&&delete c.multiline,c.type=y)})},children:Et.map(f=>e.jsx(r.MenuItem,{value:f.value,children:f.label},f.value))})]}),e.jsxs(r.Stack,{direction:"row",gap:1,children:[e.jsx(m,{allComponents:d,defaultLocale:h,component:l,property:t,label:k("defaultValue"),size:"small",fullWidth:!0,value:(p=(a=t.locales)==null?void 0:a[u])==null?void 0:p.defaultValue,onChange:(f,S)=>{x(c=>{var g;const y=c.properties[t.id].data;if(S!=null&&S.forceUpdateProperty){const P=oe(y),C=oe(f);Object.keys(C).forEach(b=>{P[b]||Ie.default(y,b,C[b])})}else y.locales??(y.locales={}),(g=y.locales)[u]??(g[u]={}),y.locales[u].defaultValue=f})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(Mt,{property:t,allComponents:d})}):null]})]})})}function Kt(t){const[s,o]=I.useState(0);return I.useEffect(()=>{if(t.current){let l=t.current.parentElement,u=0;for(;l;)l.classList.contains("property-container")&&u++,l=l.parentElement;o(u)}},[]),s}function Re({config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:u,useI18nEditor:h=!0}){const{t:d}=_.useLocaleContext(),x=V.usePopupState({variant:"dialog"}),k=t.properties&&F.default(Object.values(t.properties),"index");return e.jsx(z.UploaderProvider,{children:e.jsxs(r.Stack,{gap:2,children:[e.jsxs(r.Stack,{direction:"row",gap:1,alignItems:"center",justifyContent:"space-between",children:[e.jsx(r.Typography,{variant:"subtitle1",children:d("properties")}),e.jsx(r.Box,{flex:1}),h&&e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...V.bindTrigger(x),children:e.jsx(A.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(Ce,{component:r.Stack,gap:2,list:t.properties,renderItem:(m,v,j)=>{const i=Be(t.properties,m.id);return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed",borderColor:"divider"},children:e.jsx(r.Stack,{gap:2,children:e.jsx(Oe,{data:m,params:j,visible:i,config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:u})})},m.id)}}):e.jsx(Q.default,{style:{fontSize:12},children:d("maker.properties.noProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",onClick:()=>{u(m=>{var j;const v=T.nextId();m.properties??(m.properties={}),(j=m.properties)[v]??(j[v]={index:(k==null?void 0:k.length)||0,data:{id:v}})})},startIcon:e.jsx(A.AddRounded,{}),children:d("addObject",{object:d("property")})}),h&&e.jsx(_e,{...V.bindDialog(x),component:t})]})})}function Mt({property:t,allComponents:s}){const o=V.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...V.bindTrigger(o),children:e.jsx(A.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...V.bindPopper(o),children:e.jsx(ae.ClickAwayListener,{onClickAway:o.close,children:e.jsx(r.Paper,{children:e.jsx(r.Box,{width:500,p:2,children:e.jsx(te,{value:t.componentId,onChange:(l,u)=>t.componentId=u,allComponents:s})})})})})]})}function Lt({value:t,valueImmutable:s,onChange:o,defaultLocale:l,allComponents:u}){var k;const h=V.usePopupState({variant:"popper"}),{locale:d}=_.useLocaleContext(),x=typeof(t==null?void 0:t.componentId)=="string"?(k=u[t.componentId])==null?void 0:k.data:void 0;return x?e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},disabled:!x,...V.bindTrigger(h),children:e.jsx(A.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...V.bindPopper(h),sx:{zIndex:1e3},children:e.jsx(ae.ClickAwayListener,{onClickAway:h.close,children:e.jsx(r.Paper,{children:e.jsxs(r.Box,{width:500,p:2,children:[e.jsx(r.Typography,{variant:"subtitle1",children:"Parameters"}),e.jsx(r.Stack,{gap:1,children:(x==null?void 0:x.properties)&&F.default(Object.values(x.properties),"index").map(({data:m})=>{var v,j,i,n,a,p,f,S;return e.jsx(r.Box,{children:e.jsx(N,{allComponents:u,defaultLocale:l,size:"small",fullWidth:!0,component:x,property:m,valueImmutable:G.default((j=(v=t.properties)==null?void 0:v[m.id])==null?void 0:j.value),value:((n=(i=t.properties)==null?void 0:i[m.id])==null?void 0:n.value)??((p=(a=m.locales)==null?void 0:a[d])==null?void 0:p.defaultValue)??((S=(f=m.locales)==null?void 0:f[l])==null?void 0:S.defaultValue),onChange:c=>{if(s){const y=JSON.parse(JSON.stringify(t));o==null||o({...y,properties:{...y.properties,[m.id]:{value:c}}})}else M.getYjsValue(x).doc.transact(()=>{t.properties??(t.properties={}),t.properties[m.id]={value:c}})}})},m.id)})})]})})})})]}):null}function _e({type:t="properties",component:s,...o}){var j,i,n;const{t:l}=_.useLocaleContext(),{state:{components:u,supportedLocales:h,config:{defaultLocale:d}}}=T.useStore(),x=T.useAllComponents(),k=M.getYjsValue(s).doc,m=t==="properties"?s.properties:t==="parameters"&&((j=s.renderer)==null?void 0:j.type)==="component"?(i=u[s.renderer.componentId])==null?void 0:i.data.properties:void 0,v=((n=s.renderer)==null?void 0:n.type)==="component"?s:void 0;return e.jsxs(r.Dialog,{...o,fullWidth:!0,maxWidth:"lg",children:[e.jsx(r.DialogTitle,{children:l("i18nEditorTitle")}),e.jsx(r.DialogContent,{children:m&&e.jsx(r.Stack,{children:e.jsxs(r.Table,{stickyHeader:!0,sx:{td:{verticalAlign:"top"}},children:[e.jsx(r.TableHead,{children:e.jsx(r.TableRow,{children:h.map(({locale:a,name:p})=>e.jsxs(r.TableCell,{children:[p,d===a&&e.jsx(A.StarRounded,{sx:{fontSize:12,color:"text.secondary"}})]},a))})}),e.jsx(r.TableBody,{children:F.default(Object.values(m),"index").map(({data:a})=>e.jsx(r.TableRow,{children:h.map(({locale:p})=>{var f,S,c,y,g,P,C,b,w,B,O,q,E,U,X,L,H,J,Y,$,ce,ue,de,pe,xe,me;return e.jsx(r.TableCell,{children:e.jsx(r.Stack,{gap:1,children:t==="properties"?e.jsxs(e.Fragment,{children:[e.jsx(r.TextField,{size:"small",label:"Key",value:a.key||"",onChange:K=>{k.transact(()=>{a.key=K.target.value.trim()})}}),e.jsx(r.TextField,{size:"small",label:l("label"),value:(((S=(f=a.locales)==null?void 0:f[p])==null?void 0:S.name)??((y=(c=a.locales)==null?void 0:c[d])==null?void 0:y.name))||"",onChange:K=>{k.transact(()=>{var W;a.locales??(a.locales={}),(W=a.locales)[p]??(W[p]={}),a.locales[p].name=K.target.value})}}),e.jsx(r.Box,{children:e.jsx(N,{allComponents:x,defaultLocale:d,component:s,property:a,size:"small",fullWidth:!0,label:"Default Value",valueImmutable:G.default((P=(g=a.locales)==null?void 0:g[p])==null?void 0:P.defaultValue),value:((b=(C=a.locales)==null?void 0:C[p])==null?void 0:b.defaultValue)??((B=(w=a.locales)==null?void 0:w[d])==null?void 0:B.defaultValue),onChange:K=>{k.transact(()=>{var W;a.locales??(a.locales={}),(W=a.locales)[p]??(W[p]={}),a.locales[p].defaultValue=K})}})})]}):t==="parameters"&&v?e.jsx(r.Box,{children:e.jsx(N,{allComponents:x,defaultLocale:d,component:s,property:a,size:"small",fullWidth:!0,valueImmutable:G.default((U=(E=(q=(O=v.renderer.properties)==null?void 0:O[a.id])==null?void 0:q.locales)==null?void 0:E[p])==null?void 0:U.value),value:((J=(H=(L=(X=v.renderer.properties)==null?void 0:X[a.id])==null?void 0:L.locales)==null?void 0:H[p])==null?void 0:J.value)??((ue=(ce=($=(Y=v.renderer.properties)==null?void 0:Y[a.id])==null?void 0:$.locales)==null?void 0:ce[d])==null?void 0:ue.value)??((pe=(de=a.locales)==null?void 0:de[p])==null?void 0:pe.defaultValue)??((me=(xe=a.locales)==null?void 0:xe[d])==null?void 0:me.defaultValue),onChange:K=>{k.transact(()=>{var W,fe,he,je,be;(W=v.renderer).properties??(W.properties={}),(fe=v.renderer.properties)[he=a.id]??(fe[he]={}),(je=v.renderer.properties[a.id]).locales??(je.locales={}),(be=v.renderer.properties[a.id].locales)[p]??(be[p]={}),v.renderer.properties[a.id].locales[p].value=K})}})}):null},a.id)},p)})},a.id))})]})})}),e.jsx(r.DialogActions,{children:e.jsx(r.Button,{onClick:a=>{var p;return(p=o.onClose)==null?void 0:p.call(o,a,"escapeKeyDown")},children:l("close")})})]})}const Pe=(t,s)=>o=>{const l=[o.palette.primary.main,o.palette.secondary.main,o.palette.success.main,o.palette.warning.main,o.palette.info.main],u=t%l.length,h=l[u%l.length],d=ge.alpha(h,.5),x=ge.alpha(h,1);return{borderColor:`${d} !important`,borderLeft:"3px solid !important",borderLeftColor:d,color:x,...s}};function Ht({property:t,onChange:s,defaultLocale:o,allComponents:l}){const{t:u,locale:h}=_.useLocaleContext(),d=I.useRef(null),x=Kt(d),k=I.useCallback(()=>{if(!(t.type!=="json"&&t.type!=="yaml"&&t.type!=="array")&&t.subProperties)try{const m={};F.default(Object.values(t.subProperties),"index").filter(i=>i.data.visible!==!1&&i.data.key).forEach(({data:i})=>{var a,p,f,S;if(!i.key)return;let n=((p=(a=i.locales)==null?void 0:a[h])==null?void 0:p.defaultValue)??((S=(f=i.locales)==null?void 0:f[o])==null?void 0:S.defaultValue);if(i.type==="number")n=Number(n);else if(i.type==="boolean")n=n===!0||n==="true";else if((i.type==="json"||i.type==="yaml")&&typeof n=="string")try{i.type==="json"?n=JSON.parse(n):n=le.parse(n)}catch(c){console.error("Error parsing nested value",n,c),n={}}m[i.key]=n});const j=T.transformValue(m,t.type);s==null||s(j)}catch(m){console.error("Error converting structure to text:",m)}},[t,h,o,s]);return t.type!=="json"&&t.type!=="yaml"&&t.type!=="array"?null:e.jsxs(r.Stack,{direction:"column",gap:1.5,sx:{width:"100%"},children:[e.jsx(r.Divider,{sx:{mt:-1},children:e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:u("maker.properties.subProperties")})}),t.subProperties&&Object.keys(t.subProperties).length>0?e.jsx(Ce,{component:r.Stack,gap:2,list:t.subProperties,renderItem:(m,v,j)=>{const i=m.visible!==!1;return e.jsx(r.Paper,{ref:d,elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed","&":Pe(x)},children:e.jsx(r.Stack,{gap:2,children:e.jsx(Oe,{data:m,params:j,visible:i,config:{properties:t.subProperties},currentLocale:h,defaultLocale:o,allComponents:l,onUpdateConfig:n=>{try{const a={properties:t.subProperties||{}};n(a);const p={...t,subProperties:a.properties};s==null||s(p,{forceUpdateProperty:!0}),k()}catch(a){console.error("Error updating property:",a)}}})})},m.id)}}):e.jsx(Q.default,{style:{fontSize:12,height:100},children:u("maker.properties.noSubProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",size:"small",startIcon:e.jsx(A.AddRounded,{}),onClick:()=>{try{const m=t.subProperties||{},v=T.nextId(),i={index:Object.values(m).length,data:{id:v,key:"",type:"string",visible:!0,locales:{[h]:{name:"",defaultValue:""}},subProperties:{}}},n={...t,subProperties:{...m,[v]:i}};s==null||s(n,{forceUpdateProperty:!0}),k()}catch(m){console.error("Error adding property:",m)}},sx:{"&":Pe(x,{})},children:u("maker.properties.addSubProperty")})]})}function N({component:t,property:s,value:o,onChange:l,valueImmutable:u,defaultLocale:h,allComponents:d,...x}){var n,a,p,f,S;const{locale:k}=_.useLocaleContext(),m=z.useUploader(),v=I.useRef(null),j=()=>{var y;const c=(y=m==null?void 0:m.current)==null?void 0:y.getUploader();c==null||c.open(),v.current&&c.onceUploadSuccess(({response:g})=>{var C,b;let P=((C=g==null?void 0:g.data)==null?void 0:C.filename)||"";P&&(P=`mediakit://${P}`,o&&!o.includes("mediakit://")&&(P+=" # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")),(b=v.current)==null||b.call(v,P)})},i=x.label||((a=(n=s.locales)==null?void 0:n[k])==null?void 0:a.name)||((f=(p=s.locales)==null?void 0:p[h])==null?void 0:f.name)||s.key||s.id;if(s.type==="number")return e.jsx(Jt,{...x,label:i,NumberProps:{value:["number","string"].includes(typeof o)?o:null,onChange:(c,y)=>l==null?void 0:l(y)}});if(s.type==="decimal")return e.jsx(r.TextField,{...x,label:i,type:"text",value:o??"",onChange:c=>{const y=c.target.value;if(y===""||y==="-"){l==null||l(y);return}if(/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(y)){let P=y;/^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(P)&&(P=Number(P)),l==null||l(P)}}});if(s.type==="boolean")return e.jsx(r.FormControlLabel,{label:i,labelPlacement:"start",control:e.jsx(r.Switch,{checked:o===!0,onChange:(c,y)=>l==null?void 0:l(y)})});if(s.type==="color")return e.jsx(At,{label:i,value:o,onChange:c=>{l==null||l(c)}});if(s.type==="json"||s.type==="yaml")return e.jsx(Vt,{label:i,value:o,onChange:c=>{l==null||l(c)},property:s,component:t,defaultLocale:h,allComponents:d,PropertyValueField:N,onUpload:c=>{v.current=c,j()}});if(s.type==="custom"){const c=(S=d[s.componentId])==null?void 0:S.data;return c?e.jsx(r.Box,{width:"100%",children:e.jsx(ee.CustomComponentRenderer,{componentId:c.id,props:{label:i,value:o,onChange:l},locale:k,dev:{mode:"draft",components:d,defaultLocale:h}})}):e.jsx(r.TextField,{...x,label:i,disabled:!0,placeholder:"Click right button select a component"})}if(s.type==="component")return e.jsxs(r.Stack,{width:"100%",direction:"row",gap:1,children:[e.jsx(r.Box,{flex:1,children:e.jsx(te,{allComponents:d,label:i,value:o==null?void 0:o.componentId,onChange:(c,y)=>{u||!o?l==null||l({...o&&JSON.parse(JSON.stringify(o)),componentId:y}):typeof o=="object"&&(o.componentId=y)}})}),e.jsx(r.Box,{children:e.jsx(Lt,{value:o,valueImmutable:u,onChange:l,defaultLocale:h,allComponents:d})})]});if(!s.type||["string","url"].includes(s.type)){const c=s.type==="string"?s.multiline:void 0,y=s.type==="url"?o==null?void 0:o.url:o;return e.jsx(r.TextField,{...x,label:i,value:typeof y=="string"?y:"",multiline:c,minRows:c?2:void 0,maxRows:c?10:void 0,onChange:g=>l==null?void 0:l(s.type==="url"?{...o,url:g.target.value,mediaKitUrl:g.target.value}:g.target.value),InputProps:s.type==="url"?{sx:{pr:0},endAdornment:e.jsxs(r.InputAdornment,{position:"end",children:[e.jsx(z.UploaderButton,{onChange:async({response:g})=>{var w,B,O;const P=((w=g==null?void 0:g.data)==null?void 0:w.url)||((B=g==null?void 0:g.data)==null?void 0:B.fileUrl);let C;P&&(C=await z.getImageSize(P).catch(()=>z.getVideoSize(P)).catch(()=>{}));let b=((O=g==null?void 0:g.data)==null?void 0:O.filename)||"";b&&(b=`mediakit://${b}`),l==null||l({url:P,mediaKitUrl:b,width:C==null?void 0:C.naturalWidth,height:C==null?void 0:C.naturalHeight})}}),e.jsx(r.Tooltip,{title:"If you are using the 'mediaKitUrl' property, please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address.",children:e.jsx(A.InfoRounded,{sx:{cursor:"default"},fontSize:"small"})})]})}:void 0})}return s.type==="array"?e.jsx(Tt,{label:i,value:Array.isArray(o)?o:[],onChange:c=>l==null?void 0:l(c),property:s,renderItem:({item:c,index:y,onChange:g})=>s.subProperties&&Object.keys(s.subProperties).length>0?e.jsx(r.Stack,{gap:1,width:"100%",children:F.default(Object.values(s.subProperties),"index").filter(P=>P.data.visible!==!1).map(({data:P})=>P.key?e.jsx(N,{component:t,property:P,value:c[P.key],onChange:C=>{const b={...c,[P.key]:C};g(b)},size:"small",fullWidth:!0,defaultLocale:h,allComponents:d},P.id):null)},y):e.jsx(r.TextField,{size:x.size,fullWidth:!0,value:c,onChange:P=>g(P.target.value)})}):(console.error("Unsupported property type",s.type),null)}function Jt({NumberProps:t,...s}){const{getInputProps:o}=ae.unstable_useNumberInput(t),l=o();return e.jsx(r.TextField,{...s,inputProps:l})}const De=`import React from '@blocklet/pages-kit/builtin/react'
|
|
21
|
+
`;function At({value:t,onChange:s,...o}){const l=I.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(Ot,{...o,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(Dt,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{var u;(u=l.current)==null||u.open({value:t??""})}})})}}),e.jsx(zt,{ref:l,onSave:({value:u},m)=>{s(u),m()}})]})}function Vt({label:t,value:s,onChange:o,property:l,component:u,defaultLocale:m,allComponents:d,PropertyValueField:x,onUpload:k}){const{locale:f}=_.useLocaleContext(),v=I.useRef(null);if(!we.default(l.subProperties)){const i=F.default(Object.values(l.subProperties||{}),"index").filter(n=>n.data.visible!==!1&&n.data.key);return e.jsxs(r.Stack,{width:"100%",children:[e.jsx(r.FormLabel,{sx:{px:.25,py:.5},children:t}),e.jsx(r.Box,{children:e.jsx(r.Box,{sx:{position:"relative"},children:i.map((n,c)=>{const{data:p}=n,h=p.key??p.id,S=c===i.length-1;let a=null;try{s&&typeof s=="object"?a=s[h]:typeof s=="string"&&(a=(l.type==="yaml"?le.parse(s||""):JSON.parse(s||"{}"))[h])}catch{}a==null&&(p.locales&&f&&p.locales[f]?a=p.locales[f].defaultValue:p.locales&&m&&p.locales[m]&&(a=p.locales[m].defaultValue));const y=P=>{try{let C={};if(typeof s=="string")try{C=l.type==="yaml"?le.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(C={...s});Ie.default(C,h,P);const b=T.transformValue(C,l.type);o==null||o(b)}catch(C){console.error("Error updating property:",C)}},g=8;return e.jsxs(r.Box,{sx:{mb:S?0:1,display:"flex",flexDirection:"row"},children:[e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:g,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:g,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!S&&e.jsx(r.Box,{sx:{position:"absolute",left:g,top:16,bottom:-8,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsx(r.Box,{sx:{flexGrow:1},children:e.jsx(x,{component:u,property:p,value:a,onChange:y,size:"small",fullWidth:!0,defaultLocale:m,allComponents:d})})]},p.id)})})})]})}return e.jsx(r.Stack,{width:"100%",gap:2,children:e.jsxs(r.Stack,{sx:{width:"100%",position:"relative",pt:1,pb:"6px",px:"1px",minHeight:50,".monaco-editor,.overflow-guard":{borderRadius:1}},children:[e.jsx(r.FormLabel,{sx:{position:"absolute",left:0,top:0,transform:"translate(0px, -7px) scale(0.75)"},children:t}),e.jsx(ie.CodeEditor,{keyId:l.id,locale:f,language:l.type==="yaml"?"yaml":"json",value:typeof s=="string"?s:"",onChange:i=>{o==null||o(i)},onUpload:i=>{v.current=i,k&&k(i)}},l.id),e.jsx(r.Box,{component:"fieldset",sx:{pointerEvents:"none",position:"absolute",left:0,top:-5,width:"100%",height:"100%",border:1,borderColor:"rgba(0, 0, 0, 0.23)",borderRadius:1,px:1,py:0},children:e.jsx(r.Box,{component:"legend",sx:{fontSize:"0.75em"},children:e.jsx(r.Box,{component:"span",sx:{opacity:0},children:t})})})]})})}const Se=["string","multiline","json","yaml","component","custom","url"];function Ce({disabled:t,list:s,renderItem:o,...l}){const u=I.useRef(null),m=I.useId(),d=re.useUpdate(),x=F.default(Object.entries(s),n=>n[1].index).map(n=>n[0]),k=I.useRef(x),f=I.useCallback(n=>{k.current=n,d()},[d]),v=I.useCallback(({index:n},{index:c})=>{const p=[...k.current];p.splice(c,0,...p.splice(n,1)),f(p)},[f]);I.useEffect(()=>{f(x)},[x.join("-")]);const[{isOver:j},i]=se.useDrop({accept:m,collect:n=>({isOver:n.isOver()}),canDrop:()=>!t,drop:()=>{var p;const n=()=>{k.current.forEach((h,S)=>{const a=s[h];a&&(a.index=S)})},c=(p=M.getYjsValue(s))==null?void 0:p.doc;c?c.transact(()=>{n()}):n()}});return I.useEffect(()=>{j||f(x)},[j]),i(u),e.jsx(r.Box,{...l,ref:u,className:Ge.cx(j&&"isDragging"),children:k.current.map((n,c)=>e.jsx(Ft,{type:m,disabled:t,id:n,index:c,itemIndex:p=>k.current.indexOf(p),move:v,children:p=>{const h=s[n];return h?o(h.data,c,p):null}},n))})}function Ft({disabled:t,id:s,index:o,type:l,children:u,itemIndex:m,move:d}){const x=I.useRef(),[{isDragging:k},f,v]=se.useDrag({type:l,item:()=>({id:s}),canDrag:()=>!t,collect:i=>({isDragging:i.isDragging()})}),[,j]=se.useDrop({accept:l,canDrop:()=>!t,hover(i,n){var g;if(!x.current)return;const c=m(i.id),p=o;if(c===p)return;const h=(g=x.current)==null?void 0:g.getBoundingClientRect(),S=(h.bottom-h.top)/2,y=n.getClientOffset().y-h.top;c<p&&y<S||c>p&&y>S||d({id:i.id,index:c},{id:s,index:o})}});return typeof u=="function"?u({isDragging:k,drag:f,drop:i=>(x.current=i,j(i)),preview:v}):(f(j(v(x))),e.jsx(r.Box,{ref:x,children:u}))}function qt({drop:t,preview:s,drag:o,disabled:l,isDragging:u,children:m,onDelete:d,onVisibilityChange:x,visible:k=!0,actions:f,alwaysShowActions:v=!1}){const{t:j}=_.useLocaleContext();return e.jsx(r.Box,{ref:t,sx:{":hover .hover-visible":{maxWidth:"100%"},opacity:k?1:.5},children:e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsx(r.Box,{ref:s,sx:{flex:1,borderRadius:.5,bgcolor:u?"action.hover":"background.paper",opacity:.9999},children:m}),!l&&e.jsx(r.Box,{className:v?"":"hover-visible",sx:{maxWidth:v?"100%":0,overflow:"hidden",position:"absolute",right:2,top:2,transition:"max-width 0.3s ease-in-out"},children:e.jsxs(r.Stack,{direction:"row",sx:{bgcolor:i=>r.alpha(i.palette.grey[200],.9),borderRadius:1,p:.5,[`.${r.buttonClasses.root}`]:{minWidth:24,width:24,height:24,p:0}},children:[f,x&&e.jsx(r.Tooltip,{title:j(k?"hideParameter":"showParameter"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>x(!k),children:k?e.jsx(A.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(A.VisibilityRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),d&&e.jsx(r.Tooltip,{title:j("delete"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:d,children:e.jsx(A.DeleteOutlineRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),e.jsx(r.Tooltip,{title:j("dragSort"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{ref:o,children:e.jsx(A.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function Nt({label:t,value:s,onChange:o}){const[l,u]=I.useState(!1);return e.jsxs(r.Stack,{gap:1,children:[e.jsx(r.TextField,{label:t,size:"small",value:s,onChange:m=>o==null?void 0:o(m.target.value),InputProps:{endAdornment:e.jsx(z.UploaderButton,{onChange:({response:m})=>{var x;const d=(x=m==null?void 0:m.data)==null?void 0:x.filename;d&&(o==null||o(d))}})}}),s&&e.jsx(r.Box,{component:"img",sx:{objectFit:"contain",borderRadius:1,cursor:"pointer"},src:T.getImageAbsoluteUrl(s),alt:t,maxWidth:100,maxHeight:100,width:"100%",onClick:()=>u(!0)}),e.jsx(r.Dialog,{open:l,onClose:()=>u(!1),children:e.jsx(r.Box,{component:"img",sx:{objectFit:"contain"},src:T.getImageAbsoluteUrl(s),alt:t})})]})}function oe(t,s=""){return wt.default(t,(o,l,u)=>{const m=s?`${s}.${u}`:u;return vt.default(l)?yt.default(o,oe(l,m)):o[m]=l,o},{})}const Et=[{value:"string",label:"Text"},{value:"multiline",label:"Text (Multiline)"},{value:"number",label:"Number"},{value:"decimal",label:"Decimal"},{value:"boolean",label:"Boolean"},{value:"color",label:"Color"},{value:"url",label:"URL (Upload)"},{value:"json",label:"JSON"},{value:"yaml",label:"YAML"},{value:"array",label:"Array"},{value:"component",label:"Component"},{value:"custom",label:"Custom (Render by a Component)"}];function Z(t,s,o){return!t||!o?!1:Object.values(t).some(({data:l})=>l.id!==s&&l.key===o)}function Be(t,s){var o;return!t||!s?!1:((o=t[s])==null?void 0:o.data.visible)??!0}function Ut({componentId:t}){const{state:{components:s}}=T.useStore(),o=s[t],l=o==null?void 0:o.data;return l?e.jsx(r.Stack,{maxHeight:"100%",overflow:"auto",children:e.jsx(r.Box,{p:2,children:e.jsx(pt.ErrorBoundary,{FallbackComponent:T.ErrorView,resetKeys:[t],children:e.jsx(Wt,{value:l})})})}):null}function Wt({value:t}){var k,f,v;const{t:s}=_.useLocaleContext(),{localState:{currentLocale:o,componentDebugProps:l},state:{config:{defaultLocale:u}},localActions:{setComponentDebugProps:m}}=T.useStore(),d=M.getYjsValue(t).doc,x=T.useAllComponents();return e.jsx(r.Stack,{height:"100%",children:e.jsxs(r.Stack,{gap:2,children:[e.jsx(Te,{config:t}),e.jsx(Re,{config:t,currentLocale:o,defaultLocale:u,allComponents:x,onUpdateConfig:j=>{d.transact(()=>{j(t)})}}),e.jsxs(r.Stack,{gap:2,direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(r.Typography,{variant:"subtitle1",children:s("renderer")}),e.jsxs(r.TextField,{hiddenLabel:!0,size:"small",select:!0,SelectProps:{autoWidth:!0},value:((k=t.renderer)==null?void 0:k.type)||"react-component",onChange:j=>{d.transact(()=>{const i=j.target.value;t.renderer??(t.renderer={type:i}),t.renderer.type=i})},children:[e.jsx(r.MenuItem,{value:"react-component",children:"React Component"}),e.jsx(r.MenuItem,{value:"component",children:"Custom Component"})]})]}),((f=t.renderer)==null?void 0:f.type)==="component"?e.jsx($t,{value:t}):((v=t.renderer)==null?void 0:v.type)==="react-component"?e.jsx(Yt,{value:t}):null,e.jsx(Ae,{config:t,currentLocale:o,defaultLocale:u,allComponents:x,onChange:({key:j,value:i})=>{m({[j]:i.value})},props:{...l}})]})})}function Te({config:t}){const{t:s}=_.useLocaleContext();return e.jsx(z.UploaderProvider,{children:e.jsxs(r.Stack,{gap:2,children:[e.jsx(r.Typography,{variant:"subtitle1",children:s("basicInfo")}),e.jsx(r.TextField,{label:s("name"),size:"small",value:t.name||"",onChange:o=>t.name=o.target.value}),e.jsx(r.TextField,{label:s("description"),size:"small",multiline:!0,minRows:2,maxRows:10,inputProps:{maxLength:200},value:t.description||"",onChange:o=>t.description=o.target.value}),e.jsx(r.Autocomplete,{size:"small",options:[],multiple:!0,freeSolo:!0,value:t.tags??[],onChange:(o,l)=>t.tags=l,renderInput:o=>e.jsx(r.TextField,{label:s("tags"),...o})}),e.jsx(Nt,{label:s("previewImage"),value:t.previewImage||"",onChange:o=>t.previewImage=o})]})})}function Oe({data:t,params:s,visible:o,config:l,currentLocale:u,defaultLocale:m,allComponents:d,onUpdateConfig:x}){var v,j,i,n,c,p;const{t:k}=_.useLocaleContext(),f=I.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?Ht:N,[t.type]);return e.jsx(qt,{preview:s.preview,drop:s.drop,drag:s.drag,isDragging:s.isDragging,onDelete:()=>{x(h=>{if(h.properties){const a=Object.entries(h.properties).sort(([,g],[,P])=>g.index-P.index);delete h.properties[t.id],a.filter(([g])=>g!==t.id).forEach(([,g],P)=>{g.index=P})}})},visible:o,onVisibilityChange:h=>{x(S=>{const a=S.properties[t.id].data;a.visible=h})},alwaysShowActions:!0,children:e.jsxs(r.Stack,{direction:"column",gap:2,children:[e.jsx(r.TextField,{label:k("key"),size:"small",required:!0,sx:{width:"calc(100% - 80px - 8px)",flex:1,"& .MuiOutlinedInput-root":{borderColor:t.key?Z(l.properties,t.id,t.key)?"warning.main":void 0:"error.main"},"& .MuiFormLabel-root":{color:t.key?Z(l.properties,t.id,t.key)?"warning.main":"text.secondary":"error.main"},"& .MuiFormLabel-root.Mui-focused":{color:t.key?Z(l.properties,t.id,t.key)?"warning.main":"primary.main":"error.main"}},value:t.key||"",onChange:h=>{x(S=>{const a=S.properties[t.id].data;a.key=h.target.value.trim()})},InputProps:{endAdornment:!t.key||t.key&&Z(l.properties,t.id,t.key)?e.jsx(r.InputAdornment,{position:"end",sx:{width:16,ml:0},children:e.jsx(r.Tooltip,{title:t.key?k("duplicateKey"):k("requiredKey"),children:e.jsx(A.InfoRounded,{sx:{color:t.key?"warning.main":"error.main",fontSize:16}})})}):null}}),e.jsxs(r.Stack,{direction:"row",gap:1,children:[e.jsx(r.TextField,{label:k("label"),size:"small",sx:{flex:1},value:(((j=(v=t.locales)==null?void 0:v[u])==null?void 0:j.name)??((n=(i=t.locales)==null?void 0:i[m])==null?void 0:n.name))||"",onChange:h=>{x(S=>{var y;const a=S.properties[t.id].data;a.locales??(a.locales={}),(y=a.locales)[u]??(y[u]={}),a.locales[u].name=h.target.value})}}),e.jsx(r.TextField,{label:k("type"),size:"small",select:!0,sx:{flex:1},value:t.type==="string"&&t.multiline?"multiline":t.type||"string",onChange:h=>{x(S=>{const a=S.properties[t.id].data;if(a.locales)for(const g of Object.keys(a.locales))a.locales[g].defaultValue=void 0;const y=h.target.value;y==="multiline"?(a.type="string",a.multiline=!0):(typeof a.multiline<"u"&&delete a.multiline,a.type=y)})},children:Et.map(h=>e.jsx(r.MenuItem,{value:h.value,children:h.label},h.value))})]}),e.jsxs(r.Stack,{direction:"row",gap:1,children:[e.jsx(f,{allComponents:d,defaultLocale:m,component:l,property:t,label:k("defaultValue"),size:"small",fullWidth:!0,value:(p=(c=t.locales)==null?void 0:c[u])==null?void 0:p.defaultValue,onChange:(h,S)=>{x(a=>{var g;const y=a.properties[t.id].data;if(S!=null&&S.forceUpdateProperty){const P=oe(y),C=oe(h);Object.keys(C).forEach(b=>{P[b]||Ie.default(y,b,C[b])})}else y.locales??(y.locales={}),(g=y.locales)[u]??(g[u]={}),y.locales[u].defaultValue=h})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(Mt,{property:t,allComponents:d})}):null]})]})})}function Kt(t,s){const[o,l]=I.useState(0);return I.useEffect(()=>{const m=setTimeout(()=>{if(t.current){let d=t.current.parentElement,x=0;for(;d;)d.classList.contains("property-container")&&x++,d=d.parentElement;l(x)}},100);return()=>clearTimeout(m)},[t,s]),o}function Re({config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:u,useI18nEditor:m=!0}){const{t:d}=_.useLocaleContext(),x=V.usePopupState({variant:"dialog"}),k=t.properties&&F.default(Object.values(t.properties),"index");return e.jsx(z.UploaderProvider,{children:e.jsxs(r.Stack,{gap:2,children:[e.jsxs(r.Stack,{direction:"row",gap:1,alignItems:"center",justifyContent:"space-between",children:[e.jsx(r.Typography,{variant:"subtitle1",children:d("properties")}),e.jsx(r.Box,{flex:1}),m&&e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...V.bindTrigger(x),children:e.jsx(A.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(Ce,{component:r.Stack,gap:2,list:t.properties,renderItem:(f,v,j)=>{const i=Be(t.properties,f.id);return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed",borderColor:"divider"},children:e.jsx(r.Stack,{gap:2,children:e.jsx(Oe,{data:f,params:j,visible:i,config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:u})})},f.id)}}):e.jsx(Q.default,{style:{fontSize:12},children:d("maker.properties.noProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",onClick:()=>{u(f=>{var j;const v=T.nextId();f.properties??(f.properties={}),(j=f.properties)[v]??(j[v]={index:(k==null?void 0:k.length)||0,data:{id:v}})})},startIcon:e.jsx(A.AddRounded,{}),children:d("addObject",{object:d("property")})}),m&&e.jsx(_e,{...V.bindDialog(x),component:t})]})})}function Mt({property:t,allComponents:s}){const o=V.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...V.bindTrigger(o),children:e.jsx(A.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...V.bindPopper(o),children:e.jsx(ce.ClickAwayListener,{onClickAway:o.close,children:e.jsx(r.Paper,{children:e.jsx(r.Box,{width:500,p:2,children:e.jsx(te,{value:t.componentId,onChange:(l,u)=>t.componentId=u,allComponents:s})})})})})]})}function Lt({value:t,valueImmutable:s,onChange:o,defaultLocale:l,allComponents:u}){var k;const m=V.usePopupState({variant:"popper"}),{locale:d}=_.useLocaleContext(),x=typeof(t==null?void 0:t.componentId)=="string"?(k=u[t.componentId])==null?void 0:k.data:void 0;return x?e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},disabled:!x,...V.bindTrigger(m),children:e.jsx(A.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...V.bindPopper(m),sx:{zIndex:1e3},children:e.jsx(ce.ClickAwayListener,{onClickAway:m.close,children:e.jsx(r.Paper,{children:e.jsxs(r.Box,{width:500,p:2,children:[e.jsx(r.Typography,{variant:"subtitle1",children:"Parameters"}),e.jsx(r.Stack,{gap:1,children:(x==null?void 0:x.properties)&&F.default(Object.values(x.properties),"index").map(({data:f})=>{var v,j,i,n,c,p,h,S;return e.jsx(r.Box,{children:e.jsx(N,{allComponents:u,defaultLocale:l,size:"small",fullWidth:!0,component:x,property:f,valueImmutable:G.default((j=(v=t.properties)==null?void 0:v[f.id])==null?void 0:j.value),value:((n=(i=t.properties)==null?void 0:i[f.id])==null?void 0:n.value)??((p=(c=f.locales)==null?void 0:c[d])==null?void 0:p.defaultValue)??((S=(h=f.locales)==null?void 0:h[l])==null?void 0:S.defaultValue),onChange:a=>{if(s){const y=JSON.parse(JSON.stringify(t));o==null||o({...y,properties:{...y.properties,[f.id]:{value:a}}})}else M.getYjsValue(x).doc.transact(()=>{t.properties??(t.properties={}),t.properties[f.id]={value:a}})}})},f.id)})})]})})})})]}):null}function _e({type:t="properties",component:s,...o}){var j,i,n;const{t:l}=_.useLocaleContext(),{state:{components:u,supportedLocales:m,config:{defaultLocale:d}}}=T.useStore(),x=T.useAllComponents(),k=M.getYjsValue(s).doc,f=t==="properties"?s.properties:t==="parameters"&&((j=s.renderer)==null?void 0:j.type)==="component"?(i=u[s.renderer.componentId])==null?void 0:i.data.properties:void 0,v=((n=s.renderer)==null?void 0:n.type)==="component"?s:void 0;return e.jsxs(r.Dialog,{...o,fullWidth:!0,maxWidth:"lg",children:[e.jsx(r.DialogTitle,{children:l("i18nEditorTitle")}),e.jsx(r.DialogContent,{children:f&&e.jsx(r.Stack,{children:e.jsxs(r.Table,{stickyHeader:!0,sx:{td:{verticalAlign:"top"}},children:[e.jsx(r.TableHead,{children:e.jsx(r.TableRow,{children:m.map(({locale:c,name:p})=>e.jsxs(r.TableCell,{children:[p,d===c&&e.jsx(A.StarRounded,{sx:{fontSize:12,color:"text.secondary"}})]},c))})}),e.jsx(r.TableBody,{children:F.default(Object.values(f),"index").map(({data:c})=>e.jsx(r.TableRow,{children:m.map(({locale:p})=>{var h,S,a,y,g,P,C,b,w,B,O,q,E,U,X,L,H,J,Y,$,ae,ue,de,pe,xe,me;return e.jsx(r.TableCell,{children:e.jsx(r.Stack,{gap:1,children:t==="properties"?e.jsxs(e.Fragment,{children:[e.jsx(r.TextField,{size:"small",label:"Key",value:c.key||"",onChange:K=>{k.transact(()=>{c.key=K.target.value.trim()})}}),e.jsx(r.TextField,{size:"small",label:l("label"),value:(((S=(h=c.locales)==null?void 0:h[p])==null?void 0:S.name)??((y=(a=c.locales)==null?void 0:a[d])==null?void 0:y.name))||"",onChange:K=>{k.transact(()=>{var W;c.locales??(c.locales={}),(W=c.locales)[p]??(W[p]={}),c.locales[p].name=K.target.value})}}),e.jsx(r.Box,{children:e.jsx(N,{allComponents:x,defaultLocale:d,component:s,property:c,size:"small",fullWidth:!0,label:"Default Value",valueImmutable:G.default((P=(g=c.locales)==null?void 0:g[p])==null?void 0:P.defaultValue),value:((b=(C=c.locales)==null?void 0:C[p])==null?void 0:b.defaultValue)??((B=(w=c.locales)==null?void 0:w[d])==null?void 0:B.defaultValue),onChange:K=>{k.transact(()=>{var W;c.locales??(c.locales={}),(W=c.locales)[p]??(W[p]={}),c.locales[p].defaultValue=K})}})})]}):t==="parameters"&&v?e.jsx(r.Box,{children:e.jsx(N,{allComponents:x,defaultLocale:d,component:s,property:c,size:"small",fullWidth:!0,valueImmutable:G.default((U=(E=(q=(O=v.renderer.properties)==null?void 0:O[c.id])==null?void 0:q.locales)==null?void 0:E[p])==null?void 0:U.value),value:((J=(H=(L=(X=v.renderer.properties)==null?void 0:X[c.id])==null?void 0:L.locales)==null?void 0:H[p])==null?void 0:J.value)??((ue=(ae=($=(Y=v.renderer.properties)==null?void 0:Y[c.id])==null?void 0:$.locales)==null?void 0:ae[d])==null?void 0:ue.value)??((pe=(de=c.locales)==null?void 0:de[p])==null?void 0:pe.defaultValue)??((me=(xe=c.locales)==null?void 0:xe[d])==null?void 0:me.defaultValue),onChange:K=>{k.transact(()=>{var W,fe,he,je,be;(W=v.renderer).properties??(W.properties={}),(fe=v.renderer.properties)[he=c.id]??(fe[he]={}),(je=v.renderer.properties[c.id]).locales??(je.locales={}),(be=v.renderer.properties[c.id].locales)[p]??(be[p]={}),v.renderer.properties[c.id].locales[p].value=K})}})}):null},c.id)},p)})},c.id))})]})})}),e.jsx(r.DialogActions,{children:e.jsx(r.Button,{onClick:c=>{var p;return(p=o.onClose)==null?void 0:p.call(o,c,"escapeKeyDown")},children:l("close")})})]})}const Pe=(t,s)=>o=>{const l=[o.palette.info.main,o.palette.primary.main,o.palette.secondary.main,o.palette.success.main,o.palette.warning.main],u=Math.min(l.length-1,t),m=l[u],d=ge.alpha(m,.5),x=ge.alpha(m,1);return{borderColor:`${d} !important`,borderLeft:"3px solid !important",borderLeftColor:d,color:x,...s}};function Ht({property:t,onChange:s,defaultLocale:o,allComponents:l}){const{t:u,locale:m}=_.useLocaleContext(),d=I.useRef(null),x=Kt(d,t),k=I.useCallback(()=>{if(!(t.type!=="json"&&t.type!=="yaml"&&t.type!=="array")&&t.subProperties)try{const f={};F.default(Object.values(t.subProperties),"index").filter(i=>i.data.visible!==!1&&i.data.key).forEach(({data:i})=>{var c,p,h,S;if(!i.key)return;let n=((p=(c=i.locales)==null?void 0:c[m])==null?void 0:p.defaultValue)??((S=(h=i.locales)==null?void 0:h[o])==null?void 0:S.defaultValue);if(i.type==="number")n=Number(n);else if(i.type==="boolean")n=n===!0||n==="true";else if((i.type==="json"||i.type==="yaml")&&typeof n=="string")try{i.type==="json"?n=JSON.parse(n):n=le.parse(n)}catch(a){console.error("Error parsing nested value",n,a),n={}}f[i.key]=n});const j=T.transformValue(f,t.type);s==null||s(j)}catch(f){console.error("Error converting structure to text:",f)}},[t,m,o,s]);return t.type!=="json"&&t.type!=="yaml"&&t.type!=="array"?null:e.jsxs(r.Stack,{direction:"column",gap:1.5,sx:{width:"100%"},ref:d,children:[e.jsx(r.Divider,{sx:{mt:-1},children:e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:u("maker.properties.subProperties")})}),t.subProperties&&Object.keys(t.subProperties).length>0?e.jsx(Ce,{component:r.Stack,gap:2,list:t.subProperties,renderItem:(f,v,j)=>{const i=f.visible!==!1;return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed","&":Pe(x)},children:e.jsx(r.Stack,{gap:2,children:e.jsx(Oe,{data:f,params:j,visible:i,config:{properties:t.subProperties},currentLocale:m,defaultLocale:o,allComponents:l,onUpdateConfig:n=>{try{const c={properties:t.subProperties||{}};n(c);const p={...t,subProperties:c.properties};s==null||s(p,{forceUpdateProperty:!0}),k()}catch(c){console.error("Error updating property:",c)}}})})},f.id)}}):e.jsx(Q.default,{style:{fontSize:12,height:100},children:u("maker.properties.noSubProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",size:"small",startIcon:e.jsx(A.AddRounded,{}),onClick:()=>{try{const f=t.subProperties||{},v=T.nextId(),i={index:Object.values(f).length,data:{id:v,key:"",type:"string",visible:!0,locales:{[m]:{name:"",defaultValue:""}},subProperties:{}}},n={...t,subProperties:{...f,[v]:i}};s==null||s(n,{forceUpdateProperty:!0}),k()}catch(f){console.error("Error adding property:",f)}},sx:{"&":Pe(x,{})},children:u("maker.properties.addSubProperty")})]})}function N({component:t,property:s,value:o,onChange:l,valueImmutable:u,defaultLocale:m,allComponents:d,...x}){var n,c,p,h,S;const{locale:k}=_.useLocaleContext(),f=z.useUploader(),v=I.useRef(null),j=()=>{var y;const a=(y=f==null?void 0:f.current)==null?void 0:y.getUploader();a==null||a.open(),v.current&&a.onceUploadSuccess(({response:g})=>{var C,b;let P=((C=g==null?void 0:g.data)==null?void 0:C.filename)||"";P&&(P=`mediakit://${P}`,o&&!o.includes("mediakit://")&&(P+=" # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")),(b=v.current)==null||b.call(v,P)})},i=x.label||((c=(n=s.locales)==null?void 0:n[k])==null?void 0:c.name)||((h=(p=s.locales)==null?void 0:p[m])==null?void 0:h.name)||s.key||s.id;if(s.type==="number")return e.jsx(Jt,{...x,label:i,NumberProps:{value:["number","string"].includes(typeof o)?o:null,onChange:(a,y)=>l==null?void 0:l(y)}});if(s.type==="decimal")return e.jsx(r.TextField,{...x,label:i,type:"text",value:o??"",onChange:a=>{const y=a.target.value;if(y===""||y==="-"){l==null||l(y);return}if(/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(y)){let P=y;/^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(P)&&(P=Number(P)),l==null||l(P)}}});if(s.type==="boolean")return e.jsx(r.FormControlLabel,{label:i,labelPlacement:"start",control:e.jsx(r.Switch,{checked:o===!0,onChange:(a,y)=>l==null?void 0:l(y)})});if(s.type==="color")return e.jsx(At,{label:i,value:o,onChange:a=>{l==null||l(a)}});if(s.type==="json"||s.type==="yaml")return e.jsx(Vt,{label:i,value:o,onChange:a=>{l==null||l(a)},property:s,component:t,defaultLocale:m,allComponents:d,PropertyValueField:N,onUpload:a=>{v.current=a,j()}});if(s.type==="custom"){const a=(S=d[s.componentId])==null?void 0:S.data;return a?e.jsx(r.Box,{width:"100%",children:e.jsx(ee.CustomComponentRenderer,{componentId:a.id,props:{label:i,value:o,onChange:l},locale:k,dev:{mode:"draft",components:d,defaultLocale:m}})}):e.jsx(r.TextField,{...x,label:i,disabled:!0,placeholder:"Click right button select a component"})}if(s.type==="component")return e.jsxs(r.Stack,{width:"100%",direction:"row",gap:1,children:[e.jsx(r.Box,{flex:1,children:e.jsx(te,{allComponents:d,label:i,value:o==null?void 0:o.componentId,onChange:(a,y)=>{u||!o?l==null||l({...o&&JSON.parse(JSON.stringify(o)),componentId:y}):typeof o=="object"&&(o.componentId=y)}})}),e.jsx(r.Box,{children:e.jsx(Lt,{value:o,valueImmutable:u,onChange:l,defaultLocale:m,allComponents:d})})]});if(!s.type||["string","url"].includes(s.type)){const a=s.type==="string"?s.multiline:void 0,y=s.type==="url"?o==null?void 0:o.url:o;return e.jsx(r.TextField,{...x,label:i,value:typeof y=="string"?y:"",multiline:a,minRows:a?2:void 0,maxRows:a?10:void 0,onChange:g=>l==null?void 0:l(s.type==="url"?{...o,url:g.target.value,mediaKitUrl:g.target.value}:g.target.value),InputProps:s.type==="url"?{sx:{pr:0},endAdornment:e.jsxs(r.InputAdornment,{position:"end",children:[e.jsx(z.UploaderButton,{onChange:async({response:g})=>{var w,B,O;const P=((w=g==null?void 0:g.data)==null?void 0:w.url)||((B=g==null?void 0:g.data)==null?void 0:B.fileUrl);let C;P&&(C=await z.getImageSize(P).catch(()=>z.getVideoSize(P)).catch(()=>{}));let b=((O=g==null?void 0:g.data)==null?void 0:O.filename)||"";b&&(b=`mediakit://${b}`),l==null||l({url:P,mediaKitUrl:b,width:C==null?void 0:C.naturalWidth,height:C==null?void 0:C.naturalHeight})}}),e.jsx(r.Tooltip,{title:"If you are using the 'mediaKitUrl' property, please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address.",children:e.jsx(A.InfoRounded,{sx:{cursor:"default"},fontSize:"small"})})]})}:void 0})}return s.type==="array"?e.jsx(Tt,{label:i,value:Array.isArray(o)?o:[],onChange:a=>l==null?void 0:l(a),property:s,renderItem:({item:a,index:y,onChange:g})=>s.subProperties&&Object.keys(s.subProperties).length>0?e.jsx(r.Stack,{gap:1,width:"100%",children:F.default(Object.values(s.subProperties),"index").filter(P=>P.data.visible!==!1).map(({data:P})=>P.key?e.jsx(N,{component:t,property:P,value:a[P.key],onChange:C=>{const b={...a,[P.key]:C};g(b)},size:"small",fullWidth:!0,defaultLocale:m,allComponents:d},P.id):null)},y):e.jsx(r.TextField,{size:x.size,fullWidth:!0,value:a,onChange:P=>g(P.target.value)})}):(console.error("Unsupported property type",s.type),null)}function Jt({NumberProps:t,...s}){const{getInputProps:o}=ce.unstable_useNumberInput(t),l=o();return e.jsx(r.TextField,{...s,inputProps:l})}const De=`import React from '@blocklet/pages-kit/builtin/react'
|
|
22
22
|
import { Box } from '@blocklet/pages-kit/builtin/mui/material'
|
|
23
23
|
|
|
24
24
|
export default function () {
|
|
@@ -28,4 +28,4 @@ export default function () {
|
|
|
28
28
|
</Box>
|
|
29
29
|
)
|
|
30
30
|
}`,ze=`console.log('hello')
|
|
31
|
-
`;function Yt({value:t}){const{locale:s}=_.useLocaleContext(),o=ne.useUpdate(),l=M.getYjsValue(t).doc;return I.useEffect(()=>{var u;(u=t.renderer)!=null&&u.script||(l.transact(()=>{t.renderer.script=t.renderer.type==="react-component"?De:ze}),o())},[t]),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,overflow:"hidden"},children:e.jsx(ie.CodeEditor,{keyId:t.id,locale:s,language:"typescript",value:t.renderer.script||"",onChange:u=>t.renderer.script=u,typeScriptNoValidation:!1},t.id)})}function $t({value:t}){var v,j,i;const{t:s}=_.useLocaleContext(),o=M.getYjsValue(t).doc,{state:{components:l,config:{defaultLocale:u},resources:
|
|
31
|
+
`;function Yt({value:t}){const{locale:s}=_.useLocaleContext(),o=ne.useUpdate(),l=M.getYjsValue(t).doc;return I.useEffect(()=>{var u;(u=t.renderer)!=null&&u.script||(l.transact(()=>{t.renderer.script=t.renderer.type==="react-component"?De:ze}),o())},[t]),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,overflow:"hidden"},children:e.jsx(ie.CodeEditor,{keyId:t.id,locale:s,language:"typescript",value:t.renderer.script||"",onChange:u=>t.renderer.script=u,typeScriptNoValidation:!1},t.id)})}function $t({value:t}){var v,j,i;const{t:s}=_.useLocaleContext(),o=M.getYjsValue(t).doc,{state:{components:l,config:{defaultLocale:u},resources:m},localState:{currentLocale:d}}=T.useStore(),x=T.useAllComponents(),k=((v=l[t.renderer.componentId])==null?void 0:v.data)??((i=(j=m.components)==null?void 0:j[t.renderer.componentId])==null?void 0:i.component),f=V.usePopupState({variant:"dialog"});return e.jsxs(r.Stack,{gap:1,children:[e.jsx(te,{allComponents:x,excludes:[t.id],value:t.renderer.componentId,onChange:(n,c)=>t.renderer.componentId=c}),k&&e.jsxs(e.Fragment,{children:[e.jsxs(r.Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(r.Typography,{variant:"subtitle2",children:s("parameters")}),e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...V.bindTrigger(f),children:e.jsx(A.TranslateRounded,{fontSize:"small"})})]}),k.properties&&F.default(Object.values(k.properties),"index").map(({data:n})=>{var c,p,h,S,a,y,g,P,C,b,w,B,O,q,E,U;return e.jsx(r.Box,{children:e.jsx(N,{allComponents:x,defaultLocale:u,component:k,property:n,fullWidth:!0,size:"small",valueImmutable:G.default((S=(h=(p=(c=t.renderer.properties)==null?void 0:c[n.id])==null?void 0:p.locales)==null?void 0:h[d])==null?void 0:S.value),value:((P=(g=(y=(a=t.renderer.properties)==null?void 0:a[n.id])==null?void 0:y.locales)==null?void 0:g[d])==null?void 0:P.value)??((B=(w=(b=(C=t.renderer.properties)==null?void 0:C[n.id])==null?void 0:b.locales)==null?void 0:w[u])==null?void 0:B.value)??((q=(O=n.locales)==null?void 0:O[d])==null?void 0:q.defaultValue)??((U=(E=n.locales)==null?void 0:E[u])==null?void 0:U.defaultValue),onChange:X=>{o.transact(()=>{var L,H,J,Y,$;(L=t.renderer).properties??(L.properties={}),(H=t.renderer.properties)[J=n.id]??(H[J]={}),(Y=t.renderer.properties[n.id]).locales??(Y.locales={}),($=t.renderer.properties[n.id].locales)[d]??($[d]={}),t.renderer.properties[n.id].locales[d].value=X})}})},n.id)}),e.jsx(_e,{...V.bindDialog(f),component:t,type:"parameters"})]})]})}function te({label:t,options:s,excludes:o,value:l,onChange:u,allComponents:m,...d}){var v;const{t:x}=_.useLocaleContext(),k=s??F.default(Object.values(St.default(m,...o??[])),"index").map(j=>j.data),f=(typeof l=="string"?(v=m[l])==null?void 0:v.data:void 0)??null;return e.jsx(r.Autocomplete,{...d,size:"small",options:k,autoHighlight:!0,isOptionEqualToValue:(j,i)=>j.id===i.id,getOptionKey:j=>j.id,getOptionLabel:j=>j.name||j.id,renderInput:j=>e.jsx(r.TextField,{label:t||x("component"),...j}),value:f,onChange:(j,i)=>{var c,p,h,S,a,y;let n={};i&&(n={blockletId:(c=m[i==null?void 0:i.id])==null?void 0:c.blockletId,blockletTitle:(p=m[i==null?void 0:i.id])==null?void 0:p.blockletTitle,componentName:((S=(h=m[i==null?void 0:i.id])==null?void 0:h.data)==null?void 0:S.name)||((y=(a=m[i==null?void 0:i.id])==null?void 0:a.data)==null?void 0:y.id)}),u==null||u(j,i==null?void 0:i.id,n)}})}function Ae({config:t,allComponents:s,defaultLocale:o,propertiesValue:l,currentLocale:u,onChange:m,props:d}){const{t:x}=_.useLocaleContext(),[k,f]=I.useState(t==null?void 0:t.properties),[v,j]=I.useState(null);I.useEffect(()=>{(()=>{var S,a;((S=t==null?void 0:t.renderer)==null?void 0:S.type)==="react-component"&&we.default(t==null?void 0:t.properties)?ee.transpileAndLoadScript((a=t==null?void 0:t.renderer)==null?void 0:a.script).then(y=>{const g=ee.getPropertiesFromCode(y);f(g)}):f(t==null?void 0:t.properties)})()},[JSON.stringify(t)]);const i=I.useCallback(()=>!t||!k?{}:Object.values(k).reduce((h,{data:S})=>{var y,g,P,C,b;const a=S.key||S.id;return h[S.id]={key:a,value:(d==null?void 0:d[a])??((y=l==null?void 0:l[S.id])==null?void 0:y.value)??((P=(g=S.locales)==null?void 0:g[u])==null?void 0:P.defaultValue)??((b=(C=S.locales)==null?void 0:C[o])==null?void 0:b.defaultValue),id:S.id,type:S.type},h},{}),[JSON.stringify(k),t,l,u,o]),n=I.useMemo(()=>{if(!k)return{canUseProperties:[],visibleProperties:[],canUsePropertiesKeys:[]};const h=F.default(Object.values(k),"index"),S=h.filter(({data:g})=>g.key&&Be(k,g.id)),a=h.filter(({data:g})=>g.key),y=a.map(({data:g})=>g.key);return{canUseProperties:a,visibleProperties:S,canUsePropertiesKeys:y}},[JSON.stringify(k)]),c=i(),p=kt.default(c,"key");return e.jsx(z.UploaderProvider,{children:e.jsxs(r.Stack,{gap:2,children:[e.jsx(r.Typography,{variant:"subtitle1",children:x("maker.properties.parameters")}),!t||n.canUsePropertiesKeys.length===0?e.jsx(Q.default,{style:{fontSize:12},children:x("maker.properties.noParameters")}):e.jsxs(e.Fragment,{children:[e.jsx(r.Stack,{gap:2,children:n.visibleProperties.map(({data:h})=>{var S,a;return e.jsx(r.Box,{children:e.jsx(N,{allComponents:s,defaultLocale:o,size:"small",fullWidth:!0,component:t,property:h,valueImmutable:G.default((S=l==null?void 0:l[h.id])==null?void 0:S.value),value:(d==null?void 0:d[h.key||h.id])??((a=c[h.id])==null?void 0:a.value),onChange:y=>{m({path:["properties",h.id],value:{value:y},shouldSync:!(!h.type||Se.includes(h.type)),excludeKeys:[],key:h.key||h.id})}})},h.id)})}),e.jsx(r.Stack,{gap:2,sx:{width:"100%"},children:e.jsx(ee.CustomComponentRenderer,{componentId:(t==null?void 0:t.id)||"",renderType:"setting",locale:u,properties:c,dev:{mode:"draft",components:s,defaultLocale:o},props:{...Pt.default(d??{},n.canUsePropertiesKeys),onChange:h=>{const{canUsePropertiesKeys:S}=n;Object.keys(h).filter(y=>{var g;return h[y]!==((g=p==null?void 0:p[y])==null?void 0:g.value)}).filter(y=>!(y==="locale"&&!gt.default(p[y],"locale"))).reduce((y,g)=>y.then(()=>{const P=p[g],C=S.includes(g);if(P!=null&&P.id&&C)return m({path:["properties",P.id],value:{value:h[g]},shouldSync:!(!P.type||Se.includes(P.type)),excludeKeys:[],key:P.key||P.id}),Promise.resolve();const b=`propertyNotFound${g}`;if(v===b)return Promise.resolve();ke.default.close(v);const w=ke.default.warning(x("maker.properties.propertyNotFound",{key:g}),{key:b});return j(w),Promise.resolve()}),Promise.resolve())}}})})]})]})})}exports.BasicInfo=Te;exports.CustomComponentAutocomplete=te;exports.CustomComponentSettings=Ut;exports.DefaultReactComponentScriptTemplate=De;exports.DefaultWebComponentScriptTemplate=ze;exports.ParametersConfig=Ae;exports.PropertiesConfig=Re;exports.PropertyValueField=N;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { u as o, S as a, k as s, h as n } from "./state-
|
|
2
|
+
import { u as o, S as a, k as s, h as n } from "./state-DqChB5ys.js";
|
|
3
3
|
function d({ children: t }) {
|
|
4
4
|
const r = o();
|
|
5
5
|
return /* @__PURE__ */ e(a, { url: s(r ?? ""), name: "root", waitingSynced: !0, children: /* @__PURE__ */ e(i, { children: t }) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as n, jsxs as _, Fragment as U } from "react/jsx-runtime";
|
|
2
|
-
import { a as R, g as N, i as ae, b as ce, E as le, c as ct, d as lt, e as Et, u as de, f as me } from "./state-
|
|
2
|
+
import { a as R, g as N, i as ae, b as ce, E as le, c as ct, d as lt, e as Et, u as de, f as me } from "./state-DqChB5ys.js";
|
|
3
3
|
import { useLocaleContext as zt } from "@arcblock/ux/lib/Locale/context";
|
|
4
4
|
import Wt from "@arcblock/ux/lib/Result";
|
|
5
5
|
import { useHeaderState as ue } from "@blocklet/pages-kit/builtin/page/header";
|
|
@@ -2046,7 +2046,7 @@ function jo({ mode: t }) {
|
|
|
2046
2046
|
}
|
|
2047
2047
|
return /* @__PURE__ */ n(Bo, { children: ({ state: e }) => /* @__PURE__ */ n(et, { mode: t, state: e }) });
|
|
2048
2048
|
}
|
|
2049
|
-
const Bo = Dt(() => import("./draft-data-
|
|
2049
|
+
const Bo = Dt(() => import("./draft-data-vlK5oTGT.js"));
|
|
2050
2050
|
function Ro({
|
|
2051
2051
|
mode: t,
|
|
2052
2052
|
children: e
|
|
@@ -2262,7 +2262,7 @@ function at({
|
|
|
2262
2262
|
!((bt = a.footer) != null && bt.hidden) && /* @__PURE__ */ n(wo, {})
|
|
2263
2263
|
] });
|
|
2264
2264
|
}
|
|
2265
|
-
const To = Dt(() => import("./publish-button-
|
|
2265
|
+
const To = Dt(() => import("./publish-button-BWD3lOEM.js")), re = Ht(pe)`
|
|
2266
2266
|
&.sticky {
|
|
2267
2267
|
position: sticky;
|
|
2268
2268
|
top: 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as p, Fragment as H } from "react/jsx-runtime";
|
|
2
|
-
import { u as R, l as J, f as q, P as G } from "./state-
|
|
2
|
+
import { u as R, l as J, f as q, P as G } from "./state-DqChB5ys.js";
|
|
3
3
|
import { useLocaleContext as V } from "@arcblock/ux/lib/Locale/context";
|
|
4
4
|
import I from "@arcblock/ux/lib/Toast";
|
|
5
5
|
import { Warning as F, Sync as Q, VisibilityOff as U } from "@mui/icons-material";
|
|
@@ -9,7 +9,7 @@ import { produce as oe } from "immer";
|
|
|
9
9
|
import N from "lodash/difference";
|
|
10
10
|
import { useState as D, useMemo as j, useCallback as L, forwardRef as se, useImperativeHandle as le, useEffect as ce } from "react";
|
|
11
11
|
import { useAsync as ae } from "react-use";
|
|
12
|
-
import { p as de, g as ue, L as me } from "./home-
|
|
12
|
+
import { p as de, g as ue, L as me } from "./home-BTLUdaL7.js";
|
|
13
13
|
function ge(r) {
|
|
14
14
|
const [a, y] = D(!1);
|
|
15
15
|
return /* @__PURE__ */ e(
|