@blocklet/pages-kit-inner-components 0.5.41 → 0.5.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/add-component.js +1 -1
- package/lib/cjs/chunks/{array-Cr5KF-hM.js → array-Cip5uTnI.js} +1 -1
- package/lib/cjs/chunks/{config-string-BYZ5HfyY.js → config-string-CEipCOnU.js} +1 -1
- package/lib/cjs/chunks/{draft-data-6zW9mu28.js → draft-data-F0V4PcIs.js} +1 -1
- package/lib/cjs/chunks/{home-DryEAaN4.js → home-BCFoaIEZ.js} +3 -3
- package/lib/cjs/chunks/{publish-button-oe4N0mbK.js → publish-button-Bbd4z1_d.js} +1 -1
- package/lib/cjs/chunks/site-state-CeQEnrvX.js +57 -0
- package/lib/cjs/chunks/state-UwRWAZRe.js +1 -0
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/project-html.js +3 -3
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +2 -2
- package/lib/cjs/site-state.js +1 -1
- package/lib/cjs/theme.js +1 -1
- package/lib/es/add-component.js +3 -3
- package/lib/es/chunks/{array-D34Qpnhk.js → array-DM0x2Sjw.js} +1 -1
- package/lib/es/chunks/{config-string-DgK7ETCs.js → config-string-Dw6sJMn_.js} +1 -1
- package/lib/es/chunks/{draft-data-B5kzDvTI.js → draft-data-sTSk4UTm.js} +1 -1
- package/lib/es/chunks/{home-DZ0sRPEQ.js → home-ClxOpmCx.js} +4 -4
- package/lib/es/chunks/{publish-button-Ctl_bvtq.js → publish-button-CKXdANG9.js} +3 -3
- package/lib/es/chunks/{site-state-YSH6XJUc.js → site-state-BeEHvakk.js} +408 -397
- package/lib/es/chunks/{state-BzwEX9VC.js → state-COB6reM7.js} +98 -103
- package/lib/es/components.js +1 -1
- package/lib/es/home.js +3 -3
- package/lib/es/project-html.js +70 -70
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +1152 -888
- package/lib/es/site-state.js +1 -1
- package/lib/es/theme.js +14 -11
- package/package.json +7 -7
- package/lib/cjs/chunks/site-state-B8sLWiY2.js +0 -57
- package/lib/cjs/chunks/state-BWuBNdK8.js +0 -1
package/lib/cjs/setting.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),R=require("./chunks/state-BWuBNdK8.js"),Ve=require("@arcblock/ux/lib/Empty"),_=require("@arcblock/ux/lib/Locale/context"),oe=require("@blocklet/code-editor"),De=require("@mui/icons-material/AddRounded"),Ee=require("@mui/icons-material/ArrowDownward"),ze=require("@mui/icons-material/ArrowUpward"),Ae=require("@mui/icons-material/DeleteOutline"),r=require("@mui/material"),Ne=require("lodash/sortBy"),C=require("react"),ke=require("react-use"),ye=require("@blocklet/pages-kit/builtin/color-picker"),qe=require("./chunks/config-string-BYZ5HfyY.js"),Fe=require("lodash/isEmpty"),Ue=require("lodash/set"),Me=require("yaml"),z=require("@blocklet/pages-kit/builtin/uploader"),We=require("lodash/cloneDeep"),Ke=require("@arcblock/ux/lib/Toast"),Q=require("@blocklet/pages-kit/components"),Le=require("@blocklet/pages-kit/utils/property"),Se=require("@mui/base"),V=require("@mui/icons-material"),Y=require("@syncedstore/core"),Pe=require("ahooks"),Je=require("lodash/assign"),He=require("lodash/get"),Ye=require("lodash/has"),$e=require("lodash/isEqual"),Ge=require("lodash/isNil"),Qe=require("lodash/isObject"),Xe=require("lodash/keyBy"),Ze=require("lodash/omit"),et=require("lodash/pick"),tt=require("lodash/reduce"),A=require("material-ui-popup-state/hooks"),rt=require("react-error-boundary"),st=require("@emotion/css"),te=require("react-dnd"),T=e=>e&&e.__esModule?e:{default:e};function lt(e){if(e&&e.__esModule)return e;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const l in e)if(l!=="default"){const i=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(s,l,i.get?i:{enumerable:!0,get:()=>e[l]})}}return s.default=e,Object.freeze(s)}const Z=T(Ve),it=T(De),ot=T(Ee),nt=T(ze),ct=T(Ae),D=T(Ne),ne=T(Fe),we=T(Ue),re=lt(Me),at=T(We),se=T(Ke),ut=T(Je),dt=T(He),pt=T(Ye),xt=T($e),X=T(Ge),mt=T(Qe),ft=T(Xe),jt=T(Ze),bt=T(et),ht=T(tt);function yt({onClick:e,disabled:s,sx:l,...i}){return t.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:e,...i,children:t.jsx(ct.default,{fontSize:"small"})})}function gt({onClick:e,disabled:s,sx:l,...i}){return t.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:e,...i,children:t.jsx(nt.default,{fontSize:"small"})})}function vt({onClick:e,disabled:s,sx:l,...i}){return t.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:e,...i,children:t.jsx(ot.default,{fontSize:"small"})})}function kt({label:e,value:s,onChange:l,disabled:i=!1,itemLabel:x="",emptyHeight:b=40,property:d,renderItem:v,...S}){const{t:h,locale:y}=_.useLocaleContext(),g=ke.useUpdate(),o=C.useCallback(f=>{l(R.transformValue(f,d.type))},[l,d.type]),c=C.useMemo(()=>Array.isArray(s)?s:[],[s]),n=C.useCallback(()=>{const f=[...c,""];o(f),g()},[c,o,g]),u=C.useCallback(()=>{if(!d||!d.subProperties)return n();const f={};D.default(Object.values(d.subProperties),"index").forEach(({data:B})=>{var N,q;if(!B.key)return;const E=((q=(N=B.locales)==null?void 0:N[y])==null?void 0:q.defaultValue)??"";f[B.key]=E});const O=[...c,f];o(O),g()},[c,o,g,d,y,n]),j=C.useCallback(f=>{try{const w=JSON.parse(f);Array.isArray(w)?o(w):console.error("JSON解析结果不是数组")}catch(w){console.error("JSON解析错误:",w)}},[o]),k=C.useCallback(f=>{const w=c.filter((O,B)=>B!==f);o(w),g()},[c,o,g]),a=C.useCallback(f=>{if(f<=0)return;const w=[...c],O=w[f];w[f]=w[f-1],w[f-1]=O,o(w),g()},[c,o,g]),m=C.useCallback(f=>{if(f>=c.length-1)return;const w=[...c],O=w[f];w[f]=w[f+1],w[f+1]=O,o(w),g()},[c,o,g]),p=C.useCallback((f,w)=>{const O=[...c];O[f]=w,o(O)},[c,o]),P=d&&d.subProperties&&Object.keys(d.subProperties).length>0,I=C.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:f})=>t.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:f+1})},{field:"content",headerName:"",renderCell:({row:f,index:w})=>v&&P?v({item:f,index:w,property:d,onChange:O=>p(w,O)}):t.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:i,value:f,placeholder:x||`${h("item")} ${w+1}`,onChange:O=>p(w,O.target.value),...S})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:f})=>t.jsxs(r.Stack,{direction:"column",spacing:.25,children:[t.jsx(gt,{disabled:i||f===0,onClick:()=>a(f)}),t.jsx(vt,{disabled:i||f===c.length-1,onClick:()=>m(f)}),t.jsx(yt,{disabled:i,onClick:()=>k(f)})]})}],[v,P,d,p,x,h,i,S,k,a,m,c.length]);return P?t.jsxs(r.Stack,{width:"100%",gap:1,children:[e&&t.jsx(r.FormLabel,{children:e}),c.length>0?t.jsx(r.TableContainer,{component:r.Paper,variant:"outlined",sx:{borderRadius:1,mb:1},children:t.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:[t.jsx(r.TableHead,{sx:{display:"none"},children:t.jsx(r.TableRow,{children:I.map(f=>t.jsx(r.TableCell,{width:f.width,align:f.align||"left",sx:{fontWeight:"bold"},children:f.renderHeader?f.renderHeader():f.headerName},f.field))})}),t.jsx(r.TableBody,{children:c.map((f,w,O)=>t.jsx(r.TableRow,{sx:{borderBottom:w<O.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:I.map(B=>t.jsx(r.TableCell,{width:B.width,align:B.align||"left",sx:{borderBottom:"none"},children:B.renderCell({row:f,index:w,onChange:E=>p(w,E)})},`${w}-${B.field}`))},w))})]})}):t.jsx(Z.default,{style:{fontSize:12,height:b},children:h("maker.properties.arrayEmpty")}),t.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:i,startIcon:t.jsx(it.default,{}),onClick:u,children:h("maker.properties.addArrayItem")})]}):t.jsxs(r.Stack,{width:"100%",gap:1,children:[e&&t.jsx(r.FormLabel,{children:e}),t.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,minHeight:150},children:t.jsx(oe.CodeEditor,{keyId:d.id,locale:y,language:"json",value:JSON.stringify(c,null,2),onChange:f=>j(f||""),fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},d.id)})]})}function St({value:e,onChange:s,...l}){const i=C.useRef(null);return t.jsxs(t.Fragment,{children:[t.jsx(qe.ConfigString,{...l,value:e,onChange:s,InputProps:{endAdornment:t.jsx(r.InputAdornment,{position:"end",children:t.jsx(ye.ColorItem,{color:e??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{var x;(x=i.current)==null||x.open({value:e??""})}})})}}),t.jsx(ye.ConfigColorDialog,{ref:i,onSave:({value:x},b)=>{s(x),b()}})]})}function Pt({label:e,value:s,onChange:l,property:i,component:x,defaultLocale:b,allComponents:d,PropertyValueField:v,onUpload:S}){const{locale:h}=_.useLocaleContext(),y=C.useRef(null);if(!ne.default(i.subProperties)){const o=D.default(Object.values(i.subProperties||{}),"index").filter(c=>c.data.visible!==!1&&c.data.key);return t.jsxs(r.Stack,{width:"100%",children:[t.jsx(r.FormLabel,{sx:{px:.25,py:.5},children:e}),t.jsx(r.Box,{children:t.jsx(r.Box,{sx:{position:"relative"},children:o.map((c,n)=>{const{data:u}=c,j=u.key??u.id,k=n===o.length-1;let a=null;try{s&&typeof s=="object"?a=s[j]:typeof s=="string"&&(a=(i.type==="yaml"?re.parse(s||""):JSON.parse(s||"{}"))[j])}catch{}a==null&&(u.locales&&h&&u.locales[h]?a=u.locales[h].defaultValue:u.locales&&b&&u.locales[b]&&(a=u.locales[b].defaultValue));const m=P=>{try{let I={};if(typeof s=="string")try{I=i.type==="yaml"?re.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(I={...s});we.default(I,j,P);const f=R.transformValue(I,i.type);l==null||l(f)}catch(I){console.error("Error updating property:",I)}},p=8;return t.jsxs(r.Box,{sx:{mb:k?0:1,display:"flex",flexDirection:"row"},children:[t.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[t.jsx(r.Box,{sx:{position:"absolute",left:p,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),t.jsx(r.Box,{sx:{position:"absolute",left:p,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!k&&t.jsx(r.Box,{sx:{position:"absolute",left:p,top:16,bottom:-8,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),t.jsx(r.Box,{sx:{flexGrow:1},children:t.jsx(v,{component:x,property:u,value:a,onChange:m,size:"small",fullWidth:!0,defaultLocale:b,allComponents:d})})]},u.id)})})})]})}return t.jsx(r.Stack,{width:"100%",gap:2,children:t.jsxs(r.Stack,{sx:{width:"100%",position:"relative",pt:1,pb:"6px",px:"1px",minHeight:50,".monaco-editor,.overflow-guard":{borderRadius:1}},children:[t.jsx(r.FormLabel,{sx:{position:"absolute",left:0,top:0,transform:"translate(0px, -7px) scale(0.75)"},children:e}),t.jsx(oe.CodeEditor,{keyId:i.id,locale:h,language:i.type==="yaml"?"yaml":"json",value:typeof s=="string"?s:"",onChange:o=>{l==null||l(o)},onUpload:o=>{y.current=o,S&&S(o)},fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},i.id),t.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:t.jsx(r.Box,{component:"legend",sx:{fontSize:"0.75em"},children:t.jsx(r.Box,{component:"span",sx:{opacity:0},children:e})})})]})})}const wt=["string","multiline","json","yaml","url","component","custom","array"];function ge(e){return e.type?!wt.includes(e.type):!1}function Ie({disabled:e,list:s,renderItem:l,...i}){const x=C.useRef(null),b=C.useId(),d=Pe.useUpdate(),v=D.default(Object.entries(s),c=>c[1].index).map(c=>c[0]),S=C.useRef(v),h=C.useCallback(c=>{S.current=c,d()},[d]),y=C.useCallback(({index:c},{index:n})=>{const u=[...S.current];u.splice(n,0,...u.splice(c,1)),h(u)},[h]);C.useEffect(()=>{h(v)},[v.join("-")]);const[{isOver:g},o]=te.useDrop({accept:b,collect:c=>({isOver:c.isOver()}),canDrop:()=>!e,drop:()=>{var u;const c=()=>{S.current.forEach((j,k)=>{const a=s[j];a&&(a.index=k)})},n=(u=Y.getYjsValue(s))==null?void 0:u.doc;n?n.transact(()=>{c()}):c()}});return C.useEffect(()=>{g||h(v)},[g]),o(x),t.jsx(r.Box,{...i,ref:x,className:st.cx(g&&"isDragging"),children:S.current.map((c,n)=>t.jsx(It,{type:b,disabled:e,id:c,index:n,itemIndex:u=>S.current.indexOf(u),move:y,children:u=>{const j=s[c];return j?l(j.data,n,u):null}},c))})}function It({disabled:e,id:s,index:l,type:i,children:x,itemIndex:b,move:d}){const v=C.useRef(),[{isDragging:S},h,y]=te.useDrag({type:i,item:()=>({id:s}),canDrag:()=>!e,collect:o=>({isDragging:o.isDragging()})}),[,g]=te.useDrop({accept:i,canDrop:()=>!e,hover(o,c){var p;if(!v.current)return;const n=b(o.id),u=l;if(n===u)return;const j=(p=v.current)==null?void 0:p.getBoundingClientRect(),k=(j.bottom-j.top)/2,m=c.getClientOffset().y-j.top;n<u&&m<k||n>u&&m>k||d({id:o.id,index:n},{id:s,index:l})}});return typeof x=="function"?x({isDragging:S,drag:h,drop:o=>(v.current=o,g(o)),preview:y}):(h(g(y(v))),t.jsx(r.Box,{ref:v,children:x}))}function Ct({drop:e,preview:s,drag:l,disabled:i,isDragging:x,children:b,onDelete:d,onVisibilityChange:v,visible:S=!0,actions:h,alwaysShowActions:y=!1}){const{t:g}=_.useLocaleContext();return t.jsx(r.Box,{ref:e,sx:{":hover .hover-visible":{maxWidth:"100%"},opacity:S?1:.5},children:t.jsxs(r.Box,{sx:{position:"relative"},children:[t.jsx(r.Box,{ref:s,sx:{flex:1,borderRadius:.5,bgcolor:x?"action.hover":"background.paper",opacity:.9999},children:b}),!i&&t.jsx(r.Box,{className:y?"":"hover-visible",sx:{maxWidth:y?"100%":0,overflow:"hidden",position:"absolute",right:2,top:2,transition:"max-width 0.3s ease-in-out"},children:t.jsxs(r.Stack,{direction:"row",sx:{bgcolor:o=>r.alpha(o.palette.grey[200],.9),borderRadius:1,p:.5,[`.${r.buttonClasses.root}`]:{minWidth:24,width:24,height:24,p:0}},children:[h,v&&t.jsx(r.Tooltip,{title:g(S?"hideParameter":"showParameter"),disableInteractive:!0,placement:"top",children:t.jsx(r.Button,{onClick:()=>v(!S),children:S?t.jsx(V.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):t.jsx(V.VisibilityRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),d&&t.jsx(r.Tooltip,{title:g("delete"),disableInteractive:!0,placement:"top",children:t.jsx(r.Button,{onClick:d,children:t.jsx(V.DeleteOutlineRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),t.jsx(r.Tooltip,{title:g("dragSort"),disableInteractive:!0,placement:"top",children:t.jsx(r.Button,{ref:l,children:t.jsx(V.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function Ot({label:e,value:s,onChange:l}){const[i,x]=C.useState(!1);return t.jsxs(r.Stack,{gap:1,children:[t.jsx(r.TextField,{label:e,size:"small",value:s,onChange:b=>l==null?void 0:l(b.target.value),InputProps:{endAdornment:t.jsx(z.UploaderButton,{onChange:({response:b})=>{var v;const d=(v=b==null?void 0:b.data)==null?void 0:v.filename;d&&(l==null||l(d))}})}}),s&&t.jsx(r.Box,{component:"img",sx:{objectFit:"contain",borderRadius:1,cursor:"pointer"},src:R.getImageAbsoluteUrl(s),alt:e,maxWidth:100,maxHeight:100,width:"100%",onClick:()=>x(!0)}),t.jsx(r.Dialog,{open:i,onClose:()=>x(!1),children:t.jsx(r.Box,{component:"img",sx:{objectFit:"contain"},src:R.getImageAbsoluteUrl(s),alt:e})})]})}function le(e,s=""){return ht.default(e,(l,i,x)=>{const b=s?`${s}.${x}`:x;return mt.default(i)?ut.default(l,le(i,b)):l[b]=i,l},{})}const Tt=[{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 G(e,s,l){return!e||!l?!1:Object.values(e).some(({data:i})=>i.id!==s&&i.key===l)}function ie(e,s){var l;return!e||!s?!1:((l=e[s])==null?void 0:l.data.visible)??!0}function Bt({componentId:e}){const{state:{components:s}}=R.useStore(),l=s[e],i=l==null?void 0:l.data;return i?t.jsx(r.Stack,{maxHeight:"100%",overflow:"auto",children:t.jsx(r.Box,{p:2,children:t.jsx(rt.ErrorBoundary,{FallbackComponent:R.ErrorView,resetKeys:[e],children:t.jsx(Rt,{value:i,componentId:e})})})}):null}function Rt({value:e,componentId:s}){var g,o,c;const{t:l}=_.useLocaleContext(),{localState:{currentLocale:i,customComponentPreviewerProperties:x},state:{config:{defaultLocale:b}},localActions:{setCustomComponentPreviewerProperties:d}}=R.useStore(),v=Y.getYjsValue(e).doc,S=R.useAllComponents(),h=C.useMemo(()=>(x==null?void 0:x[s])??{},[s,x]),y=Pe.useReactive({componentId:s,propertiesValue:{...h}});return C.useEffect(()=>{y.componentId!==s&&(y.componentId=s,y.propertiesValue={...h})},[s,h,y]),C.useEffect(()=>{if(y.componentId!==s)return;const n=Object.fromEntries(Object.values(e.properties??{}).map(({data:u})=>{var j,k,a,m,p;return[u.id,{value:((j=y.propertiesValue[u.id])==null?void 0:j.value)??Le.parsePropertyValue(u,((a=(k=u.locales)==null?void 0:k[i])==null?void 0:a.defaultValue)??((p=(m=u.locales)==null?void 0:m[b])==null?void 0:p.defaultValue),{locale:i,defaultLocale:b})}]}));d(s,n)},[JSON.stringify(y.propertiesValue),s,y.componentId]),t.jsx(r.Stack,{height:"100%",children:t.jsxs(r.Stack,{gap:2,children:[t.jsx(Ce,{config:e}),t.jsx(Te,{config:e,currentLocale:i,defaultLocale:b,allComponents:S,onUpdateConfig:n=>{v.transact(()=>{n(e)})}}),t.jsxs(r.Stack,{gap:2,direction:"row",justifyContent:"space-between",alignItems:"center",children:[t.jsx(r.Typography,{variant:"subtitle1",children:l("renderer")}),t.jsxs(r.TextField,{hiddenLabel:!0,size:"small",select:!0,SelectProps:{autoWidth:!0},value:((g=e.renderer)==null?void 0:g.type)||"react-component",onChange:n=>{v.transact(()=>{const u=n.target.value;e.renderer??(e.renderer={type:u}),e.renderer.type=u})},children:[t.jsx(r.MenuItem,{value:"react-component",children:"React Component"}),t.jsx(r.MenuItem,{value:"component",children:"Custom Component"})]})]}),((o=e.renderer)==null?void 0:o.type)==="component"&&t.jsx(Nt,{value:e}),((c=e.renderer)==null?void 0:c.type)==="react-component"&&t.jsx(At,{value:e}),t.jsx(ce,{config:e,currentLocale:i,defaultLocale:b,allComponents:S,propertiesValue:y.propertiesValue,onChange:({value:n,id:u,path:j})=>{const k=[...j,"data"];if(!dt.default(e,k)){se.default.warning(l("cannotFindPropertyKey",{key:k.join(".")}));return}y.propertiesValue[u]={value:n.value}}})]})})}function Ce({config:e}){const{t:s}=_.useLocaleContext();return t.jsx(z.UploaderProvider,{children:t.jsxs(r.Stack,{gap:2,children:[t.jsx(r.Typography,{variant:"subtitle1",children:s("basicInfo")}),t.jsx(r.TextField,{label:s("name"),size:"small",value:e.name||"",onChange:l=>e.name=l.target.value}),t.jsx(r.TextField,{label:s("description"),size:"small",multiline:!0,minRows:2,maxRows:10,inputProps:{maxLength:200},value:e.description||"",onChange:l=>e.description=l.target.value}),t.jsx(r.Autocomplete,{size:"small",options:[],multiple:!0,freeSolo:!0,value:e.tags??[],onChange:(l,i)=>e.tags=i,renderInput:l=>t.jsx(r.TextField,{label:s("tags"),...l})}),t.jsx(Ot,{label:s("previewImage"),value:e.previewImage||"",onChange:l=>e.previewImage=l})]})})}function Oe({data:e,params:s,visible:l,config:i,currentLocale:x,defaultLocale:b,allComponents:d,onUpdateConfig:v}){var y,g,o,c,n,u;const{t:S}=_.useLocaleContext(),h=C.useMemo(()=>e.type==="json"||e.type==="yaml"||e.type==="array"?Et:U,[e.type]);return t.jsx(Ct,{preview:s.preview,drop:s.drop,drag:s.drag,isDragging:s.isDragging,onDelete:()=>{v(j=>{if(j.properties){const a=Object.entries(j.properties).sort(([,p],[,P])=>p.index-P.index);delete j.properties[e.id],a.filter(([p])=>p!==e.id).forEach(([,p],P)=>{p.index=P})}})},visible:l,onVisibilityChange:j=>{v(k=>{const a=k.properties[e.id].data;a.visible=j})},alwaysShowActions:!0,children:t.jsxs(r.Stack,{direction:"column",gap:2,children:[t.jsx(r.TextField,{label:S("key"),size:"small",required:!0,sx:{width:"calc(100% - 80px - 8px)",flex:1,"& .MuiOutlinedInput-root":{borderColor:e.key?G(i.properties,e.id,e.key)?"warning.main":void 0:"error.main"},"& .MuiFormLabel-root":{color:e.key?G(i.properties,e.id,e.key)?"warning.main":"text.secondary":"error.main"},"& .MuiFormLabel-root.Mui-focused":{color:e.key?G(i.properties,e.id,e.key)?"warning.main":"primary.main":"error.main"}},value:e.key||"",onChange:j=>{v(k=>{const a=k.properties[e.id].data;a.key=j.target.value.trim()})},InputProps:{endAdornment:!e.key||e.key&&G(i.properties,e.id,e.key)?t.jsx(r.InputAdornment,{position:"end",sx:{width:16,ml:0},children:t.jsx(r.Tooltip,{title:e.key?S("duplicateKey"):S("requiredKey"),children:t.jsx(V.InfoRounded,{sx:{color:e.key?"warning.main":"error.main",fontSize:16}})})}):null}}),t.jsxs(r.Stack,{direction:"row",gap:1,children:[t.jsx(r.TextField,{label:S("label"),size:"small",sx:{flex:1},value:(((g=(y=e.locales)==null?void 0:y[x])==null?void 0:g.name)??((c=(o=e.locales)==null?void 0:o[b])==null?void 0:c.name))||"",onChange:j=>{v(k=>{var m;const a=k.properties[e.id].data;a.locales??(a.locales={}),(m=a.locales)[x]??(m[x]={}),a.locales[x].name=j.target.value})}}),t.jsx(r.TextField,{label:S("type"),size:"small",select:!0,sx:{flex:1},value:e.type==="string"&&e.multiline?"multiline":e.type||"string",onChange:j=>{v(k=>{const a=k.properties[e.id].data;if(a.locales)for(const p of Object.keys(a.locales))a.locales[p].defaultValue=void 0;const m=j.target.value;m==="multiline"?(a.type="string",a.multiline=!0):(typeof a.multiline<"u"&&delete a.multiline,a.type=m)})},children:Tt.map(j=>t.jsx(r.MenuItem,{value:j.value,children:j.label},j.value))})]}),t.jsxs(r.Stack,{direction:"row",gap:1,children:[t.jsx(h,{allComponents:d,defaultLocale:b,component:i,property:e,label:S("defaultValue"),size:"small",fullWidth:!0,value:(u=(n=e.locales)==null?void 0:n[x])==null?void 0:u.defaultValue,onChange:(j,k)=>{v(a=>{var p;const m=a.properties[e.id].data;if(k!=null&&k.forceUpdateProperty){const P=le(m),I=le(j);Object.keys(I).forEach(f=>{P[f]||we.default(m,f,I[f])})}else m.locales??(m.locales={}),(p=m.locales)[x]??(p[x]={}),m.locales[x].defaultValue=j})}}),e.type==="custom"?t.jsx(r.Box,{children:t.jsx(Vt,{property:e,allComponents:d})}):null]})]})})}function _t(e,s){const[l,i]=C.useState(0);return C.useEffect(()=>{const b=setTimeout(()=>{if(e.current){let d=e.current.parentElement,v=0;for(;d;)d.classList.contains("property-container")&&v++,d=d.parentElement;i(v)}},100);return()=>clearTimeout(b)},[e,s]),l}function Te({config:e,currentLocale:s,defaultLocale:l,allComponents:i,onUpdateConfig:x,useI18nEditor:b=!0}){const{t:d}=_.useLocaleContext(),v=A.usePopupState({variant:"dialog"}),S=e.properties&&D.default(Object.values(e.properties),"index");return t.jsx(z.UploaderProvider,{children:t.jsxs(r.Stack,{gap:2,children:[t.jsxs(r.Stack,{direction:"row",gap:1,alignItems:"center",justifyContent:"space-between",children:[t.jsx(r.Typography,{variant:"subtitle1",children:d("properties")}),t.jsx(r.Box,{flex:1}),b&&t.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...A.bindTrigger(v),children:t.jsx(V.TranslateRounded,{fontSize:"small"})})]}),e.properties&&Object.keys(e.properties).length>0?t.jsx(Ie,{component:r.Stack,gap:2,list:e.properties,renderItem:(h,y,g)=>{const o=ie(e.properties,h.id);return t.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:o?"1px solid":"1px dashed",borderColor:"divider"},children:t.jsx(r.Stack,{gap:2,children:t.jsx(Oe,{data:h,params:g,visible:o,config:e,currentLocale:s,defaultLocale:l,allComponents:i,onUpdateConfig:x})})},h.id)}}):t.jsx(Z.default,{style:{fontSize:12},children:d("maker.properties.noProperties")}),t.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",onClick:()=>{x(h=>{var g;const y=R.nextId();h.properties??(h.properties={}),(g=h.properties)[y]??(g[y]={index:(S==null?void 0:S.length)||0,data:{id:y}})})},startIcon:t.jsx(V.AddRounded,{}),children:d("addObject",{object:d("property")})}),b&&t.jsx(Be,{...A.bindDialog(v),component:e})]})})}function Vt({property:e,allComponents:s}){const l=A.usePopupState({variant:"popper"});return t.jsxs(t.Fragment,{children:[t.jsx(r.Button,{sx:{minWidth:0},...A.bindTrigger(l),children:t.jsx(V.SettingsRounded,{fontSize:"small"})}),t.jsx(r.Popper,{...A.bindPopper(l),children:t.jsx(Se.ClickAwayListener,{onClickAway:l.close,children:t.jsx(r.Paper,{children:t.jsx(r.Box,{width:500,p:2,children:t.jsx(ee,{value:e.componentId,onChange:(i,x)=>e.componentId=x,allComponents:s})})})})})]})}function Dt({value:e,valueImmutable:s,onChange:l,defaultLocale:i,allComponents:x}){var y;const[b,d]=C.useState(!1),{t:v,locale:S}=_.useLocaleContext(),h=typeof(e==null?void 0:e.componentId)=="string"?(y=x[e.componentId])==null?void 0:y.data:void 0;return h?t.jsxs(r.Box,{sx:{width:"100%",position:"relative"},children:[t.jsx(r.IconButton,{sx:{minWidth:0},disabled:!h,size:"small",onClick:()=>d(!b),color:b?"primary":"default",children:t.jsx(V.SettingsRounded,{fontSize:"small"})}),b&&t.jsx(r.Collapse,{in:b,timeout:"auto",unmountOnExit:!0,sx:{width:"100%",zIndex:10},children:t.jsxs(r.Paper,{elevation:1,sx:{mt:1,p:2,borderRadius:1,border:"1px solid",borderColor:"divider",width:"100%"},children:[t.jsx(r.Box,{width:"100%",mb:2,children:t.jsx(ce,{config:h,currentLocale:S,defaultLocale:i,allComponents:x,propertiesValue:e==null?void 0:e.properties,onChange:({id:g,value:o})=>{const c=at.default(o.value),n=JSON.parse(JSON.stringify(e));n!=null&&n.componentId&&(s?l==null||l({...n,properties:{...n.properties,[g]:{value:c}}}):(n.properties=n.properties??{},n.properties[g]={value:c},l==null||l(n)))}})}),t.jsx(r.Button,{size:"small",onClick:()=>d(!1),sx:{mt:1},children:v("close")})]})})]}):null}function Be({type:e="properties",component:s,...l}){var g,o,c;const{t:i}=_.useLocaleContext(),{state:{components:x,supportedLocales:b,config:{defaultLocale:d}}}=R.useStore(),v=R.useAllComponents(),S=Y.getYjsValue(s).doc,h=e==="properties"?s.properties:e==="parameters"&&((g=s.renderer)==null?void 0:g.type)==="component"?(o=x[s.renderer.componentId])==null?void 0:o.data.properties:void 0,y=((c=s.renderer)==null?void 0:c.type)==="component"?s:void 0;return t.jsxs(r.Dialog,{...l,fullWidth:!0,maxWidth:"lg",children:[t.jsx(r.DialogTitle,{children:i("i18nEditorTitle")}),t.jsx(r.DialogContent,{children:h&&t.jsx(r.Stack,{children:t.jsxs(r.Table,{stickyHeader:!0,sx:{td:{verticalAlign:"top"}},children:[t.jsx(r.TableHead,{children:t.jsx(r.TableRow,{children:b.map(({locale:n,name:u})=>t.jsx(r.TableCell,{children:t.jsxs(r.Typography,{color:"text.primary",children:[u,d===n&&t.jsx(V.StarRounded,{sx:{fontSize:12}})]})},n))})}),t.jsx(r.TableBody,{children:D.default(Object.values(h),"index").map(({data:n})=>t.jsx(r.TableRow,{children:b.map(({locale:u})=>{var j,k,a,m,p,P,I,f,w,O,B,E,N,q,$,W,K,L,J,H,ae,ue,de,pe,xe,me;return t.jsx(r.TableCell,{children:t.jsx(r.Stack,{gap:1,children:e==="properties"?t.jsxs(t.Fragment,{children:[t.jsx(r.TextField,{size:"small",label:"Key",value:n.key||"",onChange:M=>{S.transact(()=>{n.key=M.target.value.trim()})}}),t.jsx(r.TextField,{size:"small",label:i("label"),value:(((k=(j=n.locales)==null?void 0:j[u])==null?void 0:k.name)??((m=(a=n.locales)==null?void 0:a[d])==null?void 0:m.name))||"",onChange:M=>{S.transact(()=>{var F;n.locales??(n.locales={}),(F=n.locales)[u]??(F[u]={}),n.locales[u].name=M.target.value})}}),t.jsx(r.Box,{children:t.jsx(U,{allComponents:v,defaultLocale:d,component:s,property:n,size:"small",fullWidth:!0,label:"Default Value",valueImmutable:X.default((P=(p=n.locales)==null?void 0:p[u])==null?void 0:P.defaultValue),value:((f=(I=n.locales)==null?void 0:I[u])==null?void 0:f.defaultValue)??((O=(w=n.locales)==null?void 0:w[d])==null?void 0:O.defaultValue),onChange:M=>{S.transact(()=>{var F;n.locales??(n.locales={}),(F=n.locales)[u]??(F[u]={}),n.locales[u].defaultValue=M})}})})]}):e==="parameters"&&y?t.jsx(r.Box,{children:t.jsx(U,{allComponents:v,defaultLocale:d,component:s,property:n,size:"small",fullWidth:!0,valueImmutable:X.default((q=(N=(E=(B=y.renderer.properties)==null?void 0:B[n.id])==null?void 0:E.locales)==null?void 0:N[u])==null?void 0:q.value),value:((L=(K=(W=($=y.renderer.properties)==null?void 0:$[n.id])==null?void 0:W.locales)==null?void 0:K[u])==null?void 0:L.value)??((ue=(ae=(H=(J=y.renderer.properties)==null?void 0:J[n.id])==null?void 0:H.locales)==null?void 0:ae[d])==null?void 0:ue.value)??((pe=(de=n.locales)==null?void 0:de[u])==null?void 0:pe.defaultValue)??((me=(xe=n.locales)==null?void 0:xe[d])==null?void 0:me.defaultValue),onChange:M=>{S.transact(()=>{var F,fe,je,be,he;(F=y.renderer).properties??(F.properties={}),(fe=y.renderer.properties)[je=n.id]??(fe[je]={}),(be=y.renderer.properties[n.id]).locales??(be.locales={}),(he=y.renderer.properties[n.id].locales)[u]??(he[u]={}),y.renderer.properties[n.id].locales[u].value=M})}})}):null},n.id)},u)})},n.id))})]})})}),t.jsx(r.DialogActions,{children:t.jsx(r.Button,{onClick:n=>{var u;return(u=l.onClose)==null?void 0:u.call(l,n,"escapeKeyDown")},children:i("close")})})]})}const ve=(e,s)=>l=>{const i=[l.palette.info.main,l.palette.primary.main,l.palette.secondary.main,l.palette.success.main,l.palette.warning.main],x=Math.min(i.length-1,e),b=i[x],d=r.alpha(b,.5),v=r.alpha(b,1);return{borderColor:`${d} !important`,borderLeft:"3px solid !important",borderLeftColor:d,color:v,...s}};function Et({property:e,onChange:s,defaultLocale:l,allComponents:i}){const{t:x,locale:b}=_.useLocaleContext(),d=C.useRef(null),v=_t(d,e),S=C.useCallback(()=>{if(!(e.type!=="json"&&e.type!=="yaml"&&e.type!=="array")&&e.subProperties)try{let h={};D.default(Object.values(e.subProperties),"index").filter(o=>o.data.visible!==!1&&o.data.key).forEach(({data:o})=>{var n,u,j,k;if(!o.key)return;let c=((u=(n=o.locales)==null?void 0:n[b])==null?void 0:u.defaultValue)??((k=(j=o.locales)==null?void 0:j[l])==null?void 0:k.defaultValue);if(o.type==="number")c=Number(c);else if(o.type==="boolean")c=c===!0||c==="true";else if((o.type==="json"||o.type==="yaml")&&typeof c=="string")try{o.type==="json"?c=JSON.parse(c):c=re.parse(c)}catch(a){console.error("Error parsing nested value",c,a),c={}}h[o.key]=c}),e.type==="array"&&!Array.isArray(h)&&(h=ne.default(h)?[]:[h]);const g=R.transformValue(h,e.type);s==null||s(g)}catch(h){console.error("Error converting structure to text:",h)}},[e,b,l,s]);return e.type!=="json"&&e.type!=="yaml"&&e.type!=="array"?null:t.jsxs(r.Stack,{direction:"column",gap:1.5,sx:{width:"100%"},ref:d,children:[t.jsx(r.Divider,{sx:{mt:-1},children:t.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:x("maker.properties.subProperties")})}),e.subProperties&&Object.keys(e.subProperties).length>0?t.jsx(Ie,{component:r.Stack,gap:2,list:e.subProperties,renderItem:(h,y,g)=>{const o=h.visible!==!1;return t.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:o?"1px solid":"1px dashed","&":ve(v)},children:t.jsx(r.Stack,{gap:2,children:t.jsx(Oe,{data:h,params:g,visible:o,config:{properties:e.subProperties},currentLocale:b,defaultLocale:l,allComponents:i,onUpdateConfig:c=>{try{const n={properties:e.subProperties||{}};c(n);const u={...e,subProperties:n.properties};s==null||s(u,{forceUpdateProperty:!0}),S()}catch(n){console.error("Error updating property:",n)}}})})},h.id)}}):t.jsx(Z.default,{style:{fontSize:12,height:100},children:x("maker.properties.noSubProperties")}),t.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",size:"small",startIcon:t.jsx(V.AddRounded,{}),onClick:()=>{try{const h=e.subProperties||{},y=R.nextId(),o={index:Object.values(h).length,data:{id:y,key:"",type:"string",visible:!0,locales:{[b]:{name:"",defaultValue:""}},subProperties:{}}},c={...e,subProperties:{...h,[y]:o}};s==null||s(c,{forceUpdateProperty:!0}),S()}catch(h){console.error("Error adding property:",h)}},sx:{"&":ve(v,{})},children:x("maker.properties.addSubProperty")})]})}function U({component:e,property:s,value:l,onChange:i,valueImmutable:x,defaultLocale:b,allComponents:d,...v}){var c,n,u,j,k;const{locale:S}=_.useLocaleContext(),h=z.useUploader(),y=C.useRef(null),g=()=>{var m;const a=(m=h==null?void 0:h.current)==null?void 0:m.getUploader();a==null||a.open(),y.current&&a.onceUploadSuccess(({response:p})=>{var I,f;let P=((I=p==null?void 0:p.data)==null?void 0:I.filename)||"";P&&(P=`mediakit://${P}`,l&&!l.includes("mediakit://")&&(P+=" # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")),(f=y.current)==null||f.call(y,P)})},o=v.label??(((n=(c=s.locales)==null?void 0:c[S])==null?void 0:n.name)||((j=(u=s.locales)==null?void 0:u[b])==null?void 0:j.name)||s.key||s.id);if(s.type==="number")return t.jsx(zt,{...v,label:o,NumberProps:{value:["number","string"].includes(typeof l)?l:null,onChange:(a,m)=>i==null?void 0:i(m)}});if(s.type==="decimal")return t.jsx(r.TextField,{...v,label:o,type:"text",value:l??"",onChange:a=>{const m=a.target.value;if(m===""||m==="-"){i==null||i(m);return}if(/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(m)){let P=m;/^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(P)&&(P=Number(P)),i==null||i(P)}}});if(s.type==="boolean")return t.jsx(r.FormControlLabel,{label:o,labelPlacement:"start",control:t.jsx(r.Switch,{checked:l===!0,onChange:(a,m)=>i==null?void 0:i(m)})});if(s.type==="color")return t.jsx(St,{label:o,value:l,onChange:a=>{i==null||i(a)}});if(s.type==="json"||s.type==="yaml")return t.jsx(Pt,{label:o,value:l,onChange:a=>{i==null||i(a)},property:s,component:e,defaultLocale:b,allComponents:d,PropertyValueField:U,onUpload:a=>{y.current=a,g()}});if(s.type==="custom"){const a=(k=d[s.componentId])==null?void 0:k.data;return a?t.jsx(r.Box,{width:"100%",children:t.jsx(Q.CustomComponentRenderer,{componentId:a.id,props:{label:o,value:l,onChange:i},locale:S,dev:{mode:"draft",components:d,defaultLocale:b}})}):t.jsx(r.TextField,{...v,label:o,disabled:!0,placeholder:"Click right button select a component"})}if(s.type==="component")return t.jsxs(r.Stack,{width:"100%",direction:"column",gap:1,children:[t.jsx(ee,{allComponents:d,label:o,value:l==null?void 0:l.componentId,onChange:(a,m)=>{x||!l?i==null||i({...l&&JSON.parse(JSON.stringify(l)),componentId:m}):typeof l=="object"&&(l.componentId=m,i==null||i({...l&&JSON.parse(JSON.stringify(l)),componentId:m}))}}),(l==null?void 0:l.componentId)&&t.jsx(Dt,{value:l,valueImmutable:x,onChange:i,defaultLocale:b,allComponents:d})]});if(!s.type||["string","url","multiline"].includes(s.type)){let a=s.type==="string"?s.multiline:void 0;s.type==="multiline"&&(a=!0);const m=s.type==="url"?l==null?void 0:l.url:l;return t.jsx(r.TextField,{...v,label:o,value:typeof m=="string"?m:"",multiline:a,minRows:a?2:void 0,maxRows:a?10:void 0,onChange:p=>i==null?void 0:i(s.type==="url"?{...l,url:p.target.value,mediaKitUrl:p.target.value}:p.target.value),InputProps:s.type==="url"?{sx:{pr:0},endAdornment:t.jsxs(r.InputAdornment,{position:"end",children:[t.jsx(z.UploaderButton,{onChange:async({response:p})=>{var w,O,B;const P=((w=p==null?void 0:p.data)==null?void 0:w.url)||((O=p==null?void 0:p.data)==null?void 0:O.fileUrl);let I;P&&(I=await z.getImageSize(P).catch(()=>z.getVideoSize(P)).catch(()=>{}));let f=((B=p==null?void 0:p.data)==null?void 0:B.filename)||"";f&&(f=`mediakit://${f}`),i==null||i({url:P,mediaKitUrl:f,width:I==null?void 0:I.naturalWidth,height:I==null?void 0:I.naturalHeight})}}),t.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:t.jsx(V.InfoRounded,{sx:{cursor:"default",mr:1},fontSize:"small"})})]})}:void 0})}return s.type==="array"?t.jsx(kt,{label:o,value:Array.isArray(l)?l:[],onChange:a=>i==null?void 0:i(a),property:s,renderItem:({item:a,index:m,onChange:p})=>s.subProperties&&Object.keys(s.subProperties).length>0?t.jsx(r.Stack,{gap:1,width:"100%",children:D.default(Object.values(s.subProperties),"index").filter(P=>P.data.visible!==!1).map(({data:P})=>P.key?t.jsx(U,{component:e,property:P,value:a[P.key],onChange:I=>{const f={...a,[P.key]:I};p(f)},size:"small",fullWidth:!0,defaultLocale:b,allComponents:d},P.id):null)},m):t.jsx(r.TextField,{size:v.size,fullWidth:!0,value:a,onChange:P=>p(P.target.value)})}):(console.error("Unsupported property type",s.type),null)}function zt({NumberProps:e,...s}){const{getInputProps:l}=Se.unstable_useNumberInput(e),i=l();return t.jsx(r.TextField,{...s,inputProps:i})}const Re=`import React from '@blocklet/pages-kit/builtin/react'
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),_=require("./chunks/state-UwRWAZRe.js"),Ee=require("@arcblock/ux/lib/Empty"),N=require("@arcblock/ux/lib/Locale/context"),ne=require("@blocklet/code-editor"),De=require("@mui/icons-material/AddRounded"),Ve=require("@mui/icons-material/ArrowDownward"),ze=require("@mui/icons-material/ArrowUpward"),Ae=require("@mui/icons-material/DeleteOutline"),r=require("@mui/material"),Fe=require("lodash/sortBy"),T=require("react"),ve=require("react-use"),ye=require("@blocklet/pages-kit/builtin/color-picker"),qe=require("./chunks/config-string-CEipCOnU.js"),Ue=require("lodash/isEmpty"),Me=require("lodash/set"),We=require("yaml"),q=require("@blocklet/pages-kit/builtin/uploader"),Le=require("lodash/cloneDeep"),Ke=require("@arcblock/ux/lib/Toast"),X=require("@blocklet/pages-kit/components"),Je=require("@blocklet/pages-kit/utils/property"),Se=require("@mui/base"),D=require("@mui/icons-material"),G=require("@syncedstore/core"),Pe=require("ahooks"),He=require("lodash/assign"),Ye=require("lodash/get"),$e=require("lodash/has"),Ge=require("lodash/isEqual"),Qe=require("lodash/isNil"),Xe=require("lodash/isObject"),Ze=require("lodash/keyBy"),et=require("lodash/omit"),tt=require("lodash/pick"),rt=require("lodash/reduce"),U=require("material-ui-popup-state/hooks"),st=require("react-error-boundary"),it=require("@emotion/css"),re=require("react-dnd"),O=t=>t&&t.__esModule?t:{default:t};function lt(t){if(t&&t.__esModule)return t;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const l=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(s,i,l.get?l:{enumerable:!0,get:()=>t[i]})}}return s.default=t,Object.freeze(s)}const ee=O(Ee),ot=O(De),nt=O(Ve),ct=O(ze),at=O(Ae),V=O(Fe),W=O(Ue),we=O(Me),se=lt(We),ut=O(Le),ie=O(Ke),dt=O(He),pt=O(Ye),xt=O($e),mt=O(Ge),Z=O(Qe),ft=O(Xe),bt=O(Ze),ht=O(et),jt=O(tt),yt=O(rt);function gt({onClick:t,disabled:s,sx:i,...l}){return e.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:t,...l,children:e.jsx(at.default,{fontSize:"small"})})}function kt({onClick:t,disabled:s,sx:i,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(ct.default,{fontSize:"small"})})}function vt({onClick:t,disabled:s,sx:i,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(nt.default,{fontSize:"small"})})}function St({label:t,value:s,onChange:i,disabled:l=!1,itemLabel:f="",emptyHeight:y=40,property:x,renderItem:P,...v}){const{t:h,locale:k}=N.useLocaleContext(),g=ve.useUpdate(),o=T.useCallback(p=>{i(_.transformValue(p,x.type))},[i,x.type]),a=T.useMemo(()=>Array.isArray(s)?s:[],[s]),c=T.useCallback(()=>{const p=[...a,""];o(p),g()},[a,o,g]),d=T.useCallback(()=>{if(!x||!x.subProperties)return c();const p={};V.default(Object.values(x.subProperties),"index").forEach(({data:B})=>{var E,z;if(!B.key)return;const R=((z=(E=B.locales)==null?void 0:E[k])==null?void 0:z.defaultValue)??"";p[B.key]=R});const I=[...a,p];o(I),g()},[a,o,g,x,k,c]),u=T.useCallback(p=>{try{const w=JSON.parse(p);Array.isArray(w)?o(w):console.error("JSON解析结果不是数组")}catch(w){console.error("JSON解析错误:",w)}},[o]),S=T.useCallback(p=>{const w=a.filter((I,B)=>B!==p);o(w),g()},[a,o,g]),n=T.useCallback(p=>{if(p<=0)return;const w=[...a],I=w[p];w[p]=w[p-1],w[p-1]=I,o(w),g()},[a,o,g]),b=T.useCallback(p=>{if(p>=a.length-1)return;const w=[...a],I=w[p];w[p]=w[p+1],w[p+1]=I,o(w),g()},[a,o,g]),m=T.useCallback((p,w)=>{const I=[...a];I[p]=w,o(I)},[a,o]),j=x&&x.subProperties&&Object.keys(x.subProperties).length>0,C=T.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:p})=>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:p+1})},{field:"content",headerName:"",renderCell:({row:p,index:w})=>P&&j?P({item:p,index:w,property:x,onChange:I=>m(w,I)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:p,placeholder:f||`${h("item")} ${w+1}`,onChange:I=>m(w,I.target.value),...v})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:p})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(kt,{disabled:l||p===0,onClick:()=>n(p)}),e.jsx(vt,{disabled:l||p===a.length-1,onClick:()=>b(p)}),e.jsx(gt,{disabled:l,onClick:()=>S(p)})]})}],[P,j,x,m,f,h,l,v,S,n,b,a.length]);return j?e.jsxs(r.Stack,{width:"100%",gap:1,children:[t&&e.jsx(r.FormLabel,{children:t}),a.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(p=>e.jsx(r.TableCell,{width:p.width,align:p.align||"left",sx:{fontWeight:"bold"},children:p.renderHeader?p.renderHeader():p.headerName},p.field))})}),e.jsx(r.TableBody,{children:a.map((p,w,I)=>e.jsx(r.TableRow,{sx:{borderBottom:w<I.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:C.map(B=>e.jsx(r.TableCell,{width:B.width,align:B.align||"left",sx:{borderBottom:"none"},children:B.renderCell({row:p,index:w,onChange:R=>m(w,R)})},`${w}-${B.field}`))},w))})]})}):e.jsx(ee.default,{style:{fontSize:12,height:y},children:h("maker.properties.arrayEmpty")}),e.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:l,startIcon:e.jsx(ot.default,{}),onClick:d,children:h("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(ne.CodeEditor,{keyId:x.id,locale:k,language:"json",value:JSON.stringify(a,null,2),onChange:p=>u(p||""),fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},x.id)})]})}function Pt({value:t,onChange:s,...i}){const l=T.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(qe.ConfigString,{...i,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(ye.ColorItem,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{var f;(f=l.current)==null||f.open({value:t??""})}})})}}),e.jsx(ye.ConfigColorDialog,{ref:l,onSave:({value:f},y)=>{s(f),y()}})]})}function wt({label:t,value:s,onChange:i,property:l,component:f,defaultLocale:y,allComponents:x,PropertyValueField:P,onUpload:v}){const{locale:h}=N.useLocaleContext(),k=T.useRef(null);if(!W.default(l.subProperties)){const o=V.default(Object.values(l.subProperties||{}),"index").filter(a=>a.data.visible!==!1&&a.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:o.map((a,c)=>{const{data:d}=a,u=d.key??d.id,S=c===o.length-1;let n=null;try{s&&typeof s=="object"?n=s[u]:typeof s=="string"&&(n=(l.type==="yaml"?se.parse(s||""):JSON.parse(s||"{}"))[u])}catch{}n==null&&(d.locales&&h&&d.locales[h]?n=d.locales[h].defaultValue:d.locales&&y&&d.locales[y]&&(n=d.locales[y].defaultValue));const b=j=>{try{let C={};if(typeof s=="string")try{C=l.type==="yaml"?se.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(C={...s});we.default(C,u,j);const p=_.transformValue(C,l.type);i==null||i(p)}catch(C){console.error("Error updating property:",C)}},m=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:m,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:m,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!S&&e.jsx(r.Box,{sx:{position:"absolute",left:m,top:16,bottom:-8,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsx(r.Box,{sx:{flexGrow:1},children:e.jsx(P,{component:f,property:d,value:n,onChange:b,size:"small",fullWidth:!0,defaultLocale:y,allComponents:x})})]},d.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(ne.CodeEditor,{keyId:l.id,locale:h,language:l.type==="yaml"?"yaml":"json",value:typeof s=="string"?s:"",onChange:o=>{i==null||i(o)},onUpload:o=>{k.current=o,v&&v(o)},fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},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 Ct=["string","multiline","json","yaml","url","component","custom","array"];function ge(t){return t.type?!Ct.includes(t.type):!1}function Ce({disabled:t,list:s,renderItem:i,...l}){const f=T.useRef(null),y=T.useId(),x=Pe.useUpdate(),P=V.default(Object.entries(s),a=>a[1].index).map(a=>a[0]),v=T.useRef(P),h=T.useCallback(a=>{v.current=a,x()},[x]),k=T.useCallback(({index:a},{index:c})=>{const d=[...v.current];d.splice(c,0,...d.splice(a,1)),h(d)},[h]);T.useEffect(()=>{h(P)},[P.join("-")]);const[{isOver:g},o]=re.useDrop({accept:y,collect:a=>({isOver:a.isOver()}),canDrop:()=>!t,drop:()=>{var d;const a=()=>{v.current.forEach((u,S)=>{const n=s[u];n&&(n.index=S)})},c=(d=G.getYjsValue(s))==null?void 0:d.doc;c?c.transact(()=>{a()}):a()}});return T.useEffect(()=>{g||h(P)},[g]),o(f),e.jsx(r.Box,{...l,ref:f,className:it.cx(g&&"isDragging"),children:v.current.map((a,c)=>e.jsx(It,{type:y,disabled:t,id:a,index:c,itemIndex:d=>v.current.indexOf(d),move:k,children:d=>{const u=s[a];return u?i(u.data,c,d):null}},a))})}function It({disabled:t,id:s,index:i,type:l,children:f,itemIndex:y,move:x}){const P=T.useRef(),[{isDragging:v},h,k]=re.useDrag({type:l,item:()=>({id:s}),canDrag:()=>!t,collect:o=>({isDragging:o.isDragging()})}),[,g]=re.useDrop({accept:l,canDrop:()=>!t,hover(o,a){var m;if(!P.current)return;const c=y(o.id),d=i;if(c===d)return;const u=(m=P.current)==null?void 0:m.getBoundingClientRect(),S=(u.bottom-u.top)/2,b=a.getClientOffset().y-u.top;c<d&&b<S||c>d&&b>S||x({id:o.id,index:c},{id:s,index:i})}});return typeof f=="function"?f({isDragging:v,drag:h,drop:o=>(P.current=o,g(o)),preview:k}):(h(g(k(P))),e.jsx(r.Box,{ref:P,children:f}))}function Tt({drop:t,preview:s,drag:i,disabled:l,isDragging:f,children:y,onDelete:x,onVisibilityChange:P,visible:v=!0,actions:h,alwaysShowActions:k=!1}){const{t:g}=N.useLocaleContext();return e.jsx(r.Box,{ref:t,sx:{":hover .hover-visible":{maxWidth:"100%"},opacity:v?1:.5},children:e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsx(r.Box,{ref:s,sx:{flex:1,borderRadius:.5,bgcolor:f?"action.hover":"background.paper",opacity:.9999},children:y}),!l&&e.jsx(r.Box,{className:k?"":"hover-visible",sx:{maxWidth:k?"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:o=>r.alpha(o.palette.grey[200],.9),borderRadius:1,p:.5,[`.${r.buttonClasses.root}`]:{minWidth:24,width:24,height:24,p:0}},children:[h,P&&e.jsx(r.Tooltip,{title:g(v?"hideParameter":"showParameter"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>P(!v),children:v?e.jsx(D.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(D.VisibilityRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),x&&e.jsx(r.Tooltip,{title:g("delete"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:x,children:e.jsx(D.DeleteOutlineRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),e.jsx(r.Tooltip,{title:g("dragSort"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{ref:i,children:e.jsx(D.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function Bt(t){const s=["string","json","array","url","multiline"],i=["style","fontSize","color","content","type"];return!!(s.includes(t.type||"")&&!i.includes(t.key||""))}function Ot(t,s,i){return t.locales&&t.locales[s]&&t.locales[s].name?t.locales[s].name:i&&t.locales&&t.locales[i]&&t.locales[i].name?t.locales[i].name:t.key?t.key:t.id}const Ie=(t,s,i,l)=>{const f={};return V.default(Object.entries(t),([,x])=>x.index).forEach(([x,P])=>{const v=P.data;if(!v)return;const h=v.key||v.id,k=i?Ot(v,i,l||""):h,g=s==null?void 0:s[v.id],o={key:h,isNeedGenerate:(g==null?void 0:g.isNeedGenerate)??Bt(v),describe:(g==null?void 0:g.describe)??"",displayName:k};v.subProperties&&!W.default(v.subProperties)&&(o.subProperties=Ie(v.subProperties,g==null?void 0:g.subProperties,i,l)),f[v.id]=o}),f};function Nt({open:t,onClose:s,onConfirm:i,component:l,initialConfig:f,locale:y,defaultLocale:x,title:P,loading:v=!1}){const{t:h}=N.useLocaleContext(),[k,g]=T.useState(null);T.useEffect(()=>{if(t&&l){const u={properties:{}};if(l.properties){const S=f==null?void 0:f.properties;u.properties=Ie(l.properties,S,y,x)}g(u)}},[t,l,f,y,x]);const o=()=>{s()},a=()=>{k&&(i(k),s())},c=(u,S,n)=>{if(!k||!u.length)return;const b=JSON.parse(JSON.stringify(k));let m=b.properties,j=null;for(let p=0;p<u.length-1;p++){const w=u[p];if(!w||!m[w])return;j=m;const I=m[w];I.subProperties||(I.subProperties={}),m=I.subProperties}const C=u[u.length-1];if(C){if("isNeedGenerate"in n){const p=n.isNeedGenerate,w={...S,...n};if(S.subProperties&&!W.default(S.subProperties)){const I=(B,R)=>{const E={};return Object.entries(B).forEach(([z,A])=>{const F={...A};R!==null&&(F.isNeedGenerate=R),A.subProperties&&!W.default(A.subProperties)&&(F.subProperties=I(A.subProperties,R!==null?R:null)),E[z]=F}),E};w.subProperties=I(S.subProperties,p===!1?!1:null)}if(u.length===1)b.properties[C]=w;else if(j&&u.length>=2){const I=u[u.length-2];I&&j[I]&&(j[I].subProperties||(j[I].subProperties={}),j[I].subProperties[C]=w)}}else if(u.length===1)b.properties[C]={...S,...n};else if(j&&u.length>=2){const p=u[u.length-2];p&&j[p]&&j[p].subProperties&&(j[p].subProperties[C]={...S,...n})}g(b)}},d=(u,S=[],n=!0)=>{if(!u||W.default(u))return null;const b=V.default(Object.entries(u),([,m])=>m.displayName);return e.jsx(r.Stack,{spacing:1.5,children:b.map(([m,j],C)=>{const p=[...S,m],w=C===b.length-1,I=j.subProperties&&!W.default(j.subProperties),B=j.displayName||m,R=!n;return e.jsx(r.Box,{sx:{position:"relative"},children:e.jsxs(r.Stack,{direction:"row",children:[S.length>0&&e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:8,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:8,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!w&&e.jsx(r.Box,{sx:{position:"absolute",left:8,top:16,bottom:-12,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsxs(r.Stack,{spacing:1.5,sx:{flexGrow:1},children:[e.jsxs(r.Stack,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},spacing:1.5,width:"100%",children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:j.isNeedGenerate,disabled:R,onChange:E=>{c(p,j,{isNeedGenerate:E.target.checked})}}),label:B,sx:{minWidth:"180px",maxWidth:"280px",mr:2,"& .MuiFormControlLabel-label":{wordBreak:"break-word"}}}),e.jsx(r.TextField,{size:"small",fullWidth:!0,label:h("maker.properties.llmPropertyDescribe"),value:j.describe,onChange:E=>{c(p,j,{describe:E.target.value})},disabled:!j.isNeedGenerate})]}),I&&e.jsx(r.Box,{sx:{ml:3},children:d(j.subProperties,p,j.isNeedGenerate&&n)})]})]})},m)})})};return e.jsxs(r.Dialog,{open:t,onClose:o,maxWidth:"lg",fullWidth:!0,children:[e.jsx(r.DialogTitle,{children:P||h("maker.properties.llmConfigTitle")}),e.jsx(r.DialogContent,{children:e.jsx(r.Box,{my:3,children:v?e.jsx(r.Typography,{children:h("maker.properties.loading")}):l?k?e.jsxs(r.Stack,{spacing:3,children:[e.jsx(r.Typography,{variant:"subtitle2",children:h("maker.properties.llmConfigInstructions")}),d(k.properties)]}):e.jsx(r.Typography,{children:h("maker.properties.loading")}):e.jsx(r.Typography,{color:"error",children:h("maker.properties.componentNotFound")})})}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{onClick:o,children:h("common.cancel")}),e.jsx(r.Button,{variant:"contained",onClick:a,disabled:!k||v,children:h("common.confirm")})]})]})}function Rt({label:t,value:s,onChange:i}){const[l,f]=T.useState(!1);return e.jsxs(r.Stack,{gap:1,children:[e.jsx(r.TextField,{label:t,size:"small",value:s,onChange:y=>i==null?void 0:i(y.target.value),InputProps:{endAdornment:e.jsx(q.UploaderButton,{onChange:({response:y})=>{var P;const x=(P=y==null?void 0:y.data)==null?void 0:P.filename;x&&(i==null||i(x))}})}}),s&&e.jsx(r.Box,{component:"img",sx:{objectFit:"contain",borderRadius:1,cursor:"pointer"},src:_.getImageAbsoluteUrl(s),alt:t,maxWidth:100,maxHeight:100,width:"100%",onClick:()=>f(!0)}),e.jsx(r.Dialog,{open:l,onClose:()=>f(!1),children:e.jsx(r.Box,{component:"img",sx:{objectFit:"contain"},src:_.getImageAbsoluteUrl(s),alt:t})})]})}function le(t,s=""){return yt.default(t,(i,l,f)=>{const y=s?`${s}.${f}`:f;return ft.default(l)?dt.default(i,le(l,y)):i[y]=l,i},{})}const _t=[{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 Q(t,s,i){return!t||!i?!1:Object.values(t).some(({data:l})=>l.id!==s&&l.key===i)}function oe(t,s){var i;return!t||!s?!1:((i=t[s])==null?void 0:i.data.visible)??!0}function Et({componentId:t}){const{state:{components:s}}=_.useStore(),i=s[t],l=i==null?void 0:i.data;return l?e.jsx(r.Stack,{maxHeight:"100%",overflow:"auto",children:e.jsx(r.Box,{p:2,children:e.jsx(st.ErrorBoundary,{FallbackComponent:_.ErrorView,resetKeys:[t],children:e.jsx(Dt,{value:l,componentId:t})})})}):null}function Dt({value:t,componentId:s}){var g,o,a;const{t:i}=N.useLocaleContext(),{localState:{currentLocale:l,customComponentPreviewerProperties:f},state:{config:{defaultLocale:y}},localActions:{setCustomComponentPreviewerProperties:x}}=_.useStore(),P=G.getYjsValue(t).doc,v=_.useAllComponents(),h=T.useMemo(()=>(f==null?void 0:f[s])??{},[s,f]),k=Pe.useReactive({componentId:s,propertiesValue:{...h}});return T.useEffect(()=>{k.componentId!==s&&(k.componentId=s,k.propertiesValue={...h})},[s,h,k]),T.useEffect(()=>{if(k.componentId!==s)return;const c=Object.fromEntries(Object.values(t.properties??{}).map(({data:d})=>{var u,S,n,b,m;return[d.id,{value:((u=k.propertiesValue[d.id])==null?void 0:u.value)??Je.parsePropertyValue(d,((n=(S=d.locales)==null?void 0:S[l])==null?void 0:n.defaultValue)??((m=(b=d.locales)==null?void 0:b[y])==null?void 0:m.defaultValue),{locale:l,defaultLocale:y})}]}));x(s,c)},[JSON.stringify(k.propertiesValue),s,k.componentId]),e.jsx(r.Stack,{height:"100%",children:e.jsxs(r.Stack,{gap:2,children:[e.jsx(Te,{config:t}),e.jsx(Oe,{config:t,currentLocale:l,defaultLocale:y,allComponents:v,onUpdateConfig:c=>{P.transact(()=>{c(t)})}}),e.jsxs(r.Stack,{gap:2,direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(r.Typography,{variant:"subtitle1",children:i("renderer")}),e.jsxs(r.TextField,{hiddenLabel:!0,size:"small",select:!0,SelectProps:{autoWidth:!0},value:((g=t.renderer)==null?void 0:g.type)||"react-component",onChange:c=>{P.transact(()=>{const d=c.target.value;t.renderer??(t.renderer={type:d}),t.renderer.type=d})},children:[e.jsx(r.MenuItem,{value:"react-component",children:"React Component"}),e.jsx(r.MenuItem,{value:"component",children:"Custom Component"})]})]}),((o=t.renderer)==null?void 0:o.type)==="component"&&e.jsx(Mt,{value:t}),((a=t.renderer)==null?void 0:a.type)==="react-component"&&e.jsx(Ut,{value:t}),e.jsx(ce,{config:t,currentLocale:l,defaultLocale:y,allComponents:v,propertiesValue:k.propertiesValue,onChange:({value:c,id:d,path:u})=>{const S=[...u,"data"];if(!pt.default(t,S)){ie.default.warning(i("cannotFindPropertyKey",{key:S.join(".")}));return}k.propertiesValue[d]={value:c.value}}})]})})}function Te({config:t}){const{t:s}=N.useLocaleContext();return e.jsx(q.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:i=>t.name=i.target.value}),e.jsx(r.TextField,{label:s("description"),size:"small",multiline:!0,minRows:2,maxRows:10,inputProps:{maxLength:200},value:t.description||"",onChange:i=>t.description=i.target.value,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mt:-1.5},children:e.jsx(Wt,{config:t})})}}),e.jsx(r.Autocomplete,{size:"small",options:[],multiple:!0,freeSolo:!0,value:t.tags??[],onChange:(i,l)=>t.tags=l,renderInput:i=>e.jsx(r.TextField,{label:s("tags"),...i})}),e.jsx(Rt,{label:s("previewImage"),value:t.previewImage||"",onChange:i=>t.previewImage=i})]})})}function Be({data:t,params:s,visible:i,config:l,currentLocale:f,defaultLocale:y,allComponents:x,onUpdateConfig:P}){var k,g,o,a,c,d;const{t:v}=N.useLocaleContext(),h=T.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?Ft:L,[t.type]);return e.jsx(Tt,{preview:s.preview,drop:s.drop,drag:s.drag,isDragging:s.isDragging,onDelete:()=>{P(u=>{if(u.properties){const n=Object.entries(u.properties).sort(([,m],[,j])=>m.index-j.index);delete u.properties[t.id],n.filter(([m])=>m!==t.id).forEach(([,m],j)=>{m.index=j})}})},visible:i,onVisibilityChange:u=>{P(S=>{const n=S.properties[t.id].data;n.visible=u})},alwaysShowActions:!0,children:e.jsxs(r.Stack,{direction:"column",gap:2,children:[e.jsx(r.TextField,{label:v("key"),size:"small",required:!0,sx:{width:"calc(100% - 80px - 8px)",flex:1,"& .MuiOutlinedInput-root":{borderColor:t.key?Q(l.properties,t.id,t.key)?"warning.main":void 0:"error.main"},"& .MuiFormLabel-root":{color:t.key?Q(l.properties,t.id,t.key)?"warning.main":"text.secondary":"error.main"},"& .MuiFormLabel-root.Mui-focused":{color:t.key?Q(l.properties,t.id,t.key)?"warning.main":"primary.main":"error.main"}},value:t.key||"",onChange:u=>{P(S=>{const n=S.properties[t.id].data;n.key=u.target.value.trim()})},InputProps:{endAdornment:!t.key||t.key&&Q(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?v("duplicateKey"):v("requiredKey"),children:e.jsx(D.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:v("label"),size:"small",sx:{flex:1},value:(((g=(k=t.locales)==null?void 0:k[f])==null?void 0:g.name)??((a=(o=t.locales)==null?void 0:o[y])==null?void 0:a.name))||"",onChange:u=>{P(S=>{var b;const n=S.properties[t.id].data;n.locales??(n.locales={}),(b=n.locales)[f]??(b[f]={}),n.locales[f].name=u.target.value})}}),e.jsx(r.TextField,{label:v("type"),size:"small",select:!0,sx:{flex:1},value:t.type==="string"&&t.multiline?"multiline":t.type||"string",onChange:u=>{P(S=>{const n=S.properties[t.id].data;if(n.locales)for(const m of Object.keys(n.locales))n.locales[m].defaultValue=void 0;const b=u.target.value;b==="multiline"?(n.type="string",n.multiline=!0):(typeof n.multiline<"u"&&delete n.multiline,n.type=b)})},children:_t.map(u=>e.jsx(r.MenuItem,{value:u.value,children:u.label},u.value))})]}),e.jsxs(r.Stack,{direction:"row",gap:1,children:[e.jsx(h,{allComponents:x,defaultLocale:y,component:l,property:t,label:v("defaultValue"),size:"small",fullWidth:!0,value:(d=(c=t.locales)==null?void 0:c[f])==null?void 0:d.defaultValue,onChange:(u,S)=>{P(n=>{var m;const b=n.properties[t.id].data;if(S!=null&&S.forceUpdateProperty){const j=le(b),C=le(u);Object.keys(C).forEach(p=>{j[p]||we.default(b,p,C[p])})}else b.locales??(b.locales={}),(m=b.locales)[f]??(m[f]={}),b.locales[f].defaultValue=u})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(zt,{property:t,allComponents:x})}):null]})]})})}function Vt(t,s){const[i,l]=T.useState(0);return T.useEffect(()=>{const y=setTimeout(()=>{if(t.current){let x=t.current.parentElement,P=0;for(;x;)x.classList.contains("property-container")&&P++,x=x.parentElement;l(P)}},100);return()=>clearTimeout(y)},[t,s]),i}function Oe({config:t,currentLocale:s,defaultLocale:i,allComponents:l,onUpdateConfig:f,useI18nEditor:y=!0}){const{t:x}=N.useLocaleContext(),P=U.usePopupState({variant:"dialog"}),v=t.properties&&V.default(Object.values(t.properties),"index");return e.jsx(q.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:x("properties")}),e.jsx(r.Box,{flex:1}),y&&e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...U.bindTrigger(P),children:e.jsx(D.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(Ce,{component:r.Stack,gap:2,list:t.properties,renderItem:(h,k,g)=>{const o=oe(t.properties,h.id);return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:o?"1px solid":"1px dashed",borderColor:"divider"},children:e.jsx(r.Stack,{gap:2,children:e.jsx(Be,{data:h,params:g,visible:o,config:t,currentLocale:s,defaultLocale:i,allComponents:l,onUpdateConfig:f})})},h.id)}}):e.jsx(ee.default,{style:{fontSize:12},children:x("maker.properties.noProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",onClick:()=>{f(h=>{var g;const k=_.nextId();h.properties??(h.properties={}),(g=h.properties)[k]??(g[k]={index:(v==null?void 0:v.length)||0,data:{id:k}})})},startIcon:e.jsx(D.AddRounded,{}),children:x("addObject",{object:x("property")})}),y&&e.jsx(Ne,{...U.bindDialog(P),component:t})]})})}function zt({property:t,allComponents:s}){const i=U.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...U.bindTrigger(i),children:e.jsx(D.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...U.bindPopper(i),children:e.jsx(Se.ClickAwayListener,{onClickAway:i.close,children:e.jsx(r.Paper,{children:e.jsx(r.Box,{width:500,p:2,children:e.jsx(te,{value:t.componentId,onChange:(l,f)=>t.componentId=f,allComponents:s})})})})})]})}function At({value:t,valueImmutable:s,onChange:i,defaultLocale:l,allComponents:f}){var k;const[y,x]=T.useState(!1),{t:P,locale:v}=N.useLocaleContext(),h=typeof(t==null?void 0:t.componentId)=="string"?(k=f[t.componentId])==null?void 0:k.data:void 0;return h?e.jsxs(r.Box,{sx:{width:"100%",position:"relative"},children:[e.jsx(r.IconButton,{sx:{minWidth:0},disabled:!h,size:"small",onClick:()=>x(!y),color:y?"primary":"default",children:e.jsx(D.SettingsRounded,{fontSize:"small"})}),y&&e.jsx(r.Collapse,{in:y,timeout:"auto",unmountOnExit:!0,sx:{width:"100%",zIndex:10},children:e.jsxs(r.Paper,{elevation:1,sx:{mt:1,p:2,borderRadius:1,border:"1px solid",borderColor:"divider",width:"100%"},children:[e.jsx(r.Box,{width:"100%",mb:2,children:e.jsx(ce,{config:h,currentLocale:v,defaultLocale:l,allComponents:f,propertiesValue:t==null?void 0:t.properties,onChange:({id:g,value:o})=>{const a=ut.default(o.value),c=JSON.parse(JSON.stringify(t));c!=null&&c.componentId&&(s?i==null||i({...c,properties:{...c.properties,[g]:{value:a}}}):(c.properties=c.properties??{},c.properties[g]={value:a},i==null||i(c)))}})}),e.jsx(r.Button,{size:"small",onClick:()=>x(!1),sx:{mt:1},children:P("close")})]})})]}):null}function Ne({type:t="properties",component:s,...i}){var g,o,a;const{t:l}=N.useLocaleContext(),{state:{components:f,supportedLocales:y,config:{defaultLocale:x}}}=_.useStore(),P=_.useAllComponents(),v=G.getYjsValue(s).doc,h=t==="properties"?s.properties:t==="parameters"&&((g=s.renderer)==null?void 0:g.type)==="component"?(o=f[s.renderer.componentId])==null?void 0:o.data.properties:void 0,k=((a=s.renderer)==null?void 0:a.type)==="component"?s:void 0;return e.jsxs(r.Dialog,{...i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(r.DialogTitle,{children:l("i18nEditorTitle")}),e.jsx(r.DialogContent,{children:h&&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:y.map(({locale:c,name:d})=>e.jsx(r.TableCell,{children:e.jsxs(r.Typography,{color:"text.primary",children:[d,x===c&&e.jsx(D.StarRounded,{sx:{fontSize:12}})]})},c))})}),e.jsx(r.TableBody,{children:V.default(Object.values(h),"index").map(({data:c})=>e.jsx(r.TableRow,{children:y.map(({locale:d})=>{var u,S,n,b,m,j,C,p,w,I,B,R,E,z,A,F,J,H,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=>{v.transact(()=>{c.key=K.target.value.trim()})}}),e.jsx(r.TextField,{size:"small",label:l("label"),value:(((S=(u=c.locales)==null?void 0:u[d])==null?void 0:S.name)??((b=(n=c.locales)==null?void 0:n[x])==null?void 0:b.name))||"",onChange:K=>{v.transact(()=>{var M;c.locales??(c.locales={}),(M=c.locales)[d]??(M[d]={}),c.locales[d].name=K.target.value})}}),e.jsx(r.Box,{children:e.jsx(L,{allComponents:P,defaultLocale:x,component:s,property:c,size:"small",fullWidth:!0,label:"Default Value",valueImmutable:Z.default((j=(m=c.locales)==null?void 0:m[d])==null?void 0:j.defaultValue),value:((p=(C=c.locales)==null?void 0:C[d])==null?void 0:p.defaultValue)??((I=(w=c.locales)==null?void 0:w[x])==null?void 0:I.defaultValue),onChange:K=>{v.transact(()=>{var M;c.locales??(c.locales={}),(M=c.locales)[d]??(M[d]={}),c.locales[d].defaultValue=K})}})})]}):t==="parameters"&&k?e.jsx(r.Box,{children:e.jsx(L,{allComponents:P,defaultLocale:x,component:s,property:c,size:"small",fullWidth:!0,valueImmutable:Z.default((z=(E=(R=(B=k.renderer.properties)==null?void 0:B[c.id])==null?void 0:R.locales)==null?void 0:E[d])==null?void 0:z.value),value:((H=(J=(F=(A=k.renderer.properties)==null?void 0:A[c.id])==null?void 0:F.locales)==null?void 0:J[d])==null?void 0:H.value)??((ue=(ae=($=(Y=k.renderer.properties)==null?void 0:Y[c.id])==null?void 0:$.locales)==null?void 0:ae[x])==null?void 0:ue.value)??((pe=(de=c.locales)==null?void 0:de[d])==null?void 0:pe.defaultValue)??((me=(xe=c.locales)==null?void 0:xe[x])==null?void 0:me.defaultValue),onChange:K=>{v.transact(()=>{var M,fe,be,he,je;(M=k.renderer).properties??(M.properties={}),(fe=k.renderer.properties)[be=c.id]??(fe[be]={}),(he=k.renderer.properties[c.id]).locales??(he.locales={}),(je=k.renderer.properties[c.id].locales)[d]??(je[d]={}),k.renderer.properties[c.id].locales[d].value=K})}})}):null},c.id)},d)})},c.id))})]})})}),e.jsx(r.DialogActions,{children:e.jsx(r.Button,{onClick:c=>{var d;return(d=i.onClose)==null?void 0:d.call(i,c,"escapeKeyDown")},children:l("close")})})]})}const ke=(t,s)=>i=>{const l=[i.palette.info.main,i.palette.primary.main,i.palette.secondary.main,i.palette.success.main,i.palette.warning.main],f=Math.min(l.length-1,t),y=l[f],x=r.alpha(y,.5),P=r.alpha(y,1);return{borderColor:`${x} !important`,borderLeft:"3px solid !important",borderLeftColor:x,color:P,...s}};function Ft({property:t,onChange:s,defaultLocale:i,allComponents:l}){const{t:f,locale:y}=N.useLocaleContext(),x=T.useRef(null),P=Vt(x,t),v=T.useCallback(()=>{if(!(t.type!=="json"&&t.type!=="yaml"&&t.type!=="array")&&t.subProperties)try{let h={};V.default(Object.values(t.subProperties),"index").filter(o=>o.data.visible!==!1&&o.data.key).forEach(({data:o})=>{var c,d,u,S;if(!o.key)return;let a=((d=(c=o.locales)==null?void 0:c[y])==null?void 0:d.defaultValue)??((S=(u=o.locales)==null?void 0:u[i])==null?void 0:S.defaultValue);if(o.type==="number")a=Number(a);else if(o.type==="boolean")a=a===!0||a==="true";else if((o.type==="json"||o.type==="yaml")&&typeof a=="string")try{o.type==="json"?a=JSON.parse(a):a=se.parse(a)}catch(n){console.error("Error parsing nested value",a,n),a={}}h[o.key]=a}),t.type==="array"&&!Array.isArray(h)&&(h=W.default(h)?[]:[h]);const g=_.transformValue(h,t.type);s==null||s(g)}catch(h){console.error("Error converting structure to text:",h)}},[t,y,i,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:x,children:[e.jsx(r.Divider,{sx:{mt:-1},children:e.jsx(r.Typography,{variant:"caption",color:"text.secondary",children:f("maker.properties.subProperties")})}),t.subProperties&&Object.keys(t.subProperties).length>0?e.jsx(Ce,{component:r.Stack,gap:2,list:t.subProperties,renderItem:(h,k,g)=>{const o=h.visible!==!1;return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:o?"1px solid":"1px dashed","&":ke(P)},children:e.jsx(r.Stack,{gap:2,children:e.jsx(Be,{data:h,params:g,visible:o,config:{properties:t.subProperties},currentLocale:y,defaultLocale:i,allComponents:l,onUpdateConfig:a=>{try{const c={properties:t.subProperties||{}};a(c);const d={...t,subProperties:c.properties};s==null||s(d,{forceUpdateProperty:!0}),v()}catch(c){console.error("Error updating property:",c)}}})})},h.id)}}):e.jsx(ee.default,{style:{fontSize:12,height:100},children:f("maker.properties.noSubProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",size:"small",startIcon:e.jsx(D.AddRounded,{}),onClick:()=>{try{const h=t.subProperties||{},k=_.nextId(),o={index:Object.values(h).length,data:{id:k,key:"",type:"string",visible:!0,locales:{[y]:{name:"",defaultValue:""}},subProperties:{}}},a={...t,subProperties:{...h,[k]:o}};s==null||s(a,{forceUpdateProperty:!0}),v()}catch(h){console.error("Error adding property:",h)}},sx:{"&":ke(P,{})},children:f("maker.properties.addSubProperty")})]})}function L({component:t,property:s,value:i,onChange:l,valueImmutable:f,defaultLocale:y,allComponents:x,...P}){var a,c,d,u,S;const{locale:v}=N.useLocaleContext(),h=q.useUploader(),k=T.useRef(null),g=()=>{var b;const n=(b=h==null?void 0:h.current)==null?void 0:b.getUploader();n==null||n.open(),k.current&&n.onceUploadSuccess(({response:m})=>{var C,p;let j=((C=m==null?void 0:m.data)==null?void 0:C.filename)||"";j&&(j=`mediakit://${j}`,i&&!i.includes("mediakit://")&&(j+=" # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")),(p=k.current)==null||p.call(k,j)})},o=P.label??(((c=(a=s.locales)==null?void 0:a[v])==null?void 0:c.name)||((u=(d=s.locales)==null?void 0:d[y])==null?void 0:u.name)||s.key||s.id);if(s.type==="number")return e.jsx(qt,{...P,label:o,NumberProps:{value:["number","string"].includes(typeof i)?i:null,onChange:(n,b)=>l==null?void 0:l(b)}});if(s.type==="decimal")return e.jsx(r.TextField,{...P,label:o,type:"text",value:i??"",onChange:n=>{const b=n.target.value;if(b===""||b==="-"){l==null||l(b);return}if(/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(b)){let j=b;/^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(j)&&(j=Number(j)),l==null||l(j)}}});if(s.type==="boolean")return e.jsx(r.FormControlLabel,{label:o,labelPlacement:"start",control:e.jsx(r.Switch,{checked:i===!0,onChange:(n,b)=>l==null?void 0:l(b)})});if(s.type==="color")return e.jsx(Pt,{label:o,value:i,onChange:n=>{l==null||l(n)}});if(s.type==="json"||s.type==="yaml")return e.jsx(wt,{label:o,value:i,onChange:n=>{l==null||l(n)},property:s,component:t,defaultLocale:y,allComponents:x,PropertyValueField:L,onUpload:n=>{k.current=n,g()}});if(s.type==="custom"){const n=(S=x[s.componentId])==null?void 0:S.data;return n?e.jsx(r.Box,{width:"100%",children:e.jsx(X.CustomComponentRenderer,{componentId:n.id,props:{label:o,value:i,onChange:l},locale:v,dev:{mode:"draft",components:x,defaultLocale:y}})}):e.jsx(r.TextField,{...P,label:o,disabled:!0,placeholder:"Click right button select a component"})}if(s.type==="component")return e.jsxs(r.Stack,{width:"100%",direction:"column",gap:1,children:[e.jsx(te,{allComponents:x,label:o,value:i==null?void 0:i.componentId,onChange:(n,b)=>{f||!i?l==null||l({...i&&JSON.parse(JSON.stringify(i)),componentId:b}):typeof i=="object"&&(i.componentId=b,l==null||l({...i&&JSON.parse(JSON.stringify(i)),componentId:b}))}}),(i==null?void 0:i.componentId)&&e.jsx(At,{value:i,valueImmutable:f,onChange:l,defaultLocale:y,allComponents:x})]});if(!s.type||["string","url","multiline"].includes(s.type)){let n=s.type==="string"?s.multiline:void 0;s.type==="multiline"&&(n=!0);const b=s.type==="url"?i==null?void 0:i.url:i;return e.jsx(r.TextField,{...P,label:o,value:typeof b=="string"?b:"",multiline:n,minRows:n?2:void 0,maxRows:n?10:void 0,onChange:m=>l==null?void 0:l(s.type==="url"?{...i,url:m.target.value,mediaKitUrl:m.target.value}:m.target.value),InputProps:s.type==="url"?{sx:{pr:0},endAdornment:e.jsxs(r.InputAdornment,{position:"end",children:[e.jsx(q.UploaderButton,{onChange:async({response:m})=>{var w,I,B;const j=((w=m==null?void 0:m.data)==null?void 0:w.url)||((I=m==null?void 0:m.data)==null?void 0:I.fileUrl);let C;j&&(C=await q.getImageSize(j).catch(()=>q.getVideoSize(j)).catch(()=>{}));let p=((B=m==null?void 0:m.data)==null?void 0:B.filename)||"";p&&(p=`mediakit://${p}`),l==null||l({url:j,mediaKitUrl:p,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(D.InfoRounded,{sx:{cursor:"default",mr:1},fontSize:"small"})})]})}:void 0})}return s.type==="array"?e.jsx(St,{label:o,value:Array.isArray(i)?i:[],onChange:n=>l==null?void 0:l(n),property:s,renderItem:({item:n,index:b,onChange:m})=>s.subProperties&&Object.keys(s.subProperties).length>0?e.jsx(r.Stack,{gap:1,width:"100%",children:V.default(Object.values(s.subProperties),"index").filter(j=>j.data.visible!==!1).map(({data:j})=>j.key?e.jsx(L,{component:t,property:j,value:n[j.key],onChange:C=>{const p={...n,[j.key]:C};m(p)},size:"small",fullWidth:!0,defaultLocale:y,allComponents:x},j.id):null)},b):e.jsx(r.TextField,{size:P.size,fullWidth:!0,value:n,onChange:j=>m(j.target.value)})}):(console.error("Unsupported property type",s.type),null)}function qt({NumberProps:t,...s}){const{getInputProps:i}=Se.unstable_useNumberInput(t),l=i();return e.jsx(r.TextField,{...s,inputProps:l})}const Re=`import React from '@blocklet/pages-kit/builtin/react'
|
|
2
2
|
import { Box } from '@blocklet/pages-kit/builtin/mui/material'
|
|
3
3
|
|
|
4
4
|
export default function () {
|
|
@@ -8,4 +8,4 @@ export default function () {
|
|
|
8
8
|
</Box>
|
|
9
9
|
)
|
|
10
10
|
}`,_e=`console.log('hello')
|
|
11
|
-
`;function
|
|
11
|
+
`;function Ut({value:t}){const{locale:s}=N.useLocaleContext(),i=ve.useUpdate(),l=G.getYjsValue(t).doc;return T.useEffect(()=>{var f;(f=t.renderer)!=null&&f.script||(l.transact(()=>{t.renderer.script=t.renderer.type==="react-component"?Re:_e}),i())},[t]),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,overflow:"hidden"},children:e.jsx(ne.CodeEditor,{keyId:t.id,locale:s,language:"typescript",value:t.renderer.script||"",onChange:f=>t.renderer.script=f,typeScriptNoValidation:!1,fullScreenOptions:{enableEscExit:!0}},t.id)})}function Mt({value:t}){var k,g,o;const{t:s}=N.useLocaleContext(),i=G.getYjsValue(t).doc,{state:{components:l,config:{defaultLocale:f},resources:y},localState:{currentLocale:x}}=_.useStore(),P=_.useAllComponents(),v=((k=l[t.renderer.componentId])==null?void 0:k.data)??((o=(g=y.components)==null?void 0:g[t.renderer.componentId])==null?void 0:o.component),h=U.usePopupState({variant:"dialog"});return e.jsx(q.UploaderProvider,{children:e.jsxs(r.Stack,{gap:1,children:[e.jsx(te,{allComponents:P,excludes:[t.id],value:t.renderer.componentId,onChange:(a,c)=>t.renderer.componentId=c}),v&&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},...U.bindTrigger(h),children:e.jsx(D.TranslateRounded,{fontSize:"small"})})]}),v.properties&&V.default(Object.values(v.properties),"index").map(({data:a})=>{var c,d,u,S,n,b,m,j,C,p,w,I,B,R,E,z;return e.jsx(r.Box,{children:e.jsx(L,{allComponents:P,defaultLocale:f,component:v,property:a,fullWidth:!0,size:"small",valueImmutable:Z.default((S=(u=(d=(c=t.renderer.properties)==null?void 0:c[a.id])==null?void 0:d.locales)==null?void 0:u[x])==null?void 0:S.value),value:((j=(m=(b=(n=t.renderer.properties)==null?void 0:n[a.id])==null?void 0:b.locales)==null?void 0:m[x])==null?void 0:j.value)??((I=(w=(p=(C=t.renderer.properties)==null?void 0:C[a.id])==null?void 0:p.locales)==null?void 0:w[f])==null?void 0:I.value)??((R=(B=a.locales)==null?void 0:B[x])==null?void 0:R.defaultValue)??((z=(E=a.locales)==null?void 0:E[f])==null?void 0:z.defaultValue),onChange:A=>{i.transact(()=>{var F,J,H,Y,$;(F=t.renderer).properties??(F.properties={}),(J=t.renderer.properties)[H=a.id]??(J[H]={}),(Y=t.renderer.properties[a.id]).locales??(Y.locales={}),($=t.renderer.properties[a.id].locales)[x]??($[x]={}),t.renderer.properties[a.id].locales[x].value=A})}})},a.id)}),e.jsx(Ne,{...U.bindDialog(h),component:t,type:"parameters"})]})]})})}function te({label:t,options:s,excludes:i,value:l,onChange:f,allComponents:y,...x}){var k;const{t:P}=N.useLocaleContext(),v=s??V.default(Object.values(ht.default(y,...i??[])),"index").map(g=>g.data),h=(typeof l=="string"?(k=y[l])==null?void 0:k.data:void 0)??null;return e.jsx(r.Autocomplete,{...x,size:"small",options:v,autoHighlight:!0,isOptionEqualToValue:(g,o)=>g.id===o.id,getOptionKey:g=>g.id,getOptionLabel:g=>g.name||g.id,renderInput:g=>e.jsx(r.TextField,{label:t||P("component"),...g}),value:h,onChange:(g,o)=>{var c,d,u,S,n,b;let a={};o&&(a={blockletId:(c=y[o==null?void 0:o.id])==null?void 0:c.blockletId,blockletTitle:(d=y[o==null?void 0:o.id])==null?void 0:d.blockletTitle,componentName:((S=(u=y[o==null?void 0:o.id])==null?void 0:u.data)==null?void 0:S.name)||((b=(n=y[o==null?void 0:o.id])==null?void 0:n.data)==null?void 0:b.id)}),f==null||f(g,o==null?void 0:o.id,a)}})}function ce({config:t,allComponents:s,defaultLocale:i,propertiesValue:l,currentLocale:f,onChange:y,props:x}){const{t:P}=N.useLocaleContext(),[v,h]=T.useState(t==null?void 0:t.properties),[k,g]=T.useState(null);T.useEffect(()=>{(()=>{var S,n;((S=t==null?void 0:t.renderer)==null?void 0:S.type)==="react-component"&&W.default(t==null?void 0:t.properties)?X.transpileAndLoadScript((n=t==null?void 0:t.renderer)==null?void 0:n.script).then(b=>{const m=X.getPropertiesFromCode(b);h(m)}):h(t==null?void 0:t.properties)})()},[JSON.stringify(t)]);const o=T.useCallback(()=>!t||!v?{}:Object.values(v).reduce((u,{data:S})=>{var b,m,j,C,p;const n=S.key||S.id;return u[S.id]={key:n,value:(x==null?void 0:x[n])??((b=l==null?void 0:l[S.id])==null?void 0:b.value)??((j=(m=S.locales)==null?void 0:m[f])==null?void 0:j.defaultValue)??((p=(C=S.locales)==null?void 0:C[i])==null?void 0:p.defaultValue),id:S.id,type:S.type},u},{}),[JSON.stringify(v),t,l,f,i]),a=T.useMemo(()=>{if(!v)return{canUseProperties:[],visibleProperties:[],canUsePropertiesKeys:[]};const u=V.default(Object.values(v),"index"),S=u.filter(({data:m})=>m.key&&oe(v,m.id)),n=u.filter(({data:m})=>m.key&&m.type!=="component"),b=n.map(({data:m})=>m.key);return{canUseProperties:n,visibleProperties:S,canUsePropertiesKeys:b}},[JSON.stringify(v)]),c=o(),d=bt.default(c,"key");return e.jsx(q.UploaderProvider,{children:e.jsxs(r.Stack,{gap:2,children:[e.jsx(r.Typography,{variant:"subtitle1",children:P("maker.properties.parameters")}),!t||a.canUsePropertiesKeys.length===0?e.jsx(ee.default,{style:{fontSize:12},children:P("maker.properties.noParameters")}):e.jsxs(e.Fragment,{children:[e.jsx(r.Stack,{gap:2,children:a.visibleProperties.map(({data:u})=>{var S,n;return e.jsx(r.Box,{children:e.jsx(L,{allComponents:s,defaultLocale:i,size:"small",fullWidth:!0,component:t,property:u,valueImmutable:Z.default((S=l==null?void 0:l[u.id])==null?void 0:S.value),value:(x==null?void 0:x[u.key||u.id])??((n=c[u.id])==null?void 0:n.value),onChange:b=>{y({path:["properties",u.id],id:u.id,value:{value:b},shouldSync:ge(u),excludeKeys:[],key:u.key||u.id})}})},u.id)})}),e.jsx(r.Stack,{gap:2,sx:{width:"100%"},children:e.jsx(X.CustomComponentRenderer,{componentId:(t==null?void 0:t.id)||"",renderType:"setting",locale:f,properties:c,dev:{mode:"draft",components:s,defaultLocale:i},props:{...jt.default(x??{},a.canUsePropertiesKeys),onChange:u=>{const{canUsePropertiesKeys:S}=a;Object.keys(u).filter(b=>{var m;return!mt.default(u[b],(m=d==null?void 0:d[b])==null?void 0:m.value)}).filter(b=>{var m,j,C,p;return!(b==="locale"&&!xt.default(d[b],"locale")||((m=d[b])==null?void 0:m.type)==="component"||(((j=d[b])==null?void 0:j.type)==="yaml"||((C=d[b])==null?void 0:C.type)==="json")&&oe(v,(p=d[b])==null?void 0:p.id))}).reduce((b,m)=>b.then(()=>{const j=d[m],C=S.includes(m);if(j!=null&&j.id&&C)return y({path:["properties",j.id],id:j.id,value:{value:u[m]},shouldSync:ge(j),excludeKeys:[],key:j.key||j.id}),Promise.resolve();const p=`propertyNotFound${m}`;if(k===p)return Promise.resolve();ie.default.close(k);const w=ie.default.warning(P("maker.properties.propertyNotFound",{key:m}),{key:p});return g(w),Promise.resolve()}),Promise.resolve())}}})})]})]})})}function Wt({config:t}){const{t:s}=N.useLocaleContext(),{localState:{currentLocale:i},state:{config:{defaultLocale:l}}}=_.useStore(),[f,y]=T.useState(!1),x=P=>{t.llmConfig=P};return e.jsxs(e.Fragment,{children:[e.jsx(r.Tooltip,{title:s("maker.properties.configDetailedDescription"),children:e.jsx(r.IconButton,{size:"small",color:"primary",onClick:()=>y(!0),children:e.jsx(D.PsychologyAlt,{fontSize:"small"})})}),f&&e.jsx(Nt,{open:f,onClose:()=>y(!1),onConfirm:x,component:t,initialConfig:t.llmConfig,locale:i,defaultLocale:l,title:s("maker.properties.llmConfigTitle")})]})}exports.BasicInfo=Te;exports.CustomComponentAutocomplete=te;exports.CustomComponentSettings=Et;exports.DefaultReactComponentScriptTemplate=Re;exports.DefaultWebComponentScriptTemplate=_e;exports.ParametersConfig=ce;exports.PropertiesConfig=Oe;exports.PropertyValueField=L;
|
package/lib/cjs/site-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/site-state-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/site-state-CeQEnrvX.js");require("@blocklet/pages-kit/utils/property");require("@blocklet/pages-kit/utils/route");require("@blocklet/sdk/lib/component");require("@blocklet/sdk/lib/config");require("@reactivedata/reactive");require("@syncedstore/core");require("crypto");require("fs");require("glob");require("lib0/decoding");require("lib0/encoding");require("lodash/cloneDeep");require("lodash/debounce");require("lodash/get");require("lodash/isEmpty");require("lodash/pick");require("lodash/set");require("lodash/union");require("lru-cache");require("nanoid");require("p-limit");require("path");require("stream/promises");require("tar");require("ufo");require("wait-on");require("y-protocols/awareness");require("y-protocols/sync");require("yaml");require("yjs");const t=require("@blocklet/pages-kit/types/state");exports.PUBLISH_MODES=e.PUBLISH_MODES;exports.SITE_STATE_PATH=e.SITE_STATE_PATH;exports.STATE_MODES=e.STATE_MODES;exports.default=e.SiteState;exports.downloadAsset=e.downloadAsset;exports.downloadAssets=e.downloadAssets;exports.fromPackage=e.fromPackage;exports.getResourceStates=e.getResourceStates;exports.initPackResourceStates=e.initPackResourceStates;exports.mergeState=e.mergeState;exports.nextId=e.nextId;exports.toPackage=e.toPackage;exports.triggerReloadAllProjectResource=e.triggerReloadAllProjectResource;Object.keys(t).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>t[r]})});
|
package/lib/cjs/theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),r=require("@arcblock/ux/lib/Config"),m=require("@iconify-icon/react"),x=require("@iconify-icons/tabler/chevron-down"),e=require("@mui/material"),o=require("./chunks/session-BA7Qrcia.js"),p=require("./locales.js"),c=s=>s&&s.__esModule?s:{default:s},b=c(x);var n;const a=((n=window.blocklet)==null?void 0:n.prefix)||"/",u=a.endsWith("/")?`${a}admin`:`${a}/admin`,d={fontSize:"5rem","@media (max-width: 1536px)":{fontSize:"5rem"},"@media (max-width: 1200px)":{fontSize:"4rem"},"@media (max-width: 900px)":{fontSize:"3rem"},"@media (max-width: 600px)":{fontSize:"2rem"}};function l(s){return i.jsx(e.Box,{...s,component:m.Icon,icon:b.default})}const f={typography:{big:{...d},button:{textTransform:"none",WebkitTextTransform:"none"},subtitle1:{fontWeight:600,fontSize:"18px",lineHeight:1.5},subtitle2:{fontSize:"14px",lineHeight:"24px",fontWeight:500,marginBottom:"4px"}},palette:{background:{},action:{}},shape:{borderRadius:8},components:{MuiCssBaseline:{},MuiFormLabel:{styleOverrides:{root:{fontSize:"0.875rem"}}},MuiFormControlLabel:{styleOverrides:{root:{marginLeft:0},label:{fontSize:"0.875rem"}}},MuiInputLabel:{styleOverrides:{root:{fontSize:"0.875rem"}}},MuiRadio:{styleOverrides:{root:{padding:4,[`.${e.svgIconClasses.fontSizeMedium}`]:{fontSize:"1.25rem"},[`.${e.svgIconClasses.fontSizeSmall}`]:{fontSize:"1.125rem"}}}},MuiCheckbox:{styleOverrides:{root:{padding:4,[`.${e.svgIconClasses.fontSizeMedium}`]:{fontSize:"1.25rem"},[`.${e.svgIconClasses.fontSizeSmall}`]:{fontSize:"1.125rem"}}}},MuiSwitch:{styleOverrides:{root:{height:28,width:48,padding:8,[`&.${e.switchClasses.sizeSmall}`]:{height:26,width:40,padding:8}},switchBase:{padding:4}}},MuiAutocomplete:{defaultProps:{popupIcon:i.jsx(l,{fontSize:14})},variants:[{props:{},style:({theme:s})=>s.unstable_sx({[`.${e.autocompleteClasses.inputRoot}`]:{pt:1.5,pb:.25,[`.${e.autocompleteClasses.input}.${e.inputBaseClasses.input}`]:{px:0,pt:.5,pb:.25},[`&.${e.inputBaseClasses.sizeSmall}`]:{[`.${e.autocompleteClasses.input}.${e.inputBaseClasses.input}`]:{px:0,py:0,pb:"1px"}}}})}]},MuiTextField:{defaultProps:{variant:"filled"},variants:[{props:{},style:({theme:s,ownerState:t})=>s.unstable_sx({[`.${e.inputBaseClasses.root}`]:{borderRadius:1,lineHeight:"1.5rem",[`.${e.inputBaseClasses.input}`]:{height:"1.5rem"},[`&.${e.inputClasses.multiline}`]:{pl:0,pr:0,pt:"16px","& .MuiInputBase-inputMultiline":{py:0}}},[`.${e.inputClasses.root}`]:{mt:1.5,[`&.${e.inputBaseClasses.hiddenLabel}`]:{mt:0,pt:0,[`.${e.selectClasses.select}.${e.inputClasses.input}:focus`]:{bgcolor:"transparent"}}},[`.${e.inputLabelClasses.standard}`]:{transform:"translate(0px, 18px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(0px, 15px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(0px, -1px) scale(0.8)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(0px, -1px) scale(0.8)"}}},[`.${e.filledInputClasses.root}`]:{":before,:after":{display:"none"},[`.${e.inputBaseClasses.input}`]:{pb:.5,pt:t!=null&&t.label?2:.5,px:1,":focus":{borderRadius:1},[`&.${e.inputBaseClasses.inputSizeSmall}`]:{pb:.25,pt:t!=null&&t.label?1.25:.25},[`&.${e.inputBaseClasses.inputHiddenLabel}`]:{py:.5,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}},[`.${e.inputLabelClasses.filled}`]:{transform:"translate(8px, 11px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 7px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(8px, 2px) scale(0.8)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 0) scale(0.8)"}}},[`.${e.outlinedInputClasses.root}`]:{[`.${e.inputBaseClasses.input}`]:{py:1.25,px:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:.875},[`&.${e.inputBaseClasses.inputHiddenLabel}`]:{py:.5,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}},[`.${e.inputLabelClasses.outlined}`]:{transform:"translate(8px, 10px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 7px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(16px, -7px) scale(0.8)"}}})}]},MuiInput:{defaultProps:{disableUnderline:!0},variants:[{props:{disableUnderline:!0},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",lineHeight:"1.5rem",[`&.${e.inputBaseClasses.multiline}`]:{py:0},[`.${e.inputBaseClasses.input}`]:{py:.5,height:"1.5rem"},[`&.${e.inputBaseClasses.sizeSmall}`]:{[`.${e.inputBaseClasses.input}`]:{py:"1px"}}})}]},MuiFilledInput:{styleOverrides:{root:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",bgcolor:s.palette.grey[100],"&:hover":{bgcolor:s.palette.grey[100]},"@media (hover: none)":{bgcolor:s.palette.grey[100]}})}},MuiSelect:{styleOverrides:{select:{display:"flex",alignItems:"center",[`.${e.listItemIconClasses.root}`]:{minWidth:20}}},defaultProps:{variant:"filled",IconComponent:l},variants:[{props:{},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",borderRadius:1,lineHeight:"1.5rem",[`&.${e.filledInputClasses.root}`]:{":before,:after":{display:"none"},[`.${e.inputBaseClasses.input}`]:{py:.5,borderRadius:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}},[`&.${e.outlinedInputClasses.root}`]:{[`.${e.inputBaseClasses.input}`]:{py:.5,borderRadius:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}})}]},MuiSlider:{defaultProps:{},variants:[{props:{},style:({theme:s})=>s.unstable_sx({height:3,[`.${e.sliderClasses.track}`]:{borderWidth:0},[`.${e.sliderClasses.thumb}`]:{width:16,height:16},[`&.${e.sliderClasses.sizeSmall}`]:{height:2,[`.${e.sliderClasses.thumb}`]:{width:12,height:12}}})}]},MuiFormHelperText:{styleOverrides:{root:({theme:s})=>s.unstable_sx({mx:1})}},MuiTypography:{variants:[{props:{variant:"body1"},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem"})},{props:{variant:"body2"},style:({theme:s})=>s.unstable_sx({fontSize:"0.75rem"})}]},MuiMenuItem:{styleOverrides:{root:({theme:s})=>s.unstable_sx({padding:"6px 12px",fontSize:"0.875rem",borderRadius:1,".MuiListItemIcon-root":{minWidth:0,mr:1}})}},MuiListItemButton:{styleOverrides:{root:{padding:"6px 12px"}}},MuiList:{styleOverrides:{root:{padding:4}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"0.875rem"}}},MuiDialogTitle:{styleOverrides:{root:({theme:s})=>s.unstable_sx({padding:"16px 24px",borderBottom:`1px solid ${s.palette.divider}`})}},MuiDialogActions:{styleOverrides:{root:({theme:s})=>s.unstable_sx({borderTop:`1px solid ${s.palette.divider}`,padding:"16px 24px"})}},MuiDialogContent:{styleOverrides:{root:{padding:"12px 24px !important"}}},MuiButton:{defaultProps:{size:"small"},styleOverrides:{}}}},C={typography:{big:{...d},button:{textTransform:"none",WebkitTextTransform:"none"}}},$=({children:s})=>i.jsx(r.ConfigProvider,{theme:f,translations:p.translations,fallbackLocale:"en",injectFirst:!0,children:i.jsx(o.SessionProvider,{serviceHost:a,protectedRoutes:[`${u}/*`],children:s})}),g=({children:s})=>i.jsx(r.ConfigProvider,{theme:C,translations:p.translations,fallbackLocale:"en",injectFirst:!0,children:i.jsx(o.SessionProvider,{serviceHost:a,protectedRoutes:[`${u}/*`],children:s})});exports.DashboardProvider=$;exports.PageProvider=g;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),r=require("@arcblock/ux/lib/Config"),m=require("@iconify-icon/react"),x=require("@iconify-icons/tabler/chevron-down"),e=require("@mui/material"),o=require("./chunks/session-BA7Qrcia.js"),p=require("./locales.js"),c=s=>s&&s.__esModule?s:{default:s},b=c(x);var n;const a=((n=window.blocklet)==null?void 0:n.prefix)||"/",u=a.endsWith("/")?`${a}admin`:`${a}/admin`,d={fontSize:"5rem","@media (max-width: 1536px)":{fontSize:"5rem"},"@media (max-width: 1200px)":{fontSize:"4rem"},"@media (max-width: 900px)":{fontSize:"3rem"},"@media (max-width: 600px)":{fontSize:"2rem"}};function l(s){return i.jsx(e.Box,{...s,component:m.Icon,icon:b.default})}const f={typography:{big:{...d},button:{textTransform:"none",WebkitTextTransform:"none"},subtitle1:{fontWeight:600,fontSize:"18px",lineHeight:1.5},subtitle2:{fontSize:"14px",lineHeight:"24px",fontWeight:500,marginBottom:"4px"}},palette:{background:{},action:{}},shape:{borderRadius:8},components:{MuiCssBaseline:{},MuiFormLabel:{styleOverrides:{root:{fontSize:"0.875rem"}}},MuiFormControlLabel:{styleOverrides:{root:{marginLeft:0},label:{fontSize:"0.875rem"}}},MuiInputLabel:{styleOverrides:{root:{fontSize:"0.875rem"}}},MuiRadio:{styleOverrides:{root:{padding:4,[`.${e.svgIconClasses.fontSizeMedium}`]:{fontSize:"1.25rem"},[`.${e.svgIconClasses.fontSizeSmall}`]:{fontSize:"1.125rem"}}}},MuiCheckbox:{styleOverrides:{root:{padding:4,[`.${e.svgIconClasses.fontSizeMedium}`]:{fontSize:"1.25rem"},[`.${e.svgIconClasses.fontSizeSmall}`]:{fontSize:"1.125rem"}}}},MuiSwitch:{styleOverrides:{root:{height:28,width:48,padding:8,[`&.${e.switchClasses.sizeSmall}`]:{height:26,width:40,padding:8}},switchBase:{padding:4}}},MuiAutocomplete:{defaultProps:{popupIcon:i.jsx(l,{fontSize:14})},variants:[{props:{},style:({theme:s})=>s.unstable_sx({[`.${e.autocompleteClasses.inputRoot}`]:{pt:1.5,pb:.25,[`.${e.autocompleteClasses.input}.${e.inputBaseClasses.input}`]:{px:0,pt:.5,pb:.25},[`&.${e.inputBaseClasses.sizeSmall}`]:{[`.${e.autocompleteClasses.input}.${e.inputBaseClasses.input}`]:{px:0,py:0,pb:"1px"}}}})}]},MuiTextField:{defaultProps:{variant:"filled"},variants:[{props:{},style:({theme:s,ownerState:t})=>s.unstable_sx({[`.${e.inputBaseClasses.root}`]:{borderRadius:1,lineHeight:"1.5rem",[`.${e.inputBaseClasses.input}`]:{height:"1.5rem"},[`&.${e.inputClasses.multiline}`]:{pl:0,pr:0,pt:"16px","& .MuiInputBase-inputMultiline":{py:0}}},[`.${e.inputClasses.root}`]:{mt:1.5,[`&.${e.inputBaseClasses.hiddenLabel}`]:{mt:0,pt:0,[`.${e.selectClasses.select}.${e.inputClasses.input}:focus`]:{bgcolor:"transparent"}}},[`.${e.inputLabelClasses.standard}`]:{transform:"translate(0px, 18px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(0px, 15px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(0px, -1px) scale(0.8)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(0px, -1px) scale(0.8)"}}},[`.${e.filledInputClasses.root}`]:{":before,:after":{display:"none"},[`.${e.inputBaseClasses.input}`]:{pb:.5,pt:t!=null&&t.label?2:.5,px:1,":focus":{borderRadius:1},[`&.${e.inputBaseClasses.inputSizeSmall}`]:{pb:.25,pt:t!=null&&t.label?1.25:.25,...t!=null&&t.multiline?{pt:0}:{}},[`&.${e.inputBaseClasses.inputHiddenLabel}`]:{py:.5,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}},[`.${e.inputLabelClasses.filled}`]:{transform:"translate(8px, 11px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 7px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(8px, 2px) scale(0.8)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 0) scale(0.8)"}}},[`.${e.outlinedInputClasses.root}`]:{[`.${e.inputBaseClasses.input}`]:{py:1.25,px:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:.875},[`&.${e.inputBaseClasses.inputHiddenLabel}`]:{py:.5,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}},[`.${e.inputLabelClasses.outlined}`]:{transform:"translate(8px, 10px) scale(1)",[`&.${e.inputLabelClasses.sizeSmall}`]:{transform:"translate(8px, 7px) scale(1)"},[`&.${e.inputLabelClasses.shrink}`]:{transform:"translate(16px, -7px) scale(0.8)"}}})}]},MuiInput:{defaultProps:{disableUnderline:!0},variants:[{props:{disableUnderline:!0},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",lineHeight:"1.5rem",[`&.${e.inputBaseClasses.multiline}`]:{py:0},[`.${e.inputBaseClasses.input}`]:{py:.5,height:"1.5rem"},[`&.${e.inputBaseClasses.sizeSmall}`]:{[`.${e.inputBaseClasses.input}`]:{py:"1px"}}})}]},MuiFilledInput:{styleOverrides:{root:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",bgcolor:s.palette.grey[100],"&:hover":{bgcolor:s.palette.grey[100]},"@media (hover: none)":{bgcolor:s.palette.grey[100]}})}},MuiSelect:{styleOverrides:{select:{display:"flex",alignItems:"center",[`.${e.listItemIconClasses.root}`]:{minWidth:20}}},defaultProps:{variant:"filled",IconComponent:l},variants:[{props:{},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem",borderRadius:1,lineHeight:"1.5rem",[`&.${e.filledInputClasses.root}`]:{":before,:after":{display:"none"},[`.${e.inputBaseClasses.input}`]:{py:.5,borderRadius:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}},[`&.${e.outlinedInputClasses.root}`]:{[`.${e.inputBaseClasses.input}`]:{py:.5,borderRadius:1,[`&.${e.inputBaseClasses.inputSizeSmall}`]:{py:"1px"}}}})}]},MuiSlider:{defaultProps:{},variants:[{props:{},style:({theme:s})=>s.unstable_sx({height:3,[`.${e.sliderClasses.track}`]:{borderWidth:0},[`.${e.sliderClasses.thumb}`]:{width:16,height:16},[`&.${e.sliderClasses.sizeSmall}`]:{height:2,[`.${e.sliderClasses.thumb}`]:{width:12,height:12}}})}]},MuiFormHelperText:{styleOverrides:{root:({theme:s})=>s.unstable_sx({mx:1})}},MuiTypography:{variants:[{props:{variant:"body1"},style:({theme:s})=>s.unstable_sx({fontSize:"0.875rem"})},{props:{variant:"body2"},style:({theme:s})=>s.unstable_sx({fontSize:"0.75rem"})}]},MuiMenuItem:{styleOverrides:{root:({theme:s})=>s.unstable_sx({padding:"6px 12px",fontSize:"0.875rem",borderRadius:1,".MuiListItemIcon-root":{minWidth:0,mr:1}})}},MuiListItemButton:{styleOverrides:{root:{padding:"6px 12px"}}},MuiList:{styleOverrides:{root:{padding:4}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"0.875rem"}}},MuiDialogTitle:{styleOverrides:{root:({theme:s})=>s.unstable_sx({padding:"16px 24px",borderBottom:`1px solid ${s.palette.divider}`})}},MuiDialogActions:{styleOverrides:{root:({theme:s})=>s.unstable_sx({borderTop:`1px solid ${s.palette.divider}`,padding:"16px 24px"})}},MuiDialogContent:{styleOverrides:{root:{padding:"12px 24px !important"}}},MuiButton:{defaultProps:{size:"small"},styleOverrides:{}}}},C={typography:{big:{...d},button:{textTransform:"none",WebkitTextTransform:"none"}}},$=({children:s})=>i.jsx(r.ConfigProvider,{theme:f,translations:p.translations,fallbackLocale:"en",injectFirst:!0,children:i.jsx(o.SessionProvider,{serviceHost:a,protectedRoutes:[`${u}/*`],children:s})}),g=({children:s})=>i.jsx(r.ConfigProvider,{theme:C,translations:p.translations,fallbackLocale:"en",injectFirst:!0,children:i.jsx(o.SessionProvider,{serviceHost:a,protectedRoutes:[`${u}/*`],children:s})});exports.DashboardProvider=$;exports.PageProvider=g;
|
package/lib/es/add-component.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as e, jsx as I, Fragment as f } from "react/jsx-runtime";
|
|
2
|
-
import { b as gI, i as q, j as AC, n as _, h as iC, k as oC, l as wC, g as sC } from "./chunks/state-
|
|
2
|
+
import { b as gI, i as q, j as AC, n as _, h as iC, k as oC, l as wC, g as sC } from "./chunks/state-COB6reM7.js";
|
|
3
3
|
import tI from "@arcblock/ux/lib/Empty";
|
|
4
4
|
import { useLocaleContext as T } from "@arcblock/ux/lib/Locale/context";
|
|
5
5
|
import { Icon as $ } from "@iconify-icon/react";
|
|
@@ -7,14 +7,14 @@ import MC from "@mui/icons-material/Check";
|
|
|
7
7
|
import { Box as D, styled as nI, InputLabel as uI, TextField as h, IconButton as G, Autocomplete as XI, FormControl as LC, Select as jC, MenuItem as Q, ListItemText as WI, Typography as k, OutlinedInput as JC, useTheme as OC, CircularProgress as AI, InputAdornment as mC, Button as W, Grid as V, Stack as TI, Input as YI, CssBaseline as SC, Menu as BC, Dialog as MI, DialogTitle as LI, DialogContent as jI, DialogActions as JI, Tabs as yC, Tab as DC, Card as eC, CardMedia as bC, CardContent as NC, Skeleton as KC } from "@mui/material";
|
|
8
8
|
import { useDebounceFn as dC, useRequest as zC, useReactive as v, useUpdate as xI, useThrottleFn as rI, useGetState as cC, useAsyncEffect as hI, useBoolean as ZI } from "ahooks";
|
|
9
9
|
import QI, { useState as F, useEffect as n, useMemo as t, createContext as OI, useContext as FC, useRef as Z, useCallback as Y, createElement as aC, forwardRef as mI, useImperativeHandle as SI } from "react";
|
|
10
|
-
import { I as HC, n as bI, A as lC, b as EC, T as tC, c as nC, B as uC } from "./chunks/array-
|
|
10
|
+
import { I as HC, n as bI, A as lC, b as EC, T as tC, c as nC, B as uC } from "./chunks/array-DM0x2Sjw.js";
|
|
11
11
|
import { styled as iI } from "@arcblock/ux/lib/Theme";
|
|
12
12
|
import "@blocklet/pages-kit/builtin/color-picker";
|
|
13
13
|
import "@blocklet/pages-kit/utils/style";
|
|
14
14
|
import { cx as sI } from "@emotion/css";
|
|
15
15
|
import "lodash/without";
|
|
16
16
|
import { red as XC, pink as WC, purple as TC, indigo as YC, blue as xC, cyan as rC, teal as hC, green as ZC, lime as QC, yellow as kC, amber as RC, orange as pC, brown as UC, grey as fC, blueGrey as GC } from "@mui/material/colors";
|
|
17
|
-
import { C as CI } from "./chunks/config-string-
|
|
17
|
+
import { C as CI } from "./chunks/config-string-Dw6sJMn_.js";
|
|
18
18
|
import VC from "lodash/cloneDeep";
|
|
19
19
|
import { DragIndicator as NI, SearchRounded as vC, Remove as PC, Add as kI, Language as _C, CopyAll as $C, Settings as qC, Delete as Ig } from "@mui/icons-material";
|
|
20
20
|
import { useDrag as Cg, useDrop as gg } from "react-dnd";
|
|
@@ -5,7 +5,7 @@ import te from "lodash/isEmpty";
|
|
|
5
5
|
import tt from "lodash/pick";
|
|
6
6
|
import ee, { createContext as $t, useMemo as L, useCallback as F, useContext as Ct, Fragment as oe, isValidElement as Nt, useState as et, useEffect as H, useRef as lt } from "react";
|
|
7
7
|
import ot from "lodash/keyBy";
|
|
8
|
-
import { f as T, g as I, E as re, i as st, m as ct } from "./state-
|
|
8
|
+
import { f as T, g as I, E as re, i as st, m as ct } from "./state-COB6reM7.js";
|
|
9
9
|
import { AIForm as ht, AIFormResult as ft } from "@blocklet/ai-runtime/components";
|
|
10
10
|
import { deepmerge as ne } from "@mui/utils";
|
|
11
11
|
import { ErrorBoundary as ie } from "react-error-boundary";
|
|
@@ -4,7 +4,7 @@ import { Icon as P } from "@iconify-icon/react";
|
|
|
4
4
|
import { TextField as A, Stack as w, FormControlLabel as F, Switch as L, Box as j, InputAdornment as k } from "@mui/material";
|
|
5
5
|
import { forwardRef as B, useState as D, useEffect as E, useImperativeHandle as U } from "react";
|
|
6
6
|
import { useDebounce as V } from "react-use";
|
|
7
|
-
import { g as x } from "./state-
|
|
7
|
+
import { g as x } from "./state-COB6reM7.js";
|
|
8
8
|
const J = B(function({ showMarkdown: I, markdown: h, onMarkdownChange: n, showUploader: S, value: o, meta: H, onChange: l, ...a }, z) {
|
|
9
9
|
const [e, c] = D("");
|
|
10
10
|
E(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { u as a, S as o, a as s, b as n } from "./state-
|
|
2
|
+
import { u as a, S as o, a as s, b as n } from "./state-COB6reM7.js";
|
|
3
3
|
function d({ children: t }) {
|
|
4
4
|
const r = a();
|
|
5
5
|
return /* @__PURE__ */ e(o, { url: s(r ?? ""), name: "root", waitingSynced: !0, children: /* @__PURE__ */ e(i, { children: t }) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t, jsxs as D } from "react/jsx-runtime";
|
|
2
|
-
import { u as J, d as Q, e as ft, f as ht, g as bt, c as vt } from "./state-
|
|
2
|
+
import { u as J, d as Q, e as ft, f as ht, g as bt, c as vt } from "./state-COB6reM7.js";
|
|
3
3
|
import { useLocaleContext as X } from "@arcblock/ux/lib/Locale/context";
|
|
4
4
|
import Z from "@arcblock/ux/lib/Result";
|
|
5
5
|
import { useHeaderState as yt } from "@blocklet/pages-kit/builtin/page/header";
|
|
@@ -21,7 +21,7 @@ import { Helmet as Ot } from "react-helmet";
|
|
|
21
21
|
import { useSearchParams as ut, Routes as Bt, Route as T, Navigate as Mt, ScrollRestoration as Ft } from "react-router-dom";
|
|
22
22
|
import { useAsync as pt } from "react-use";
|
|
23
23
|
import { joinURL as S } from "ufo";
|
|
24
|
-
import { S as Lt, n as Y, P as $t, a as _t, B as At, g as Dt } from "./array-
|
|
24
|
+
import { S as Lt, n as Y, P as $t, a as _t, B as At, g as Dt } from "./array-DM0x2Sjw.js";
|
|
25
25
|
import { styled as mt, useTheme as Ht } from "@arcblock/ux/lib/Theme";
|
|
26
26
|
import Nt from "@blocklet/ui-react/lib/Footer";
|
|
27
27
|
import "webfontloader";
|
|
@@ -96,7 +96,7 @@ function Qt({ mode: e }) {
|
|
|
96
96
|
}
|
|
97
97
|
return /* @__PURE__ */ t(Xt, { children: ({ state: n }) => /* @__PURE__ */ t(U, { mode: e, state: n }) });
|
|
98
98
|
}
|
|
99
|
-
const Xt = it(() => import("./draft-data-
|
|
99
|
+
const Xt = it(() => import("./draft-data-sTSk4UTm.js"));
|
|
100
100
|
function Zt({
|
|
101
101
|
mode: e,
|
|
102
102
|
children: n
|
|
@@ -439,7 +439,7 @@ function N({
|
|
|
439
439
|
!((j = r.footer) != null && j.hidden) && /* @__PURE__ */ t(Gt, {})
|
|
440
440
|
] });
|
|
441
441
|
}
|
|
442
|
-
const te = it(() => import("./publish-button-
|
|
442
|
+
const te = it(() => import("./publish-button-CKXdANG9.js")), dt = nt(kt)`
|
|
443
443
|
&.sticky {
|
|
444
444
|
position: sticky;
|
|
445
445
|
top: 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t, jsxs as f, Fragment as le } from "react/jsx-runtime";
|
|
2
|
-
import { u as ce, c as de } from "./state-
|
|
2
|
+
import { u as ce, c as de } from "./state-COB6reM7.js";
|
|
3
3
|
import { useLocaleContext as U } from "@arcblock/ux/lib/Locale/context";
|
|
4
4
|
import Q from "@arcblock/ux/lib/Toast";
|
|
5
5
|
import { generateParamCombinations as me } from "@blocklet/pages-kit/utils/route";
|
|
@@ -10,8 +10,8 @@ import { produce as Oe } from "immer";
|
|
|
10
10
|
import ee from "lodash/difference";
|
|
11
11
|
import { useState as j, useMemo as R, useCallback as v, forwardRef as je, useImperativeHandle as ve, useEffect as $, useRef as Te } from "react";
|
|
12
12
|
import { useAsync as Re } from "react-use";
|
|
13
|
-
import { L as ze } from "./home-
|
|
14
|
-
import { p as Le, g as Be } from "./array-
|
|
13
|
+
import { L as ze } from "./home-ClxOpmCx.js";
|
|
14
|
+
import { p as Le, g as Be } from "./array-DM0x2Sjw.js";
|
|
15
15
|
function Ee(s) {
|
|
16
16
|
const [y, w] = j(!1);
|
|
17
17
|
return /* @__PURE__ */ t(
|