@nocobase/client 2.0.0-beta.7 → 2.0.0-beta.8
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/es/index.mjs +29 -23
- package/lib/{index-C3fHjsMw-DskQCehl.js → index-C3fHjsMw-2UyqyjSq.js} +2 -2
- package/lib/index.js +112 -112
- package/package.json +6 -6
package/es/index.mjs
CHANGED
|
@@ -9685,7 +9685,7 @@ function addAppVersion(e, t) {
|
|
|
9685
9685
|
addAppVersion((n = e.properties) == null ? void 0 : n[o], t);
|
|
9686
9686
|
}), e;
|
|
9687
9687
|
}
|
|
9688
|
-
const name = "@nocobase/client", version = "2.0.0-beta.
|
|
9688
|
+
const name = "@nocobase/client", version = "2.0.0-beta.8", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
|
|
9689
9689
|
"@ahooksjs/use-url-state": "3.5.1",
|
|
9690
9690
|
"@ant-design/cssinjs": "^1.11.1",
|
|
9691
9691
|
"@ant-design/icons": "^5.6.1",
|
|
@@ -9708,10 +9708,10 @@ const name = "@nocobase/client", version = "2.0.0-beta.7", license = "AGPL-3.0",
|
|
|
9708
9708
|
"@formily/reactive-react": "^2.2.27",
|
|
9709
9709
|
"@formily/shared": "^2.2.27",
|
|
9710
9710
|
"@formily/validator": "^2.2.27",
|
|
9711
|
-
"@nocobase/evaluators": "2.0.0-beta.
|
|
9712
|
-
"@nocobase/flow-engine": "2.0.0-beta.
|
|
9713
|
-
"@nocobase/sdk": "2.0.0-beta.
|
|
9714
|
-
"@nocobase/utils": "2.0.0-beta.
|
|
9711
|
+
"@nocobase/evaluators": "2.0.0-beta.8",
|
|
9712
|
+
"@nocobase/flow-engine": "2.0.0-beta.8",
|
|
9713
|
+
"@nocobase/sdk": "2.0.0-beta.8",
|
|
9714
|
+
"@nocobase/utils": "2.0.0-beta.8",
|
|
9715
9715
|
"@tanstack/react-table": "^8.21.3",
|
|
9716
9716
|
"@types/tabulator-tables": "^6.2.6",
|
|
9717
9717
|
"acorn-jsx": "^5.3.2",
|
|
@@ -56153,15 +56153,18 @@ const supportTypes = ["string", "bigInt", "integer", "uuid", "uid", "nanoid"], S
|
|
|
56153
56153
|
const { value: t, disabled: o } = e, { targetKey: n, target: r, type: i } = useRecord(), { getCollection: a } = useCollectionManager_deprecated(), [l, c] = useState([]), [u, d] = useState(t || n), p = useForm(), m = useCompile(), h = useField();
|
|
56154
56154
|
return h.required = !0, useEffect(() => {
|
|
56155
56155
|
var g;
|
|
56156
|
-
r
|
|
56157
|
-
|
|
56158
|
-
|
|
56159
|
-
|
|
56160
|
-
|
|
56161
|
-
|
|
56162
|
-
|
|
56163
|
-
|
|
56164
|
-
|
|
56156
|
+
if (r) {
|
|
56157
|
+
const x = castArray(a(r).filterTargetKey);
|
|
56158
|
+
c(
|
|
56159
|
+
(g = a(r).fields) == null ? void 0 : g.filter((b) => b.primaryKey || b.unique ? !0 : x.length === 1 ? x[0] === b.name : i === "hasMany" && supportTypes.includes(b.type)).map((b) => {
|
|
56160
|
+
var y;
|
|
56161
|
+
return {
|
|
56162
|
+
value: b.name,
|
|
56163
|
+
label: m(((y = b == null ? void 0 : b.uiSchema) == null ? void 0 : y.title) || b.title || b.name)
|
|
56164
|
+
};
|
|
56165
|
+
})
|
|
56166
|
+
);
|
|
56167
|
+
}
|
|
56165
56168
|
}, []), /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
56166
56169
|
Select$1,
|
|
56167
56170
|
{
|
|
@@ -56170,15 +56173,18 @@ const supportTypes = ["string", "bigInt", "integer", "uuid", "uid", "nanoid"], S
|
|
|
56170
56173
|
onDropdownVisibleChange: (g) => N(void 0, null, function* () {
|
|
56171
56174
|
var y;
|
|
56172
56175
|
const { target: x, type: b } = p.values;
|
|
56173
|
-
x && g
|
|
56174
|
-
|
|
56175
|
-
|
|
56176
|
-
|
|
56177
|
-
|
|
56178
|
-
|
|
56179
|
-
|
|
56180
|
-
|
|
56181
|
-
|
|
56176
|
+
if (x && g) {
|
|
56177
|
+
const C = castArray(a(x).filterTargetKey);
|
|
56178
|
+
c(
|
|
56179
|
+
(y = a(x).fields) == null ? void 0 : y.filter((v) => v.primaryKey || v.unique ? !0 : C.length === 1 ? C[0] === v.name : b === "hasMany" && supportTypes.includes(v.type)).map((v) => {
|
|
56180
|
+
var S;
|
|
56181
|
+
return {
|
|
56182
|
+
value: v.name,
|
|
56183
|
+
label: m(((S = v == null ? void 0 : v.uiSchema) == null ? void 0 : S.title) || v.title || v.name)
|
|
56184
|
+
};
|
|
56185
|
+
})
|
|
56186
|
+
);
|
|
56187
|
+
}
|
|
56182
56188
|
}),
|
|
56183
56189
|
onChange: (g) => {
|
|
56184
56190
|
var x;
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
width: 100%;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`,items:s},i))})},XM=()=>{const{isInMenu:e}=JM();return{attribute:m.useMemo(()=>e?{}:{role:"menuitem"},[e])}},{Paragraph:QM,Text:ZM}=I.Typography,eA=e=>{const[t,o]=m.useState(!1),n=a.jsx(QM,{style:{display:"flex",marginBottom:0},copyable:{text:e.error.message},children:a.jsxs(ZM,{type:"danger",style:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",display:"inline-block",maxWidth:"200px"},children:["Error: ",e.error.message]})});return a.jsxs(a.Fragment,{children:[a.jsx("div",{onMouseOver:()=>o(!0),children:e.children||n}),a.jsx(I.Modal,{zIndex:1e4,open:t,footer:null,onCancel:()=>o(!1),width:"60%",children:a.jsx(bo,f({},e))})]})},{Paragraph:tA,Text:oA,Link:nA}=I.Typography,Zd=(e,t={})=>{const o=Bd(),[n,l]=m.useState(!1),i=Te();return{loading:n,download:()=>O(void 0,null,function*(){l(!0);try{const r=yield i.request({url:"logger:collect",method:"post",responseType:"blob",data:f({error:{message:e.message,stack:e.stack},location:o},t)}),s=window.URL.createObjectURL(new Blob([r.data],{type:"application/gzip"})),c=document.createElement("a");c.setAttribute("href",s),c.setAttribute("download","logs.tar.gz"),c.click(),c.remove()}catch(r){console.log(r)}l(!1)})}},bo=({error:e})=>{const t=S.useFieldSchema(),{t:o}=K.useTranslation(),{loading:n,download:l}=Zd(e,{schema:t}),i=a.jsxs(K.Trans,{children:["This is likely a NocoBase internals bug. Please open an issue at ",a.jsx(nA,{href:"https://github.com/nocobase/nocobase/issues",target:"_blank",children:"here"})]});return a.jsx("div",{style:{backgroundColor:"white"},children:a.jsx(I.Result,{style:{maxWidth:"60vw",margin:"auto"},status:"error",title:o("Render Failed"),subTitle:i,extra:[a.jsx(I.Button,{type:"primary",href:"https://github.com/nocobase/nocobase/issues",target:"_blank",children:o("Feedback")},"feedback"),a.jsx(I.Button,{loading:n,onClick:l,children:o("Download logs")},"log")],children:a.jsx(tA,{copyable:{text:e.stack},children:a.jsx(oA,{type:"danger",style:{whiteSpace:"pre-line",textAlign:"center"},children:e.stack})})})})};bo.Modal=eA;const Sr=()=>{const e=De.useNavigate(),{t}=K.useTranslation();return a.jsx(I.Result,{status:"404",title:"404",subTitle:t("Sorry, the page you visited does not exist."),extra:a.jsx(I.Button,{onClick:()=>e("/",{replace:!0}),type:"primary",children:"Back Home"})})};class co{constructor(t,o){this.options=t,this.app=o,this.options=t,this.app=o}get pluginManager(){return this.app.pluginManager}get context(){return this.app.context}get flowEngine(){return this.app.flowEngine}get engine(){return this.app.flowEngine}get pm(){return this.app.pm}get router(){return this.app.router}get pluginSettingsManager(){return this.app.pluginSettingsManager}get pluginSettingsRouter(){return this.app.pluginSettingsManager}get schemaInitializerManager(){return this.app.schemaInitializerManager}get schemaSettingsManager(){return this.app.schemaSettingsManager}get dataSourceManager(){return this.app.dataSourceManager}afterAdd(){return O(this,null,function*(){})}beforeLoad(){return O(this,null,function*(){})}load(){return O(this,null,function*(){})}t(t,o={}){var n;return this.app.i18n.t(t,f({ns:(n=this.options)==null?void 0:n.packageName},o))}}const lA={display:"flex",alignItems:"center",gap:4},eu=e=>t=>{const{tooltip:o}=t;return o?a.jsxs("div",{style:lA,children:[a.jsx(e,f({},t)),a.jsx(I.Tooltip,{title:o,children:a.jsx(te.QuestionCircleOutlined,{style:{zIndex:1}})})]}):a.jsx(e,f({},t))},{evaluate:iA}=wd.evaluators.get("formula.js"),Zh=e=>{const t=ct(),o=gt(),[n,l]=m.useState();return m.useEffect(()=>{O(void 0,null,function*(){if(e==null||e===""){l(void 0);return}const{exp:i,scope:r}=yield Jd(e,{variables:t,localVariables:o});try{const s=iA(i,f({now:()=>new Date().toString()},r));l(s)}catch(s){console.error(s)}})},[t.parseVariable,e,o]),n};class kn{constructor(t){A(this,"options"),A(this,"name"),this.options=Object.assign({items:[]},t),this.name=t.name}get items(){return this.options.items}add(t,o){const n=t.split("."),l=n[n.length-1],i=T(f({},o),{name:l}),r=(d,u)=>{const p=this.items.findIndex(h=>h.name===d);p===-1?this.items.push(u):this.items[p]=u};if(n.length===1){r(l,i);return}const s=n.slice(0,-1).join("."),c=this.get(s);if(c){c.children||(c.children=[]);const d=t.replace(`${c.name}.`,""),u=c.children.findIndex(p=>p.name===d);u===-1?c.children.push(i):c.children[u]=i}else r(l,i)}get(t){var o;if(!t)return;const n=t.split(".");let l={children:this.items};for(let i=0;i<n.length;i++){const r=n[i],s=(o=l.children)==null?void 0:o.find(c=>c.name===r);if(s&&(l=s),i===n.length-1)return s}}remove(t){const o=t.split(".");if(o.length===1){const l=this.items.findIndex(i=>i.name===o[0]);l!==-1&&this.items.splice(l,1);return}const n=this.get(o.slice(0,-1).join("."));if(n&&n.children){const l=o[o.length-1],i=n.children.findIndex(r=>r.name===l);i!==-1&&n.children.splice(i,1)}}}var Ze=(e=>(e.group="group",e.page="page",e.flowRoute="flowRoute",e.link="link",e.tabs="tabs",e.flowPage="flowPage",e))(Ze||{});const Ai=Nt("nb-menu-item",e=>{const{componentCls:t}=e;return{[t]:{paddingLeft:`${e.padding}px !important`,paddingRight:`${e.padding}px !important`}}}),rA=()=>{const e=Te();return m.useCallback(t=>O(void 0,null,function*(){yield e.request({method:"POST",url:"/uiSchemas:insert",data:t})}),[e])},aA=()=>{const{t:e}=K.useTranslation(),t=m.useContext(S.SchemaOptionsContext),{theme:o}=Wo(),{componentCls:n,hashId:l}=Ai(),i=Xi(),{createRoute:r}=Bt(),s=rA(),c=m.useCallback(()=>O(void 0,null,function*(){const d=yield Jo(e("Add page"),()=>a.jsx(ht,{scope:t.scope,components:f({},t.components),children:a.jsx(ue.FormLayout,{layout:"vertical",children:a.jsx(To.Provider,{value:bl,children:a.jsx(He,{schema:{properties:{title:{title:e("Menu item title"),required:!0,"x-component":"Input","x-decorator":"FormItem"},icon:{title:e("Icon"),"x-component":"IconPicker","x-decorator":"FormItem"}}}})})})}),o).open({initialValues:{}}),u=ee.uid(),p=ee.uid(),h=ee.uid(),g=ee.uid();yield r({type:Ze.flowPage,title:d.title,icon:d.icon,parentId:i==null?void 0:i.id,schemaUid:p,menuSchemaUid:u,enableTabs:!1,children:[{type:Ze.tabs,schemaUid:h,tabSchemaName:g,hidden:!0}]}),s(z0({pageSchemaUid:p}))}),[r,s,t==null?void 0:t.components,t==null?void 0:t.scope,i==null?void 0:i.id,e,o]);return a.jsx(Mt,{title:e("Modern page (v2)"),onClick:c,className:`${n} ${l}`})};function z0({pageSchemaUid:e}){return{type:"void","x-component":"FlowRoute","x-uid":e}}const _0=()=>{const{t:e}=K.useTranslation(),t=m.useContext(S.SchemaOptionsContext),{theme:o}=Wo(),{componentCls:n,hashId:l}=Ai(),i=Xi(),{createRoute:r}=Bt(),s=m.useCallback(()=>O(void 0,null,function*(){const c=yield Jo(e("Add group"),()=>a.jsx(ht,{scope:t.scope,components:f({},t.components),children:a.jsx(ue.FormLayout,{layout:"vertical",children:a.jsx(To.Provider,{value:bl,children:a.jsx(He,{schema:{properties:{title:{title:e("Menu item title"),"x-component":"Input","x-decorator":"FormItem",required:!0},icon:{title:e("Icon"),"x-component":"IconPicker","x-decorator":"FormItem"}}}})})})}),o).open({initialValues:{}}),{title:d,icon:u}=c,p=ee.uid();yield r({type:Ze.group,title:d,icon:u,parentId:i==null?void 0:i.id,schemaUid:p})}),[t.components,t.scope,e,o]);return a.jsx(Mt,{title:e("Group"),onClick:s,className:`${n} ${l}`})},Ri=e=>{const t=m.useRef(null);return m.useEffect(()=>(t.current&&e!==t.current&&t.current.onUnmount(),t.current=e,e.onMount(),()=>{e.onUnmount()}),[e]),e},ri={},sb=e=>/{{.*?}}/g.test(e),se=({noCache:e}={noCache:!1})=>{const t=m.useContext(S.SchemaOptionsContext),o=m.useContext(S.SchemaExpressionScopeContext);return(n,l)=>{let i=!1,r;if(typeof n=="string"&&n.startsWith("{{")&&(i=!0,r=n),n&&typeof n=="object"&&!m.isValidElement(n)){try{r=JSON.stringify(n)}catch(s){return console.warn("Failed to stringify:",s),n}if(ri[r])return ri[r];i=sb(r)}if(Array.isArray(n)){try{r=JSON.stringify(n)}catch(s){return console.warn("Failed to stringify:",s),n}if(ri[r])return ri[r];i=sb(r)}if(i){const s=f(f(f({},t==null?void 0:t.scope),o),l);if(!r)return S.Schema.compile(n,s);try{return e?S.Schema.compile(n,s):(ri[r]=ri[r]||S.Schema.compile(n,s),ri[r])}catch(c){return console.log("useCompile error",n,c),S.Schema.compile(n,s)}}return n}},jo=(e,t)=>{const{components:o}=m.useContext(S.SchemaOptionsContext);return e?typeof e!="string"?e:L.get(o,e)||t:t},Lm=Symbol("LAZY_COMPONENT_KEY");function _r(e,...t){if(t.length===0){const o=m.lazy(()=>e().then(l=>{const i=l.default;return n[Lm]=i,{default:i}})),n=l=>a.jsx(m.Suspense,{fallback:a.jsx(I.Spin,{}),children:a.jsx(o,f({},l))});return n}return t.reduce((o,n)=>{const l=m.lazy(()=>e().then(i=>{const r=L.get(i,n);return o[n][Lm]=r,{default:r}}));return o[n]=i=>a.jsx(m.Suspense,{fallback:a.jsx(I.Spin,{}),children:a.jsx(l,f({},i))}),o},{})}function K0(e,t){if(e)return e["x-app-version"]||(e["x-app-version"]=t),Object.keys(e.properties||{}).forEach(o=>{var n;K0((n=e.properties)==null?void 0:n[o],t)}),e}const sA="@nocobase/client",cA="2.0.0-beta.7",dA="AGPL-3.0",uA="lib/index.js",pA="es/index.mjs",mA="es/index.d.ts",hA={"@ahooksjs/use-url-state":"3.5.1","@ant-design/cssinjs":"^1.11.1","@ant-design/icons":"^5.6.1","@ant-design/pro-layout":"^7.22.1","@antv/g2plot":"^2.4.18","@budibase/handlebars-helpers":"0.14.0","@codemirror/lang-html":"^6.4.10","@codemirror/theme-one-dark":"^6.1.3","@ctrl/tinycolor":"^3.6.0","@dnd-kit/core":"^6.0.0","@dnd-kit/sortable":"^7.0.0","@emotion/css":"^11.7.1","@formily/antd-v5":"1.2.3","@formily/core":"^2.2.27","@formily/grid":"^2.2.27","@formily/json-schema":"^2.2.27","@formily/path":"^2.2.27","@formily/react":"^2.2.27","@formily/reactive":"^2.2.27","@formily/reactive-react":"^2.2.27","@formily/shared":"^2.2.27","@formily/validator":"^2.2.27","@nocobase/evaluators":"2.0.0-beta.7","@nocobase/flow-engine":"2.0.0-beta.7","@nocobase/sdk":"2.0.0-beta.7","@nocobase/utils":"2.0.0-beta.7","@tanstack/react-table":"^8.21.3","@types/tabulator-tables":"^6.2.6","acorn-jsx":"^5.3.2",ahooks:"^3.7.2",antd:"5.24.2","antd-mobile":"^5.41.1","antd-mobile-icons":"^0.3.0","antd-style":"3.7.1",axios:"^1.7.0","bignumber.js":"^9.1.2",classnames:"^2.3.1",codemirror:"^6.0.2",cronstrue:"^2.11.0","file-saver":"^2.0.5",filesize:"9.0.11",flat:"^5.0.2","html5-qrcode":"^2.3.8",i18next:"^22.4.9","i18next-http-backend":"^2.1.1",ignore:"^5.2.0",json5:"^2.2.3",liquidjs:"^10.0.0",lodash:"4.17.21","lru-cache":"6.0.0","markdown-it":"14.1.0","markdown-it-highlightjs":"3.3.1",mathjs:"^10.6.0",mermaid:"9.4.3",mime:"^4.0.4","mime-match":"^1.0.2","react-beautiful-dnd":"^13.1.0","react-device-detect":"2.2.3","react-drag-listview":"^0.1.9","react-error-boundary":"^4.0.10","react-helmet":"^6.1.0","react-hotkeys-hook":"^3.4.7","react-i18next":"^11.15.1","react-iframe":"~1.8.5","react-image-lightbox":"^5.1.4","react-intersection-observer":"9.14.0","react-js-cron":"^3.1.0","react-quill":"^2.0.0","react-router-dom":"^6.30.1","react-to-print":"^2.14.7","sanitize-html":"2.13.0","tabulator-tables":"^6.3.1","use-deep-compare-effect":"^1.8.1",vditor:"^3.10.3"},gA={react:">=18.0.0","react-dom":">=18.0.0","react-is":">=18.0.0"},vA={"@testing-library/react":"^14.0.0","@types/markdown-it":"14.1.1","@types/markdown-it-highlightjs":"3.3.1","@types/react-big-calendar":"^1.6.4","axios-mock-adapter":"^1.20.0",dumi:"2.2.14","dumi-theme-nocobase":"^0.2.32"},xA={name:sA,version:cA,license:dA,main:uA,module:pA,types:mA,dependencies:hA,peerDependencies:gA,devDependencies:vA};function en(e){return new eg(e)}const U0=e=>{e&&(e["x-uid"]||(e["x-uid"]=ee.uid()),Object.keys(e.properties||{}).forEach(t=>{U0(e.properties[t])}))},Ac=e=>e,fA=(e,t)=>{if(!(!e||!t)){for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==(e==null?void 0:e[o]))return!1;return!0}},hr=(e,t)=>{if(e["x-uid"]&&e["x-uid"]===t["x-uid"])return[null,e.toJSON()];const o=e.toJSON(),n=T(f({},o),{properties:{}});let l=null;const i=(r,s)=>{Object.keys(r||{}).forEach(c=>{const d=r[c];if(d["x-uid"]===t["x-uid"]){l=r[c];return}else s.properties[c]=T(f({},d),{properties:{}}),i(d==null?void 0:d.properties,s.properties[c])})};return i(o.properties,n),[n,l]},bA=e=>e;class eg{constructor(t){A(this,"current"),A(this,"options"),A(this,"appVersion"),A(this,"events",{}),this.options=t,this.current=t.current,this.appVersion=t.appVersion}get model(){return this.options.model}get query(){return this.options.query}loadAPIClientEvents(){const{api:t,t:o=bA}=this.options;if(!t)return;const n=l=>{if(!l)return[];const i=Object.values(l.properties).length,r=[];return l.mapProperties(s=>{s["x-component-props"]=s["x-component-props"]||{},s["x-component-props"].width=100/i,s["x-uid"]&&r.push({"x-uid":s["x-uid"],"x-component-props":s["x-component-props"]})}),l["x-uid"]&&r.length?r:[]};this.on("insertAdjacent",l=>O(this,[l],function*({onSuccess:i,current:r,position:s,schema:c,wrap:d,wrapped:u,removed:p}){var h;let g=[];if((u==null?void 0:u["x-component"])==="Grid.Col"&&(g=g.concat(n(u.parent))),(p==null?void 0:p["x-component"])==="Grid.Col"&&(g=g.concat(n(p.parent))),this.refresh(),!r["x-uid"])return;const v=yield t.request({url:`/uiSchemas:insertAdjacent/${r["x-uid"]}?position=${s}`,method:"post",data:{schema:K0(c,this.appVersion),wrap:d}});g.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:g})),p!=null&&p["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${p["x-uid"]}`,method:"post"})),i==null||i((h=v==null?void 0:v.data)==null?void 0:h.data),I.message.success(o("Saved successfully"),.2)})),this.on("patch",l=>O(this,[l],function*({schema:i}){this.refresh(),i!=null&&i["x-uid"]&&(yield t.request({url:"/uiSchemas:patch",method:"post",data:f({},i)}),I.message.success(o("Saved successfully"),.2))})),this.on("initializeActionContext",l=>O(this,[l],function*({schema:i}){i!=null&&i["x-uid"]&&(yield t.request({url:"/uiSchemas:initializeActionContext",method:"post",data:f({},i)}))})),this.on("batchPatch",l=>O(this,[l],function*({schemas:i}){this.refresh(),yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:i}),I.message.success(o("Saved successfully"),.2)})),this.on("remove",l=>O(this,[l],function*({removed:i}){let r=[];(i==null?void 0:i["x-component"])==="Grid.Col"&&(r=n(i.parent)),this.refresh(),i!=null&&i["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${i["x-uid"]}`,method:"post"}),r.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:r})),I.message.success(o("Saved successfully"),.2))}))}prepareProperty(t){t.type||(t.type="void"),t.name||(t.name=ee.uid()),this.current["x-uid"]&&U0(t)}on(t,o){this.events[t]||(this.events[t]=[]),this.events[t].push(o)}emit(t,...o){return O(this,null,function*(){if(!this.events[t])return;const[n,...l]=o;return Promise.all(this.events[t].map(i=>i.bind(this)(f({current:this.current},n),...l)))})}parentsIn(t){if(!t||!S.Schema.isSchemaInstance(t))return!1;let o=this.current;for(;o!=null&&o.parent;){if(o.parent===t)return!0;o=o.parent}return!1}refresh(t){const{refresh:o}=this.options;return o==null?void 0:o(t)}deepMerge(t){const o={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly"},n={"x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(t).forEach(l=>{o[l]?(this.current[l]=t[l],this.updateModel(o[l],t[l])):n[l]?Object.keys(t[l]).forEach(i=>{Im(this.current,[l,i],t[l][i]),this.updateModel([n[l],i],t[l][i])}):this.current[l]=t[l]}),this.emit("patch",{schema:t})}getSchemaAttribute(t,o){return gi(this.current,t,o)}shallowMerge(t){const o={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly","x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(t).forEach(n=>{this.current[n]=t[n],o[n]&&this.updateModel(o[n],t[n])}),this.emit("patch",{schema:t})}updateModel(t,o){const n=l=>{Im(l,t,o)};this.model&&n(this.model),this.query&&this.query.take(n)}insertAdjacent(t,o,n={}){switch(t){case"beforeBegin":return this.insertBeforeBegin(o,n);case"afterBegin":return this.insertAfterBegin(o,n);case"beforeEnd":return this.insertBeforeEnd(o,n);case"afterEnd":return this.insertAfterEnd(o,n)}}recursiveRemoveIfNoChildren(t,o){if(!t)return;let n=t,l;const i=o==null?void 0:o.breakRemoveOn;for(;n;){if(typeof i=="function"){if(i(n))break}else if(fA(n,i))break;if(Object.keys(n.properties||{}).length>0)break;n.parent&&(l=n.parent.removeProperty(n.name)),n=n.parent}return l}remove(t,o={}){const{breakRemoveOn:n,removeParentsIfNoChildren:l}=o,i=t||this.current;let r=i.parent.removeProperty(i.name);if(l){const s=this.recursiveRemoveIfNoChildren(i.parent,{breakRemoveOn:n});s&&(r=s)}return this.emit("remove",{removed:r})}removeWithoutEmit(t,o={}){const{breakRemoveOn:n,removeParentsIfNoChildren:l}=o,i=t||this.current;let r=i.parent.removeProperty(i.name);if(l){const s=this.recursiveRemoveIfNoChildren(i.parent,{breakRemoveOn:n});s&&(r=s)}return r}insertBeforeBeginOrAfterEnd(t,o={}){if(!S.Schema.isSchemaInstance(this.current)||!S.Schema.isSchemaInstance(t)||this.current.parent!==t.parent)return;let n=0,l=0;return this.current.parent.mapProperties((i,r,s)=>{this.current.name===r&&(l=s),t.name===r&&(n=s)}),n>l?this.insertBeforeBegin(t,o):this.insertAfterEnd(t,o)}insertBeforeBegin(t,o={}){if(!S.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o.onSuccess},{wrap:l=Ac,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(S.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Qo(t));const s={};let c=!1,d=0,u=0;this.current.parent.mapProperties((x,b)=>{b===this.current.name&&(u=d,c=!0,++d),x["x-index"]=d,++d,c&&(s[b]=x,this.current.parent.removeProperty(b))}),this.prepareProperty(t);const p=l(t),h=this.current.parent.addProperty(p.name||ee.uid(),p);h["x-index"]=u,h.parent=this.current.parent,this.current.parent.setProperties(s);const[g,v]=hr(h,t);this.emit("insertAdjacent",f({position:"beforeBegin",schema:v,wrapped:p,wrap:g},n))}insertAfterBegin(t,o={}){if(!S.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o.onSuccess},{wrap:l=Ac,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(S.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Qo(t));const s={};let c=1;this.current.mapProperties((g,v)=>{g["x-index"]=c,++c,s[v]=g}),this.current.properties={},this.prepareProperty(t);const d=l(t),u=this.current.addProperty(d.name||ee.uid(),d);u["x-index"]=0,u.parent=this.current,this.current.setProperties(s);const[p,h]=hr(u,t);this.emit("insertAdjacent",f({position:"afterBegin",schema:h,wrap:p,wrapped:d},n))}insertBeforeEnd(t,o={}){if(!S.Schema.isSchemaInstance(this.current))return;delete t["x-index"];const n={onSuccess:o.onSuccess},{wrap:l=Ac,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(S.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Qo(t));this.prepareProperty(t);const s=l(t),c=this.current.addProperty(s.name||ee.uid(),s);c.parent=this.current;const[d,u]=hr(c,t);return this.emit("insertAdjacent",f({position:"beforeEnd",schema:u,wrap:d,wrapped:s},n))}insertAfterEnd(t,o={}){if(!S.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o==null?void 0:o.onSuccess},{wrap:l=Ac,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;let s=0,c=0,d=!1;const u={};if(this.current.parent.mapProperties((x,b)=>{x["x-index"]=s,b===this.current.name&&(++s,c=s,d=!0),++s,d&&b!==this.current.name&&(u[b]=x,this.current.parent.removeProperty(b))}),S.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i})),t.parent=null}else t&&(t=Qo(t));this.prepareProperty(t);const p=l(t),h=this.current.parent.addProperty(p.name||ee.uid(),p);h.parent=this.current.parent,h["x-index"]=c,this.current.parent.setProperties(u);const[g,v]=hr(h,t);this.emit("insertAdjacent",f({position:"afterEnd",schema:v,wrap:g,wrapped:p},n))}}function tu(){const e=m.useContext(S.SchemaOptionsContext),t=m.useMemo(()=>(e==null?void 0:e.components)||{},[e]);return o=>{if(!o)return null;if(typeof o!="string")return o;const n=gi(t,o);return n||console.error(`[nocobase]: Component "${o}" not found`),n}}function X(){const{designable:e,setDesignable:t,refresh:o,reset:n}=m.useContext(Pt),l=m.useContext(S.SchemaOptionsContext),i=m.useMemo(()=>(l==null?void 0:l.components)||{},[l]),r=m.useMemo(()=>()=>a.jsx(a.Fragment,{}),[]),s=Ct.useUpdate(),c=Ji(),d=Vs(),u=m.useCallback(y=>{o==null||o(),s(),c==null||c(y),d==null||d()},[o,s,c,d]),p=S.useField(),h=S.useFieldSchema(),g=Te(),{t:v}=K.useTranslation(),x=m.useMemo(()=>en({t:v,api:g,refresh:u,current:h,model:p,appVersion:xA.version}),[v,g,u,h,p]);m.useEffect(()=>{x.loadAPIClientEvents()},[x]);const{isMobileLayout:b}=to();return{dn:x,designable:b?!1:e,reset:n,refresh:u,setDesignable:t,DesignableBar:r,findComponent:m.useCallback(y=>{var F;if(!y)return null;if(typeof y!="string")return y;const k=gi(i,y);return(F=k==null?void 0:k[Lm])!=null?F:k},[gi]),on:x.on.bind(x),patch:m.useCallback((y,F)=>{const k=C=>{Object.keys(C).forEach(j=>{const P=C[j];j==="title"&&(p.title=P,h.title=P),j==="x-decorator-props"&&(p.decoratorProps||(p.decoratorProps={}),h["x-decorator-props"]||(h["x-decorator-props"]={}),Object.keys(P).forEach(M=>{p.decoratorProps[M]=P[M],h["x-decorator-props"][M]=P[M]})),j==="x-component-props"&&(p.componentProps||(p.componentProps={}),h["x-component-props"]||(h["x-component-props"]={}),Object.keys(P).forEach(M=>{p.componentProps[M]=P[M],h["x-component-props"][M]=P[M]}))})};if(typeof y=="string"){const C={};return Im(C,y,F),k(C)}k(y),u()},[x]),shallowMerge:m.useCallback(y=>{x.shallowMerge(y)},[x]),deepMerge:m.useCallback(y=>{x.deepMerge(y)},[x]),remove:m.useCallback((y,F)=>{x.remove(y,F)},[x]),insertAdjacent:m.useCallback((y,F,k)=>{x.insertAdjacent(y,F,k)},[x]),insertBeforeBegin:m.useCallback(y=>{x.insertBeforeBegin(y)},[x]),insertAfterBegin:m.useCallback(y=>{x.insertAfterBegin(y)},[x]),insertBeforeEnd:m.useCallback(y=>{x.insertBeforeEnd(y)},[x]),insertAfterEnd:m.useCallback(y=>{x.insertAfterEnd(y)},[x])}}const Vm=()=>null;Vm.isNullComponent=!0;const Yo=()=>{const{designable:e}=X(),t=S.useFieldSchema(),o=m.useMemo(()=>t["x-designer"]||t["x-toolbar"]?t["x-designer"]||t["x-toolbar"]:t["x-settings"]?dn:Vm,[t]),n=jo(o);return e&&n||Vm},H0=e=>{const t=m.useContext(S.SchemaOptionsContext),o=m.useContext(S.SchemaExpressionScopeContext),n=m.useRef();return n.current=o,e.toFieldProps(T(f({},t),{get scope(){return f(f({},t.scope),n.current)}}))};function Ni(){return m.useContext(Pt)}const tg=()=>{var e;const{getCollectionJoinField:t,getCollection:o}=ie(),n=S.useFieldSchema(),{getField:l}=re(),i=l(n.name)||t(n["x-collection-field"]),{t:r}=K.useTranslation(),{label:s}=((e=n["x-component-props"])==null?void 0:e.fieldNames)||{};return m.useMemo(()=>{if(!i||!(i!=null&&i.interface)||!["o2o","oho","obo","o2m","linkTo","m2o","m2m"].includes(i.interface))return;const c=o(i.target);if((c==null?void 0:c.template)==="file")return[{label:r("Record picker"),value:"CollectionField"},{label:r("Select"),value:"AssociationSelect"}];switch(i.interface){case"o2m":return[{label:r("Record picker"),value:"CollectionField"},{label:r("Subtable"),value:"TableField"},{label:r("Select"),value:"AssociationSelect"}];case"m2o":case"m2m":case"linkTo":return[{label:r("Record picker"),value:"CollectionField"},{label:r("Select"),value:"AssociationSelect"}];default:return[{label:r("Record picker"),value:"CollectionField"},{label:r("Subform"),value:"FormField"},{label:r("Select"),value:"AssociationSelect"}]}},[r,i==null?void 0:i.interface,s])},ou=()=>{var e;const t=S.useField(),o=S.useFieldSchema(),n=ve(),l=Ye(),i=(n==null?void 0:n.getField(o.name))||(l==null?void 0:l.getCollectionField(o["x-collection-field"])),r=se();m.useEffect(()=>{var s;t!=null&&t.title||(t.title=r((s=i==null?void 0:i.uiSchema)==null?void 0:s.title))},[(e=i==null?void 0:i.uiSchema)==null?void 0:e.title])},cb=()=>({}),Yt=(e={})=>{const t=e,{useProps:o=cb}=t,n=ne(t,["useProps"]);let l=o;typeof o!="function"&&(l=cb);const i=l();return f(f({},n),i)};function _l({filterOption:e,onFilterChange:t}){const{parseFilter:o,findVariable:n}=_$(),[l,i]=m.useState({}),[r,s]=m.useState(!!e);return m.useEffect(()=>{if(!e)return;const c=()=>O(this,null,function*(){s(!0);const u=yield o(e);s(!1),i(u),t==null||t(u)});c();const d=L.debounce(c,A0);ut.reaction(()=>de.flatten(e,{breakOn({key:u}){return u.startsWith("$")&&u!=="$and"&&u!=="$or"},transformValue(u){if(!dt(u))return u;const p=Wd(u),h=n(p);let g=null;const v=Gd(u).split(".");return v.forEach((x,b)=>{const y=v.slice(0,b+1).join("."),F=de.getValuesByPath({[p]:(h==null?void 0:h.ctx)||{}},y);L.isEmpty(F)||(g=F)}),g}}),d,{equals:L.isEqual})},[JSON.stringify(e),o,n]),{filter:l,parseVariableLoading:r}}const as=e=>{const t=Dt();if(e)return t},yA=e=>{var t;const{params:o,parseVariableLoading:n}=G0(e),l=as(e.association),i=(t=wt().getDataSource(e.dataSource))==null?void 0:t.collectionManager.getCollection(e.collection);return{params:o,parentRecord:l,parseVariableLoading:n,rowKey:(i==null?void 0:i.filterTargetKey)||"id"}};function G0(e){var t;const o=S.useFieldSchema(),{filter:n,parseVariableLoading:l}=_l({filterOption:(t=e.params)==null?void 0:t.filter});return{params:m.useMemo(()=>{const i=e.params||{},{dragSortBy:r}=(o==null?void 0:o["x-decorator-props"])||{};return e.dragSort&&r&&(i.sort=r),T(f({},i),{filter:n})},[o,n,e.dragSort,e.params]),parseVariableLoading:l}}const W0="__isNewRecord__",og=e=>ut.untracked(()=>!!(e!=null&&e[W0])),nl=e=>{if(!L.isObject(e))throw new Error("markRecordAsNew: record must be an object");return e[W0]=!0,e},SA=()=>{var e;return!!((e=Hn())!=null&&e.loading)},ss=(e,t)=>{const{useLoading:o=SA,displayName:n,SkeletonComponent:l=I.Skeleton}=t||{},i=m.memo(r=>{const s=o(),c=m.useRef(!1),d=m.useDeferredValue(s);return!c.current&&d?a.jsx(l,{}):(c.current=!0,a.jsx(e,f({},r)))});return i.displayName=n||`${e.displayName}(withSkeletonComponent)`||`${e.name}(withSkeletonComponent)`,i},CA=(e,t)=>{const o=n=>(n==null?void 0:n.mode)==="constant"?n.value:null;switch(!0){case[he.Color,he.BackgroundColor,he.TextAlign,he.FontSize,he.FontWeight,he.FontStyle].includes(e):return o(t);default:return null}},FA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield Promise.all(o.filter(r=>!r.disabled).map(r=>O(void 0,null,function*(){return(yield Co({ruleGroup:r.condition,variables:n,localVariables:l,conditionType:r.conditionType},i))?r:null})))).filter(Boolean).map(r=>r.actions).flat()}),kA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield FA({rules:o,variables:n,localVariables:l},i)).map(r=>T(f({},r),{value:CA(r.operator,r.value)}))}),wA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield kA({rules:o,variables:n,localVariables:l},i)).reduce((r,s)=>T(f({},r),{[s.operator]:s.value}),{})});function ng({formValues:e,category:t="default",rules:o,schema:n,form:l}){const[i,r]=m.useState({}),s=S.useFieldSchema(),c=ct(),d=gt({currentForm:{values:e}}),u=n??s,p=o??(u[od[t]]||(u==null?void 0:u.parent[od[t]])),h=ot(),g=m.useCallback(()=>{p&&e&&wA({rules:p,variables:c,localVariables:d},h.jsonLogic).then(v=>{L.isEmpty(v)?r({}):r(v)}).catch(v=>{throw new Error(v.message)})},[c,d,p,e]);return m.useEffect(()=>{if(g(),l){const v=ee.uid();return l.addEffects(v,()=>{Oe.onFormValuesChange(()=>{g()})}),()=>{l.removeEffects(v)}}},[l,g,e]),{valueMap:i}}const Y0=m.memo(({record:e,schema:t,onStyleChange:o})=>{const{valueMap:n}=ng({formValues:e,category:"style",schema:t});return m.useEffect(()=>{o(n)},[o,n]),null});Y0.displayName="GetStyleRules";const PA={opacity:.5},jA={position:"relative"},IA={display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",left:0,right:0,height:"100%",maxHeight:400,zIndex:1e3},TA={display:"none"},lg=m.memo(e=>a.jsxs("div",{style:jA,children:[a.jsx(I.Spin,T(f({},L.omit(e,"children")),{style:e.spinning?IA:TA})),a.jsx("div",{style:e.spinning?PA:null,children:e.children})]}));lg.displayName="HighPerformanceSpin";var Kr=(e=>(e[e.FORM=0]="FORM",e[e.TABLE=1]="TABLE",e[e.TREE=2]="TREE",e[e.COLLAPSE=3]="COLLAPSE",e))(Kr||{});const Zt=(e,t="$and")=>{const o=e.filter(n=>{if(n&&typeof n=="object"&&!Array.isArray(n))return Object.values(n).filter(l=>l!==void 0).length});return o.length===0?{}:o.length===1?o[0]:{[t]:o}},J0=(e,t)=>{var o;return(o=t.associatedFields)==null?void 0:o.filter(n=>e==null?void 0:e.some(l=>l===n.target))},X0=(e,t)=>{var o;return(o=t.foreignKeyFields)==null?void 0:o.filter(n=>e.fields.some(l=>l.type!=="belongsTo"&&l.foreignKey===n.name&&l.target===n.collectionName))},MA=e=>{const{getDataBlocks:t}=Xl(),o=S.useFieldSchema(),n=ve(),{getAllCollectionsInheritChain:l}=t0();if(e===0||e===3)return t().filter(i=>zm(i.collection,n));if(e===1||e===2)return t().filter(i=>{var r,s;return o["x-uid"]!==i.uid&&(zm(i.collection,n)||((r=J0(l(n.name,n.dataSource),i))==null?void 0:r.length)||((s=X0(n,i))==null?void 0:s.length))})},AA=(e,t,o,n)=>(e=de.flatten(e,{breakOn({value:l,path:i}){if(["$match","$notMatch","$anyOf","$noneOf","$childIn","$childNotIn","$dateBetween","$in","$notIn"].includes(t[i]))return!0;const r=o(`${n}.${i}`);if(["datetime","datetimeNoTz","date","unixTimestamp","createdAt","updatedAt"].includes(r==null?void 0:r.interface))return!0;if(r!=null&&r.target){if(Array.isArray(l))return!0;const s=r.targetKey||"id";if(l&&l[s]!=null)return!0}return!1}}),{$and:Object.keys(e).map(l=>{let i=L.get(e,l);const r=o(`${n}.${l}`);return r!=null&&r.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(r.type)&&(i=de.getValuesByPath(i,r.targetKey||"id"),l=`${l}.${r.targetKey||"id"}`,(r==null?void 0:r.interface)==="chinaRegion"&&(i=L.last(i))),!i&&i!==0&&i!==!1?null:{[l]:{[t[l]||"$eq"]:i}}}).filter(Boolean)}),ig=()=>{var e;return((e=ve())==null?void 0:e.fields.filter(t=>Q0(t)))||[]},Q0=e=>["o2o","oho","obo","m2o","createdBy","updatedBy","o2m","m2m","linkTo","chinaRegion","mbm"].includes(e==null?void 0:e.interface),zm=(e,t)=>e.name===t.name&&e.dataSource===t.dataSource,Cr=e=>{for(;e;){if(e["x-filter-targets"])return e["x-decorator"]==="FilterFormBlockProvider";e=e.parent}return!1},nu=m.createContext({});nu.displayName="AssociationFieldContext";const al=e=>{const t=S.useFieldSchema(),{insertAfterBegin:o}=X(),{isMobileLayout:n}=to();return m.useCallback(l=>{n||t.reduceProperties((i,r)=>r["x-component"]==="AssociationField."+e?r:i,null)||o(Qo(l))},[e,t,o,n])};function Tt(){return m.useContext(nu)}function rg(e){var t,o,n,l,i,r,s,c,d,u;const{action:p="list",service:h,useOriginalFilter:g}=e,v=S.useFieldSchema(),x=S.useField(),{getField:b}=re(),{getCollectionJoinField:y}=ie(),F=$e(),{isNew:k}=fo()||{},C=(L.isString((n=(o=(t=v==null?void 0:v["x-component-props"])==null?void 0:t.service)==null?void 0:o.params)==null?void 0:n.filter)?(r=(i=(l=x.componentProps)==null?void 0:l.service)==null?void 0:i.params)==null?void 0:r.filter:(d=(c=(s=v==null?void 0:v["x-component-props"])==null?void 0:s.service)==null?void 0:c.params)==null?void 0:d.filter)||((u=h==null?void 0:h.params)==null?void 0:u.filter),{filter:j}=_l({filterOption:C,onFilterChange:()=>{k&&x.reset()}}),P=m.useMemo(()=>b(v.name)||y(v==null?void 0:v["x-collection-field"]),[v]),M=F==null?void 0:F[P==null?void 0:P.sourceKey],R=m.useMemo(()=>{const N=["oho","o2m"].includes(P==null?void 0:P.interface);return Zt([Zt([N&&!Cr(v)&&P!=null&&P.foreignKey&&!g?{[P.foreignKey]:{$is:null}}:null,j]),N&&M!==void 0&&M!==null&&!Cr(v)&&P!=null&&P.foreignKey&&!g?{[P.foreignKey]:{$eq:M}}:null],"$or")},[P==null?void 0:P.interface,P==null?void 0:P.foreignKey,v,j,M,g]);return m.useMemo(()=>T(f({resource:P==null?void 0:P.target,action:p},h),{params:T(f({},h==null?void 0:h.params),{filter:R})}),[P==null?void 0:P.target,p,R,h])}const Ur=(e={})=>{var t,o,n,l,i;const r=S.useFieldSchema(),s=((l=(n=(o=(t=r["x-component-props"])==null?void 0:t.field)==null?void 0:o.uiSchema)==null?void 0:n["x-component-props"])==null?void 0:l.fieldNames)||((i=r["x-component-props"])==null?void 0:i.fieldNames)||e.fieldNames;return f({label:"label",value:"value"},s)},ld=m.createContext(null);ld.displayName="SubFormContext";const Di=e=>{const t=m.useContext(ld),{value:o,collection:n,fieldSchema:l,parent:i,skip:r}=e.value,s=m.useMemo(()=>L.omitBy({value:o,collection:n,fieldSchema:l,skip:r,parent:i||(t!=null&&t.skip?t.parent:t)},L.isUndefined),[o,n,l,r,i,t]);return a.jsx(ld.Provider,{value:s,children:e.children})},Hr=()=>{const{value:e,collection:t,fieldSchema:o,parent:n}=m.useContext(ld)||{};return{formValue:e,collection:t,fieldSchema:o,parent:n}},cs=e=>{const{t}=K.useTranslation(),o=`nocobase_table_column_settings_${e}`,n=m.useCallback(()=>{try{const r=localStorage.getItem(o);return r?JSON.parse(r):null}catch(r){return console.warn("Failed to parse table column settings from localStorage:",r),null}},[o]),l=m.useCallback(r=>{try{const s=JSON.stringify(r);localStorage.setItem(o,s);const c=new CustomEvent("nocobase-table-settings-changed",{detail:{key:o,tableId:e,settings:r}});window.dispatchEvent(c)}catch(s){console.warn("Failed to save table column settings to localStorage:",s),I.message.error(t("Failed to save table settings"))}},[o,e,t]),i=m.useCallback(()=>{try{localStorage.removeItem(o);const r=new CustomEvent("nocobase-table-settings-changed",{detail:{key:o,tableId:e,settings:null}});window.dispatchEvent(r)}catch(r){console.warn("Failed to clear table column settings from localStorage:",r),I.message.error(t("Failed to clear table settings"))}},[o,e,t]);return{getSettings:n,saveSettings:l,clearSettings:i}},lu=(e,t=!0)=>{const o=S.useFieldSchema(),n=(o==null?void 0:o["x-uid"])||"default",{getSettings:l}=cs(n),[i,r]=m.useState(0);m.useEffect(()=>{const c=d=>{const{key:u,tableId:p}=d.detail;(u.includes(n)||p===n)&&r(h=>h+1)};return window.addEventListener("nocobase-table-settings-changed",c),()=>{window.removeEventListener("nocobase-table-settings-changed",c)}},[n]);const s=m.useMemo(()=>l(),[l,i]);return{columns:m.useMemo(()=>{if(!t||!s||s.length===0)return e;const c=new Map;s.forEach(g=>{c.set(g.key,g)});const d=e.map(g=>{const v=c.get(g.key);if(v){const x=g.columnHidden||!v.visible,b=v.width||g.width,y=v.fixed||g.fixed;return T(f({},g),{columnHidden:x,fixed:y,width:b,_orderIndex:v.order})}return g}),u=[],p=[];d.forEach(g=>{g._orderIndex!==void 0?u.push(g):p.push(g)}),u.sort((g,v)=>(g._orderIndex||0)-(v._orderIndex||0));const h=[...u,...p];return h.forEach(g=>{delete g._orderIndex}),h},[e,s])}},RA=({rows:e=5,columns:t=6})=>{const{token:o}=mt(),n=o.controlHeight*2.06,l=o.controlHeight*1.75,i=m.useMemo(()=>Z.css`
|
|
64
|
+
`,items:s},i))})},XM=()=>{const{isInMenu:e}=JM();return{attribute:m.useMemo(()=>e?{}:{role:"menuitem"},[e])}},{Paragraph:QM,Text:ZM}=I.Typography,eA=e=>{const[t,o]=m.useState(!1),n=a.jsx(QM,{style:{display:"flex",marginBottom:0},copyable:{text:e.error.message},children:a.jsxs(ZM,{type:"danger",style:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",display:"inline-block",maxWidth:"200px"},children:["Error: ",e.error.message]})});return a.jsxs(a.Fragment,{children:[a.jsx("div",{onMouseOver:()=>o(!0),children:e.children||n}),a.jsx(I.Modal,{zIndex:1e4,open:t,footer:null,onCancel:()=>o(!1),width:"60%",children:a.jsx(bo,f({},e))})]})},{Paragraph:tA,Text:oA,Link:nA}=I.Typography,Zd=(e,t={})=>{const o=Bd(),[n,l]=m.useState(!1),i=Te();return{loading:n,download:()=>O(void 0,null,function*(){l(!0);try{const r=yield i.request({url:"logger:collect",method:"post",responseType:"blob",data:f({error:{message:e.message,stack:e.stack},location:o},t)}),s=window.URL.createObjectURL(new Blob([r.data],{type:"application/gzip"})),c=document.createElement("a");c.setAttribute("href",s),c.setAttribute("download","logs.tar.gz"),c.click(),c.remove()}catch(r){console.log(r)}l(!1)})}},bo=({error:e})=>{const t=S.useFieldSchema(),{t:o}=K.useTranslation(),{loading:n,download:l}=Zd(e,{schema:t}),i=a.jsxs(K.Trans,{children:["This is likely a NocoBase internals bug. Please open an issue at ",a.jsx(nA,{href:"https://github.com/nocobase/nocobase/issues",target:"_blank",children:"here"})]});return a.jsx("div",{style:{backgroundColor:"white"},children:a.jsx(I.Result,{style:{maxWidth:"60vw",margin:"auto"},status:"error",title:o("Render Failed"),subTitle:i,extra:[a.jsx(I.Button,{type:"primary",href:"https://github.com/nocobase/nocobase/issues",target:"_blank",children:o("Feedback")},"feedback"),a.jsx(I.Button,{loading:n,onClick:l,children:o("Download logs")},"log")],children:a.jsx(tA,{copyable:{text:e.stack},children:a.jsx(oA,{type:"danger",style:{whiteSpace:"pre-line",textAlign:"center"},children:e.stack})})})})};bo.Modal=eA;const Sr=()=>{const e=De.useNavigate(),{t}=K.useTranslation();return a.jsx(I.Result,{status:"404",title:"404",subTitle:t("Sorry, the page you visited does not exist."),extra:a.jsx(I.Button,{onClick:()=>e("/",{replace:!0}),type:"primary",children:"Back Home"})})};class co{constructor(t,o){this.options=t,this.app=o,this.options=t,this.app=o}get pluginManager(){return this.app.pluginManager}get context(){return this.app.context}get flowEngine(){return this.app.flowEngine}get engine(){return this.app.flowEngine}get pm(){return this.app.pm}get router(){return this.app.router}get pluginSettingsManager(){return this.app.pluginSettingsManager}get pluginSettingsRouter(){return this.app.pluginSettingsManager}get schemaInitializerManager(){return this.app.schemaInitializerManager}get schemaSettingsManager(){return this.app.schemaSettingsManager}get dataSourceManager(){return this.app.dataSourceManager}afterAdd(){return O(this,null,function*(){})}beforeLoad(){return O(this,null,function*(){})}load(){return O(this,null,function*(){})}t(t,o={}){var n;return this.app.i18n.t(t,f({ns:(n=this.options)==null?void 0:n.packageName},o))}}const lA={display:"flex",alignItems:"center",gap:4},eu=e=>t=>{const{tooltip:o}=t;return o?a.jsxs("div",{style:lA,children:[a.jsx(e,f({},t)),a.jsx(I.Tooltip,{title:o,children:a.jsx(te.QuestionCircleOutlined,{style:{zIndex:1}})})]}):a.jsx(e,f({},t))},{evaluate:iA}=wd.evaluators.get("formula.js"),Zh=e=>{const t=ct(),o=gt(),[n,l]=m.useState();return m.useEffect(()=>{O(void 0,null,function*(){if(e==null||e===""){l(void 0);return}const{exp:i,scope:r}=yield Jd(e,{variables:t,localVariables:o});try{const s=iA(i,f({now:()=>new Date().toString()},r));l(s)}catch(s){console.error(s)}})},[t.parseVariable,e,o]),n};class kn{constructor(t){A(this,"options"),A(this,"name"),this.options=Object.assign({items:[]},t),this.name=t.name}get items(){return this.options.items}add(t,o){const n=t.split("."),l=n[n.length-1],i=T(f({},o),{name:l}),r=(d,u)=>{const p=this.items.findIndex(h=>h.name===d);p===-1?this.items.push(u):this.items[p]=u};if(n.length===1){r(l,i);return}const s=n.slice(0,-1).join("."),c=this.get(s);if(c){c.children||(c.children=[]);const d=t.replace(`${c.name}.`,""),u=c.children.findIndex(p=>p.name===d);u===-1?c.children.push(i):c.children[u]=i}else r(l,i)}get(t){var o;if(!t)return;const n=t.split(".");let l={children:this.items};for(let i=0;i<n.length;i++){const r=n[i],s=(o=l.children)==null?void 0:o.find(c=>c.name===r);if(s&&(l=s),i===n.length-1)return s}}remove(t){const o=t.split(".");if(o.length===1){const l=this.items.findIndex(i=>i.name===o[0]);l!==-1&&this.items.splice(l,1);return}const n=this.get(o.slice(0,-1).join("."));if(n&&n.children){const l=o[o.length-1],i=n.children.findIndex(r=>r.name===l);i!==-1&&n.children.splice(i,1)}}}var Ze=(e=>(e.group="group",e.page="page",e.flowRoute="flowRoute",e.link="link",e.tabs="tabs",e.flowPage="flowPage",e))(Ze||{});const Ai=Nt("nb-menu-item",e=>{const{componentCls:t}=e;return{[t]:{paddingLeft:`${e.padding}px !important`,paddingRight:`${e.padding}px !important`}}}),rA=()=>{const e=Te();return m.useCallback(t=>O(void 0,null,function*(){yield e.request({method:"POST",url:"/uiSchemas:insert",data:t})}),[e])},aA=()=>{const{t:e}=K.useTranslation(),t=m.useContext(S.SchemaOptionsContext),{theme:o}=Wo(),{componentCls:n,hashId:l}=Ai(),i=Xi(),{createRoute:r}=Bt(),s=rA(),c=m.useCallback(()=>O(void 0,null,function*(){const d=yield Jo(e("Add page"),()=>a.jsx(ht,{scope:t.scope,components:f({},t.components),children:a.jsx(ue.FormLayout,{layout:"vertical",children:a.jsx(To.Provider,{value:bl,children:a.jsx(He,{schema:{properties:{title:{title:e("Menu item title"),required:!0,"x-component":"Input","x-decorator":"FormItem"},icon:{title:e("Icon"),"x-component":"IconPicker","x-decorator":"FormItem"}}}})})})}),o).open({initialValues:{}}),u=ee.uid(),p=ee.uid(),h=ee.uid(),g=ee.uid();yield r({type:Ze.flowPage,title:d.title,icon:d.icon,parentId:i==null?void 0:i.id,schemaUid:p,menuSchemaUid:u,enableTabs:!1,children:[{type:Ze.tabs,schemaUid:h,tabSchemaName:g,hidden:!0}]}),s(z0({pageSchemaUid:p}))}),[r,s,t==null?void 0:t.components,t==null?void 0:t.scope,i==null?void 0:i.id,e,o]);return a.jsx(Mt,{title:e("Modern page (v2)"),onClick:c,className:`${n} ${l}`})};function z0({pageSchemaUid:e}){return{type:"void","x-component":"FlowRoute","x-uid":e}}const _0=()=>{const{t:e}=K.useTranslation(),t=m.useContext(S.SchemaOptionsContext),{theme:o}=Wo(),{componentCls:n,hashId:l}=Ai(),i=Xi(),{createRoute:r}=Bt(),s=m.useCallback(()=>O(void 0,null,function*(){const c=yield Jo(e("Add group"),()=>a.jsx(ht,{scope:t.scope,components:f({},t.components),children:a.jsx(ue.FormLayout,{layout:"vertical",children:a.jsx(To.Provider,{value:bl,children:a.jsx(He,{schema:{properties:{title:{title:e("Menu item title"),"x-component":"Input","x-decorator":"FormItem",required:!0},icon:{title:e("Icon"),"x-component":"IconPicker","x-decorator":"FormItem"}}}})})})}),o).open({initialValues:{}}),{title:d,icon:u}=c,p=ee.uid();yield r({type:Ze.group,title:d,icon:u,parentId:i==null?void 0:i.id,schemaUid:p})}),[t.components,t.scope,e,o]);return a.jsx(Mt,{title:e("Group"),onClick:s,className:`${n} ${l}`})},Ri=e=>{const t=m.useRef(null);return m.useEffect(()=>(t.current&&e!==t.current&&t.current.onUnmount(),t.current=e,e.onMount(),()=>{e.onUnmount()}),[e]),e},ri={},sb=e=>/{{.*?}}/g.test(e),se=({noCache:e}={noCache:!1})=>{const t=m.useContext(S.SchemaOptionsContext),o=m.useContext(S.SchemaExpressionScopeContext);return(n,l)=>{let i=!1,r;if(typeof n=="string"&&n.startsWith("{{")&&(i=!0,r=n),n&&typeof n=="object"&&!m.isValidElement(n)){try{r=JSON.stringify(n)}catch(s){return console.warn("Failed to stringify:",s),n}if(ri[r])return ri[r];i=sb(r)}if(Array.isArray(n)){try{r=JSON.stringify(n)}catch(s){return console.warn("Failed to stringify:",s),n}if(ri[r])return ri[r];i=sb(r)}if(i){const s=f(f(f({},t==null?void 0:t.scope),o),l);if(!r)return S.Schema.compile(n,s);try{return e?S.Schema.compile(n,s):(ri[r]=ri[r]||S.Schema.compile(n,s),ri[r])}catch(c){return console.log("useCompile error",n,c),S.Schema.compile(n,s)}}return n}},jo=(e,t)=>{const{components:o}=m.useContext(S.SchemaOptionsContext);return e?typeof e!="string"?e:L.get(o,e)||t:t},Lm=Symbol("LAZY_COMPONENT_KEY");function _r(e,...t){if(t.length===0){const o=m.lazy(()=>e().then(l=>{const i=l.default;return n[Lm]=i,{default:i}})),n=l=>a.jsx(m.Suspense,{fallback:a.jsx(I.Spin,{}),children:a.jsx(o,f({},l))});return n}return t.reduce((o,n)=>{const l=m.lazy(()=>e().then(i=>{const r=L.get(i,n);return o[n][Lm]=r,{default:r}}));return o[n]=i=>a.jsx(m.Suspense,{fallback:a.jsx(I.Spin,{}),children:a.jsx(l,f({},i))}),o},{})}function K0(e,t){if(e)return e["x-app-version"]||(e["x-app-version"]=t),Object.keys(e.properties||{}).forEach(o=>{var n;K0((n=e.properties)==null?void 0:n[o],t)}),e}const sA="@nocobase/client",cA="2.0.0-beta.8",dA="AGPL-3.0",uA="lib/index.js",pA="es/index.mjs",mA="es/index.d.ts",hA={"@ahooksjs/use-url-state":"3.5.1","@ant-design/cssinjs":"^1.11.1","@ant-design/icons":"^5.6.1","@ant-design/pro-layout":"^7.22.1","@antv/g2plot":"^2.4.18","@budibase/handlebars-helpers":"0.14.0","@codemirror/lang-html":"^6.4.10","@codemirror/theme-one-dark":"^6.1.3","@ctrl/tinycolor":"^3.6.0","@dnd-kit/core":"^6.0.0","@dnd-kit/sortable":"^7.0.0","@emotion/css":"^11.7.1","@formily/antd-v5":"1.2.3","@formily/core":"^2.2.27","@formily/grid":"^2.2.27","@formily/json-schema":"^2.2.27","@formily/path":"^2.2.27","@formily/react":"^2.2.27","@formily/reactive":"^2.2.27","@formily/reactive-react":"^2.2.27","@formily/shared":"^2.2.27","@formily/validator":"^2.2.27","@nocobase/evaluators":"2.0.0-beta.8","@nocobase/flow-engine":"2.0.0-beta.8","@nocobase/sdk":"2.0.0-beta.8","@nocobase/utils":"2.0.0-beta.8","@tanstack/react-table":"^8.21.3","@types/tabulator-tables":"^6.2.6","acorn-jsx":"^5.3.2",ahooks:"^3.7.2",antd:"5.24.2","antd-mobile":"^5.41.1","antd-mobile-icons":"^0.3.0","antd-style":"3.7.1",axios:"^1.7.0","bignumber.js":"^9.1.2",classnames:"^2.3.1",codemirror:"^6.0.2",cronstrue:"^2.11.0","file-saver":"^2.0.5",filesize:"9.0.11",flat:"^5.0.2","html5-qrcode":"^2.3.8",i18next:"^22.4.9","i18next-http-backend":"^2.1.1",ignore:"^5.2.0",json5:"^2.2.3",liquidjs:"^10.0.0",lodash:"4.17.21","lru-cache":"6.0.0","markdown-it":"14.1.0","markdown-it-highlightjs":"3.3.1",mathjs:"^10.6.0",mermaid:"9.4.3",mime:"^4.0.4","mime-match":"^1.0.2","react-beautiful-dnd":"^13.1.0","react-device-detect":"2.2.3","react-drag-listview":"^0.1.9","react-error-boundary":"^4.0.10","react-helmet":"^6.1.0","react-hotkeys-hook":"^3.4.7","react-i18next":"^11.15.1","react-iframe":"~1.8.5","react-image-lightbox":"^5.1.4","react-intersection-observer":"9.14.0","react-js-cron":"^3.1.0","react-quill":"^2.0.0","react-router-dom":"^6.30.1","react-to-print":"^2.14.7","sanitize-html":"2.13.0","tabulator-tables":"^6.3.1","use-deep-compare-effect":"^1.8.1",vditor:"^3.10.3"},gA={react:">=18.0.0","react-dom":">=18.0.0","react-is":">=18.0.0"},vA={"@testing-library/react":"^14.0.0","@types/markdown-it":"14.1.1","@types/markdown-it-highlightjs":"3.3.1","@types/react-big-calendar":"^1.6.4","axios-mock-adapter":"^1.20.0",dumi:"2.2.14","dumi-theme-nocobase":"^0.2.32"},xA={name:sA,version:cA,license:dA,main:uA,module:pA,types:mA,dependencies:hA,peerDependencies:gA,devDependencies:vA};function en(e){return new eg(e)}const U0=e=>{e&&(e["x-uid"]||(e["x-uid"]=ee.uid()),Object.keys(e.properties||{}).forEach(t=>{U0(e.properties[t])}))},Ac=e=>e,fA=(e,t)=>{if(!(!e||!t)){for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==(e==null?void 0:e[o]))return!1;return!0}},hr=(e,t)=>{if(e["x-uid"]&&e["x-uid"]===t["x-uid"])return[null,e.toJSON()];const o=e.toJSON(),n=T(f({},o),{properties:{}});let l=null;const i=(r,s)=>{Object.keys(r||{}).forEach(c=>{const d=r[c];if(d["x-uid"]===t["x-uid"]){l=r[c];return}else s.properties[c]=T(f({},d),{properties:{}}),i(d==null?void 0:d.properties,s.properties[c])})};return i(o.properties,n),[n,l]},bA=e=>e;class eg{constructor(t){A(this,"current"),A(this,"options"),A(this,"appVersion"),A(this,"events",{}),this.options=t,this.current=t.current,this.appVersion=t.appVersion}get model(){return this.options.model}get query(){return this.options.query}loadAPIClientEvents(){const{api:t,t:o=bA}=this.options;if(!t)return;const n=l=>{if(!l)return[];const i=Object.values(l.properties).length,r=[];return l.mapProperties(s=>{s["x-component-props"]=s["x-component-props"]||{},s["x-component-props"].width=100/i,s["x-uid"]&&r.push({"x-uid":s["x-uid"],"x-component-props":s["x-component-props"]})}),l["x-uid"]&&r.length?r:[]};this.on("insertAdjacent",l=>O(this,[l],function*({onSuccess:i,current:r,position:s,schema:c,wrap:d,wrapped:u,removed:p}){var h;let g=[];if((u==null?void 0:u["x-component"])==="Grid.Col"&&(g=g.concat(n(u.parent))),(p==null?void 0:p["x-component"])==="Grid.Col"&&(g=g.concat(n(p.parent))),this.refresh(),!r["x-uid"])return;const v=yield t.request({url:`/uiSchemas:insertAdjacent/${r["x-uid"]}?position=${s}`,method:"post",data:{schema:K0(c,this.appVersion),wrap:d}});g.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:g})),p!=null&&p["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${p["x-uid"]}`,method:"post"})),i==null||i((h=v==null?void 0:v.data)==null?void 0:h.data),I.message.success(o("Saved successfully"),.2)})),this.on("patch",l=>O(this,[l],function*({schema:i}){this.refresh(),i!=null&&i["x-uid"]&&(yield t.request({url:"/uiSchemas:patch",method:"post",data:f({},i)}),I.message.success(o("Saved successfully"),.2))})),this.on("initializeActionContext",l=>O(this,[l],function*({schema:i}){i!=null&&i["x-uid"]&&(yield t.request({url:"/uiSchemas:initializeActionContext",method:"post",data:f({},i)}))})),this.on("batchPatch",l=>O(this,[l],function*({schemas:i}){this.refresh(),yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:i}),I.message.success(o("Saved successfully"),.2)})),this.on("remove",l=>O(this,[l],function*({removed:i}){let r=[];(i==null?void 0:i["x-component"])==="Grid.Col"&&(r=n(i.parent)),this.refresh(),i!=null&&i["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${i["x-uid"]}`,method:"post"}),r.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:r})),I.message.success(o("Saved successfully"),.2))}))}prepareProperty(t){t.type||(t.type="void"),t.name||(t.name=ee.uid()),this.current["x-uid"]&&U0(t)}on(t,o){this.events[t]||(this.events[t]=[]),this.events[t].push(o)}emit(t,...o){return O(this,null,function*(){if(!this.events[t])return;const[n,...l]=o;return Promise.all(this.events[t].map(i=>i.bind(this)(f({current:this.current},n),...l)))})}parentsIn(t){if(!t||!S.Schema.isSchemaInstance(t))return!1;let o=this.current;for(;o!=null&&o.parent;){if(o.parent===t)return!0;o=o.parent}return!1}refresh(t){const{refresh:o}=this.options;return o==null?void 0:o(t)}deepMerge(t){const o={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly"},n={"x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(t).forEach(l=>{o[l]?(this.current[l]=t[l],this.updateModel(o[l],t[l])):n[l]?Object.keys(t[l]).forEach(i=>{Im(this.current,[l,i],t[l][i]),this.updateModel([n[l],i],t[l][i])}):this.current[l]=t[l]}),this.emit("patch",{schema:t})}getSchemaAttribute(t,o){return gi(this.current,t,o)}shallowMerge(t){const o={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly","x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(t).forEach(n=>{this.current[n]=t[n],o[n]&&this.updateModel(o[n],t[n])}),this.emit("patch",{schema:t})}updateModel(t,o){const n=l=>{Im(l,t,o)};this.model&&n(this.model),this.query&&this.query.take(n)}insertAdjacent(t,o,n={}){switch(t){case"beforeBegin":return this.insertBeforeBegin(o,n);case"afterBegin":return this.insertAfterBegin(o,n);case"beforeEnd":return this.insertBeforeEnd(o,n);case"afterEnd":return this.insertAfterEnd(o,n)}}recursiveRemoveIfNoChildren(t,o){if(!t)return;let n=t,l;const i=o==null?void 0:o.breakRemoveOn;for(;n;){if(typeof i=="function"){if(i(n))break}else if(fA(n,i))break;if(Object.keys(n.properties||{}).length>0)break;n.parent&&(l=n.parent.removeProperty(n.name)),n=n.parent}return l}remove(t,o={}){const{breakRemoveOn:n,removeParentsIfNoChildren:l}=o,i=t||this.current;let r=i.parent.removeProperty(i.name);if(l){const s=this.recursiveRemoveIfNoChildren(i.parent,{breakRemoveOn:n});s&&(r=s)}return this.emit("remove",{removed:r})}removeWithoutEmit(t,o={}){const{breakRemoveOn:n,removeParentsIfNoChildren:l}=o,i=t||this.current;let r=i.parent.removeProperty(i.name);if(l){const s=this.recursiveRemoveIfNoChildren(i.parent,{breakRemoveOn:n});s&&(r=s)}return r}insertBeforeBeginOrAfterEnd(t,o={}){if(!S.Schema.isSchemaInstance(this.current)||!S.Schema.isSchemaInstance(t)||this.current.parent!==t.parent)return;let n=0,l=0;return this.current.parent.mapProperties((i,r,s)=>{this.current.name===r&&(l=s),t.name===r&&(n=s)}),n>l?this.insertBeforeBegin(t,o):this.insertAfterEnd(t,o)}insertBeforeBegin(t,o={}){if(!S.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o.onSuccess},{wrap:l=Ac,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(S.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Qo(t));const s={};let c=!1,d=0,u=0;this.current.parent.mapProperties((x,b)=>{b===this.current.name&&(u=d,c=!0,++d),x["x-index"]=d,++d,c&&(s[b]=x,this.current.parent.removeProperty(b))}),this.prepareProperty(t);const p=l(t),h=this.current.parent.addProperty(p.name||ee.uid(),p);h["x-index"]=u,h.parent=this.current.parent,this.current.parent.setProperties(s);const[g,v]=hr(h,t);this.emit("insertAdjacent",f({position:"beforeBegin",schema:v,wrapped:p,wrap:g},n))}insertAfterBegin(t,o={}){if(!S.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o.onSuccess},{wrap:l=Ac,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(S.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Qo(t));const s={};let c=1;this.current.mapProperties((g,v)=>{g["x-index"]=c,++c,s[v]=g}),this.current.properties={},this.prepareProperty(t);const d=l(t),u=this.current.addProperty(d.name||ee.uid(),d);u["x-index"]=0,u.parent=this.current,this.current.setProperties(s);const[p,h]=hr(u,t);this.emit("insertAdjacent",f({position:"afterBegin",schema:h,wrap:p,wrapped:d},n))}insertBeforeEnd(t,o={}){if(!S.Schema.isSchemaInstance(this.current))return;delete t["x-index"];const n={onSuccess:o.onSuccess},{wrap:l=Ac,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(S.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Qo(t));this.prepareProperty(t);const s=l(t),c=this.current.addProperty(s.name||ee.uid(),s);c.parent=this.current;const[d,u]=hr(c,t);return this.emit("insertAdjacent",f({position:"beforeEnd",schema:u,wrap:d,wrapped:s},n))}insertAfterEnd(t,o={}){if(!S.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o==null?void 0:o.onSuccess},{wrap:l=Ac,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;let s=0,c=0,d=!1;const u={};if(this.current.parent.mapProperties((x,b)=>{x["x-index"]=s,b===this.current.name&&(++s,c=s,d=!0),++s,d&&b!==this.current.name&&(u[b]=x,this.current.parent.removeProperty(b))}),S.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i})),t.parent=null}else t&&(t=Qo(t));this.prepareProperty(t);const p=l(t),h=this.current.parent.addProperty(p.name||ee.uid(),p);h.parent=this.current.parent,h["x-index"]=c,this.current.parent.setProperties(u);const[g,v]=hr(h,t);this.emit("insertAdjacent",f({position:"afterEnd",schema:v,wrap:g,wrapped:p},n))}}function tu(){const e=m.useContext(S.SchemaOptionsContext),t=m.useMemo(()=>(e==null?void 0:e.components)||{},[e]);return o=>{if(!o)return null;if(typeof o!="string")return o;const n=gi(t,o);return n||console.error(`[nocobase]: Component "${o}" not found`),n}}function X(){const{designable:e,setDesignable:t,refresh:o,reset:n}=m.useContext(Pt),l=m.useContext(S.SchemaOptionsContext),i=m.useMemo(()=>(l==null?void 0:l.components)||{},[l]),r=m.useMemo(()=>()=>a.jsx(a.Fragment,{}),[]),s=Ct.useUpdate(),c=Ji(),d=Vs(),u=m.useCallback(y=>{o==null||o(),s(),c==null||c(y),d==null||d()},[o,s,c,d]),p=S.useField(),h=S.useFieldSchema(),g=Te(),{t:v}=K.useTranslation(),x=m.useMemo(()=>en({t:v,api:g,refresh:u,current:h,model:p,appVersion:xA.version}),[v,g,u,h,p]);m.useEffect(()=>{x.loadAPIClientEvents()},[x]);const{isMobileLayout:b}=to();return{dn:x,designable:b?!1:e,reset:n,refresh:u,setDesignable:t,DesignableBar:r,findComponent:m.useCallback(y=>{var F;if(!y)return null;if(typeof y!="string")return y;const k=gi(i,y);return(F=k==null?void 0:k[Lm])!=null?F:k},[gi]),on:x.on.bind(x),patch:m.useCallback((y,F)=>{const k=C=>{Object.keys(C).forEach(j=>{const P=C[j];j==="title"&&(p.title=P,h.title=P),j==="x-decorator-props"&&(p.decoratorProps||(p.decoratorProps={}),h["x-decorator-props"]||(h["x-decorator-props"]={}),Object.keys(P).forEach(M=>{p.decoratorProps[M]=P[M],h["x-decorator-props"][M]=P[M]})),j==="x-component-props"&&(p.componentProps||(p.componentProps={}),h["x-component-props"]||(h["x-component-props"]={}),Object.keys(P).forEach(M=>{p.componentProps[M]=P[M],h["x-component-props"][M]=P[M]}))})};if(typeof y=="string"){const C={};return Im(C,y,F),k(C)}k(y),u()},[x]),shallowMerge:m.useCallback(y=>{x.shallowMerge(y)},[x]),deepMerge:m.useCallback(y=>{x.deepMerge(y)},[x]),remove:m.useCallback((y,F)=>{x.remove(y,F)},[x]),insertAdjacent:m.useCallback((y,F,k)=>{x.insertAdjacent(y,F,k)},[x]),insertBeforeBegin:m.useCallback(y=>{x.insertBeforeBegin(y)},[x]),insertAfterBegin:m.useCallback(y=>{x.insertAfterBegin(y)},[x]),insertBeforeEnd:m.useCallback(y=>{x.insertBeforeEnd(y)},[x]),insertAfterEnd:m.useCallback(y=>{x.insertAfterEnd(y)},[x])}}const Vm=()=>null;Vm.isNullComponent=!0;const Yo=()=>{const{designable:e}=X(),t=S.useFieldSchema(),o=m.useMemo(()=>t["x-designer"]||t["x-toolbar"]?t["x-designer"]||t["x-toolbar"]:t["x-settings"]?dn:Vm,[t]),n=jo(o);return e&&n||Vm},H0=e=>{const t=m.useContext(S.SchemaOptionsContext),o=m.useContext(S.SchemaExpressionScopeContext),n=m.useRef();return n.current=o,e.toFieldProps(T(f({},t),{get scope(){return f(f({},t.scope),n.current)}}))};function Ni(){return m.useContext(Pt)}const tg=()=>{var e;const{getCollectionJoinField:t,getCollection:o}=ie(),n=S.useFieldSchema(),{getField:l}=re(),i=l(n.name)||t(n["x-collection-field"]),{t:r}=K.useTranslation(),{label:s}=((e=n["x-component-props"])==null?void 0:e.fieldNames)||{};return m.useMemo(()=>{if(!i||!(i!=null&&i.interface)||!["o2o","oho","obo","o2m","linkTo","m2o","m2m"].includes(i.interface))return;const c=o(i.target);if((c==null?void 0:c.template)==="file")return[{label:r("Record picker"),value:"CollectionField"},{label:r("Select"),value:"AssociationSelect"}];switch(i.interface){case"o2m":return[{label:r("Record picker"),value:"CollectionField"},{label:r("Subtable"),value:"TableField"},{label:r("Select"),value:"AssociationSelect"}];case"m2o":case"m2m":case"linkTo":return[{label:r("Record picker"),value:"CollectionField"},{label:r("Select"),value:"AssociationSelect"}];default:return[{label:r("Record picker"),value:"CollectionField"},{label:r("Subform"),value:"FormField"},{label:r("Select"),value:"AssociationSelect"}]}},[r,i==null?void 0:i.interface,s])},ou=()=>{var e;const t=S.useField(),o=S.useFieldSchema(),n=ve(),l=Ye(),i=(n==null?void 0:n.getField(o.name))||(l==null?void 0:l.getCollectionField(o["x-collection-field"])),r=se();m.useEffect(()=>{var s;t!=null&&t.title||(t.title=r((s=i==null?void 0:i.uiSchema)==null?void 0:s.title))},[(e=i==null?void 0:i.uiSchema)==null?void 0:e.title])},cb=()=>({}),Yt=(e={})=>{const t=e,{useProps:o=cb}=t,n=ne(t,["useProps"]);let l=o;typeof o!="function"&&(l=cb);const i=l();return f(f({},n),i)};function _l({filterOption:e,onFilterChange:t}){const{parseFilter:o,findVariable:n}=_$(),[l,i]=m.useState({}),[r,s]=m.useState(!!e);return m.useEffect(()=>{if(!e)return;const c=()=>O(this,null,function*(){s(!0);const u=yield o(e);s(!1),i(u),t==null||t(u)});c();const d=L.debounce(c,A0);ut.reaction(()=>de.flatten(e,{breakOn({key:u}){return u.startsWith("$")&&u!=="$and"&&u!=="$or"},transformValue(u){if(!dt(u))return u;const p=Wd(u),h=n(p);let g=null;const v=Gd(u).split(".");return v.forEach((x,b)=>{const y=v.slice(0,b+1).join("."),F=de.getValuesByPath({[p]:(h==null?void 0:h.ctx)||{}},y);L.isEmpty(F)||(g=F)}),g}}),d,{equals:L.isEqual})},[JSON.stringify(e),o,n]),{filter:l,parseVariableLoading:r}}const as=e=>{const t=Dt();if(e)return t},yA=e=>{var t;const{params:o,parseVariableLoading:n}=G0(e),l=as(e.association),i=(t=wt().getDataSource(e.dataSource))==null?void 0:t.collectionManager.getCollection(e.collection);return{params:o,parentRecord:l,parseVariableLoading:n,rowKey:(i==null?void 0:i.filterTargetKey)||"id"}};function G0(e){var t;const o=S.useFieldSchema(),{filter:n,parseVariableLoading:l}=_l({filterOption:(t=e.params)==null?void 0:t.filter});return{params:m.useMemo(()=>{const i=e.params||{},{dragSortBy:r}=(o==null?void 0:o["x-decorator-props"])||{};return e.dragSort&&r&&(i.sort=r),T(f({},i),{filter:n})},[o,n,e.dragSort,e.params]),parseVariableLoading:l}}const W0="__isNewRecord__",og=e=>ut.untracked(()=>!!(e!=null&&e[W0])),nl=e=>{if(!L.isObject(e))throw new Error("markRecordAsNew: record must be an object");return e[W0]=!0,e},SA=()=>{var e;return!!((e=Hn())!=null&&e.loading)},ss=(e,t)=>{const{useLoading:o=SA,displayName:n,SkeletonComponent:l=I.Skeleton}=t||{},i=m.memo(r=>{const s=o(),c=m.useRef(!1),d=m.useDeferredValue(s);return!c.current&&d?a.jsx(l,{}):(c.current=!0,a.jsx(e,f({},r)))});return i.displayName=n||`${e.displayName}(withSkeletonComponent)`||`${e.name}(withSkeletonComponent)`,i},CA=(e,t)=>{const o=n=>(n==null?void 0:n.mode)==="constant"?n.value:null;switch(!0){case[he.Color,he.BackgroundColor,he.TextAlign,he.FontSize,he.FontWeight,he.FontStyle].includes(e):return o(t);default:return null}},FA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield Promise.all(o.filter(r=>!r.disabled).map(r=>O(void 0,null,function*(){return(yield Co({ruleGroup:r.condition,variables:n,localVariables:l,conditionType:r.conditionType},i))?r:null})))).filter(Boolean).map(r=>r.actions).flat()}),kA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield FA({rules:o,variables:n,localVariables:l},i)).map(r=>T(f({},r),{value:CA(r.operator,r.value)}))}),wA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield kA({rules:o,variables:n,localVariables:l},i)).reduce((r,s)=>T(f({},r),{[s.operator]:s.value}),{})});function ng({formValues:e,category:t="default",rules:o,schema:n,form:l}){const[i,r]=m.useState({}),s=S.useFieldSchema(),c=ct(),d=gt({currentForm:{values:e}}),u=n??s,p=o??(u[od[t]]||(u==null?void 0:u.parent[od[t]])),h=ot(),g=m.useCallback(()=>{p&&e&&wA({rules:p,variables:c,localVariables:d},h.jsonLogic).then(v=>{L.isEmpty(v)?r({}):r(v)}).catch(v=>{throw new Error(v.message)})},[c,d,p,e]);return m.useEffect(()=>{if(g(),l){const v=ee.uid();return l.addEffects(v,()=>{Oe.onFormValuesChange(()=>{g()})}),()=>{l.removeEffects(v)}}},[l,g,e]),{valueMap:i}}const Y0=m.memo(({record:e,schema:t,onStyleChange:o})=>{const{valueMap:n}=ng({formValues:e,category:"style",schema:t});return m.useEffect(()=>{o(n)},[o,n]),null});Y0.displayName="GetStyleRules";const PA={opacity:.5},jA={position:"relative"},IA={display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",left:0,right:0,height:"100%",maxHeight:400,zIndex:1e3},TA={display:"none"},lg=m.memo(e=>a.jsxs("div",{style:jA,children:[a.jsx(I.Spin,T(f({},L.omit(e,"children")),{style:e.spinning?IA:TA})),a.jsx("div",{style:e.spinning?PA:null,children:e.children})]}));lg.displayName="HighPerformanceSpin";var Kr=(e=>(e[e.FORM=0]="FORM",e[e.TABLE=1]="TABLE",e[e.TREE=2]="TREE",e[e.COLLAPSE=3]="COLLAPSE",e))(Kr||{});const Zt=(e,t="$and")=>{const o=e.filter(n=>{if(n&&typeof n=="object"&&!Array.isArray(n))return Object.values(n).filter(l=>l!==void 0).length});return o.length===0?{}:o.length===1?o[0]:{[t]:o}},J0=(e,t)=>{var o;return(o=t.associatedFields)==null?void 0:o.filter(n=>e==null?void 0:e.some(l=>l===n.target))},X0=(e,t)=>{var o;return(o=t.foreignKeyFields)==null?void 0:o.filter(n=>e.fields.some(l=>l.type!=="belongsTo"&&l.foreignKey===n.name&&l.target===n.collectionName))},MA=e=>{const{getDataBlocks:t}=Xl(),o=S.useFieldSchema(),n=ve(),{getAllCollectionsInheritChain:l}=t0();if(e===0||e===3)return t().filter(i=>zm(i.collection,n));if(e===1||e===2)return t().filter(i=>{var r,s;return o["x-uid"]!==i.uid&&(zm(i.collection,n)||((r=J0(l(n.name,n.dataSource),i))==null?void 0:r.length)||((s=X0(n,i))==null?void 0:s.length))})},AA=(e,t,o,n)=>(e=de.flatten(e,{breakOn({value:l,path:i}){if(["$match","$notMatch","$anyOf","$noneOf","$childIn","$childNotIn","$dateBetween","$in","$notIn"].includes(t[i]))return!0;const r=o(`${n}.${i}`);if(["datetime","datetimeNoTz","date","unixTimestamp","createdAt","updatedAt"].includes(r==null?void 0:r.interface))return!0;if(r!=null&&r.target){if(Array.isArray(l))return!0;const s=r.targetKey||"id";if(l&&l[s]!=null)return!0}return!1}}),{$and:Object.keys(e).map(l=>{let i=L.get(e,l);const r=o(`${n}.${l}`);return r!=null&&r.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(r.type)&&(i=de.getValuesByPath(i,r.targetKey||"id"),l=`${l}.${r.targetKey||"id"}`,(r==null?void 0:r.interface)==="chinaRegion"&&(i=L.last(i))),!i&&i!==0&&i!==!1?null:{[l]:{[t[l]||"$eq"]:i}}}).filter(Boolean)}),ig=()=>{var e;return((e=ve())==null?void 0:e.fields.filter(t=>Q0(t)))||[]},Q0=e=>["o2o","oho","obo","m2o","createdBy","updatedBy","o2m","m2m","linkTo","chinaRegion","mbm"].includes(e==null?void 0:e.interface),zm=(e,t)=>e.name===t.name&&e.dataSource===t.dataSource,Cr=e=>{for(;e;){if(e["x-filter-targets"])return e["x-decorator"]==="FilterFormBlockProvider";e=e.parent}return!1},nu=m.createContext({});nu.displayName="AssociationFieldContext";const al=e=>{const t=S.useFieldSchema(),{insertAfterBegin:o}=X(),{isMobileLayout:n}=to();return m.useCallback(l=>{n||t.reduceProperties((i,r)=>r["x-component"]==="AssociationField."+e?r:i,null)||o(Qo(l))},[e,t,o,n])};function Tt(){return m.useContext(nu)}function rg(e){var t,o,n,l,i,r,s,c,d,u;const{action:p="list",service:h,useOriginalFilter:g}=e,v=S.useFieldSchema(),x=S.useField(),{getField:b}=re(),{getCollectionJoinField:y}=ie(),F=$e(),{isNew:k}=fo()||{},C=(L.isString((n=(o=(t=v==null?void 0:v["x-component-props"])==null?void 0:t.service)==null?void 0:o.params)==null?void 0:n.filter)?(r=(i=(l=x.componentProps)==null?void 0:l.service)==null?void 0:i.params)==null?void 0:r.filter:(d=(c=(s=v==null?void 0:v["x-component-props"])==null?void 0:s.service)==null?void 0:c.params)==null?void 0:d.filter)||((u=h==null?void 0:h.params)==null?void 0:u.filter),{filter:j}=_l({filterOption:C,onFilterChange:()=>{k&&x.reset()}}),P=m.useMemo(()=>b(v.name)||y(v==null?void 0:v["x-collection-field"]),[v]),M=F==null?void 0:F[P==null?void 0:P.sourceKey],R=m.useMemo(()=>{const N=["oho","o2m"].includes(P==null?void 0:P.interface);return Zt([Zt([N&&!Cr(v)&&P!=null&&P.foreignKey&&!g?{[P.foreignKey]:{$is:null}}:null,j]),N&&M!==void 0&&M!==null&&!Cr(v)&&P!=null&&P.foreignKey&&!g?{[P.foreignKey]:{$eq:M}}:null],"$or")},[P==null?void 0:P.interface,P==null?void 0:P.foreignKey,v,j,M,g]);return m.useMemo(()=>T(f({resource:P==null?void 0:P.target,action:p},h),{params:T(f({},h==null?void 0:h.params),{filter:R})}),[P==null?void 0:P.target,p,R,h])}const Ur=(e={})=>{var t,o,n,l,i;const r=S.useFieldSchema(),s=((l=(n=(o=(t=r["x-component-props"])==null?void 0:t.field)==null?void 0:o.uiSchema)==null?void 0:n["x-component-props"])==null?void 0:l.fieldNames)||((i=r["x-component-props"])==null?void 0:i.fieldNames)||e.fieldNames;return f({label:"label",value:"value"},s)},ld=m.createContext(null);ld.displayName="SubFormContext";const Di=e=>{const t=m.useContext(ld),{value:o,collection:n,fieldSchema:l,parent:i,skip:r}=e.value,s=m.useMemo(()=>L.omitBy({value:o,collection:n,fieldSchema:l,skip:r,parent:i||(t!=null&&t.skip?t.parent:t)},L.isUndefined),[o,n,l,r,i,t]);return a.jsx(ld.Provider,{value:s,children:e.children})},Hr=()=>{const{value:e,collection:t,fieldSchema:o,parent:n}=m.useContext(ld)||{};return{formValue:e,collection:t,fieldSchema:o,parent:n}},cs=e=>{const{t}=K.useTranslation(),o=`nocobase_table_column_settings_${e}`,n=m.useCallback(()=>{try{const r=localStorage.getItem(o);return r?JSON.parse(r):null}catch(r){return console.warn("Failed to parse table column settings from localStorage:",r),null}},[o]),l=m.useCallback(r=>{try{const s=JSON.stringify(r);localStorage.setItem(o,s);const c=new CustomEvent("nocobase-table-settings-changed",{detail:{key:o,tableId:e,settings:r}});window.dispatchEvent(c)}catch(s){console.warn("Failed to save table column settings to localStorage:",s),I.message.error(t("Failed to save table settings"))}},[o,e,t]),i=m.useCallback(()=>{try{localStorage.removeItem(o);const r=new CustomEvent("nocobase-table-settings-changed",{detail:{key:o,tableId:e,settings:null}});window.dispatchEvent(r)}catch(r){console.warn("Failed to clear table column settings from localStorage:",r),I.message.error(t("Failed to clear table settings"))}},[o,e,t]);return{getSettings:n,saveSettings:l,clearSettings:i}},lu=(e,t=!0)=>{const o=S.useFieldSchema(),n=(o==null?void 0:o["x-uid"])||"default",{getSettings:l}=cs(n),[i,r]=m.useState(0);m.useEffect(()=>{const c=d=>{const{key:u,tableId:p}=d.detail;(u.includes(n)||p===n)&&r(h=>h+1)};return window.addEventListener("nocobase-table-settings-changed",c),()=>{window.removeEventListener("nocobase-table-settings-changed",c)}},[n]);const s=m.useMemo(()=>l(),[l,i]);return{columns:m.useMemo(()=>{if(!t||!s||s.length===0)return e;const c=new Map;s.forEach(g=>{c.set(g.key,g)});const d=e.map(g=>{const v=c.get(g.key);if(v){const x=g.columnHidden||!v.visible,b=v.width||g.width,y=v.fixed||g.fixed;return T(f({},g),{columnHidden:x,fixed:y,width:b,_orderIndex:v.order})}return g}),u=[],p=[];d.forEach(g=>{g._orderIndex!==void 0?u.push(g):p.push(g)}),u.sort((g,v)=>(g._orderIndex||0)-(v._orderIndex||0));const h=[...u,...p];return h.forEach(g=>{delete g._orderIndex}),h},[e,s])}},RA=({rows:e=5,columns:t=6})=>{const{token:o}=mt(),n=o.controlHeight*2.06,l=o.controlHeight*1.75,i=m.useMemo(()=>Z.css`
|
|
65
65
|
&.skeleton-wrapper {
|
|
66
66
|
width: 100%;
|
|
67
67
|
background: ${o.colorBgContainer};
|
|
@@ -1606,7 +1606,7 @@ ${JSON.stringify(H,null,2)}`)},[d,c,s,l,n,M,t,r,i,v,o,x,k,R,C,j,g]),D=m.useCallb
|
|
|
1606
1606
|
& + a {
|
|
1607
1607
|
margin-left: 0.25em;
|
|
1608
1608
|
}
|
|
1609
|
-
`,children:c("References")}),a.jsx("a",{href:"https://joi.dev/api/",target:"_blank",rel:"noreferrer",children:c("Joi API")})]})]})]})});_x.displayName="FieldValidation";const vd=["string","bigInt","integer","uuid","uid","nanoid"],MU=S.observer(()=>{const e=$e(),{getCollection:t}=ie(),o=e!=null&&e.collectionName?t(e.collectionName):e,n=S.useField();S.useForm();const{getCollectionFields:l}=ie();return a.jsx("div",{children:a.jsx(I.Select,{allowClear:!0,placeholder:"留空时,自动生成 FK 字段",disabled:n.disabled,value:n.value,options:l(o.name).filter(i=>i.type).map(i=>{var r;return{label:((r=i==null?void 0:i.uiSchema)==null?void 0:r.title)||i.name,value:i.name}})})})},{displayName:"SourceForeignKey"}),AU=S.observer(()=>{const e=S.useField(),t=S.useForm(),{getCollectionFields:o}=ie();return a.jsx("div",{children:a.jsx(I.Select,{allowClear:!0,popupMatchSelectWidth:!1,placeholder:"留空时,自动生成 FK 字段",disabled:e.disabled,value:e.value,options:o(t.values.through).filter(n=>n.type).map(n=>{var l;return{label:((l=n==null?void 0:n.uiSchema)==null?void 0:l.title)||n.name,value:n.name}})})})},{displayName:"ThroughForeignKey"}),RU=S.observer(()=>{const e=S.useField(),t=S.useForm(),{getCollectionFields:o}=ie();return a.jsx("div",{children:a.jsx(I.Select,{allowClear:!0,popupMatchSelectWidth:!1,placeholder:"留空时,自动生成 FK 字段",disabled:e.disabled,value:e.value,options:o(t.values.target).filter(n=>n.type).map(n=>{var l;return{label:((l=n==null?void 0:n.uiSchema)==null?void 0:l.title)||n.name,value:n.name}})})})},{displayName:"TargetForeignKey"}),NU=S.observer(()=>{const e=$e(),{getCollection:t}=ie(),o=e!=null&&e.collectionName?t(e.collectionName):e,n=se();return a.jsx("div",{children:a.jsx(I.Select,{disabled:!0,popupMatchSelectWidth:!1,value:o.name,options:[{value:o.name,label:n(o.title)}]})})},{displayName:"SourceCollection"}),DU=S.observer(e=>{var t,o;const{sourceKey:n,collectionName:l,name:i}=$e(),{getCollection:r}=ie(),s=S.useField(),c=se(),d=(t=r(l||i).fields)==null?void 0:t.filter(u=>u.primaryKey||u.unique).map(u=>{var p;return{value:u.name,label:c(((p=u.uiSchema)==null?void 0:p.title)||u.name)}});return m.useEffect(()=>{var u;s.initialValue=n||((u=d==null?void 0:d[0])==null?void 0:u.value)},[]),a.jsx("div",{children:a.jsx(I.Select,{disabled:n,options:d,defaultValue:n||((o=d==null?void 0:d[0])==null?void 0:o.value),onChange:e==null?void 0:e.onChange,showSearch:!0,filterOption:(u,p)=>p==null?void 0:p.label.toLowerCase().includes(u.toLowerCase())})})},{displayName:"SourceKey"}),EU=S.observer(e=>{const{value:t,disabled:o}=e,{targetKey:n,target:l,type:i}=$e(),{getCollection:r}=ie(),[s,c]=m.useState([]),[d,u]=m.useState(t||n),p=S.useForm(),h=se(),g=S.useField();return g.required=!0,m.useEffect(()=>{var v;l&&c((v=r(l).fields)==null?void 0:v.filter(x=>x.primaryKey||x.unique?!0:i==="hasMany"&&vd.includes(x.type)).map(x=>{var b;return{value:x.name,label:h(((b=x==null?void 0:x.uiSchema)==null?void 0:b.title)||x.title||x.name)}}))},[]),a.jsx("div",{children:a.jsx(I.Select,{showSearch:!0,options:s,onDropdownVisibleChange:v=>O(void 0,null,function*(){var x;const{target:b,type:y}=p.values;b&&v&&c((x=r(b).fields)==null?void 0:x.filter(F=>F.primaryKey||F.unique?!0:y==="hasMany"&&vd.includes(F.type)).map(F=>{var k;return{value:F.name,label:h(((k=F==null?void 0:F.uiSchema)==null?void 0:k.title)||F.title||F.name)}}))}),onChange:v=>{var x;(x=e==null?void 0:e.onChange)==null||x.call(e,v),u(v)},value:d,disabled:o,filterOption:(v,x)=>x==null?void 0:x.label.toLowerCase().includes(v.toLowerCase())})})},{displayName:"TargetKey"}),BU=S.observer(e=>{const{disabled:t}=e,[o,n]=m.useState([]),{getCollection:l}=ie(),i=$e(),r=S.useField(),{collectionName:s,target:c,type:d,through:u,name:p,template:h}=i,g=i[r.props.name],v=se(),x=S.useForm(),[b,y]=m.useState(g||(h==="view"?null:r.initialValue)),[F,k]=m.useState([]);return m.useEffect(()=>{var C;const j=["belongsTo"].includes(d)?s:["belongsToMany"].includes(d)?u:c,P=(C=l(j))==null?void 0:C.fields;if(P){const M=P==null?void 0:P.filter(R=>vd.includes(R.type)).map(R=>{var N;return{value:R.name,label:v(((N=R.uiSchema)==null?void 0:N.title)||R.name)}});if(n(M),k(M),g){const R=M.find(N=>N.value===g);y((R==null?void 0:R.label)||g)}}},[d]),a.jsx("div",{children:a.jsx(h==="view"?I.Select:I.AutoComplete,{disabled:t,value:b,options:o,showSearch:!0,onDropdownVisibleChange:C=>O(void 0,null,function*(){var j;const{target:P,type:M,through:R}=x.values,N=["belongsTo"].includes(M)?s||p:["belongsToMany"].includes(M)?R:P;if(N&&C){const D=((j=l(N))==null?void 0:j.fields)||[];n(D==null?void 0:D.filter(q=>vd.includes(q.type)).map(q=>{var $;return{value:q.name,label:v((($=q.uiSchema)==null?void 0:$.title)||q.name)}}))}}),onChange:(C,j)=>{var P;(P=e==null?void 0:e.onChange)==null||P.call(e,C),y(j.label||C)},onSearch:C=>{if(C){const j=C.toLocaleLowerCase(),P=o.filter(M=>M.label.toLocaleLowerCase().includes(j));n(P)}else n(F)}})})},{displayName:"ForeignKey"}),qU=S.observer(e=>{const{disabled:t}=e,o=se(),{getCollections:n}=ie(),[l,i]=m.useState([]),r=S.useField(),s=$e()[r.props.name],[c,d]=m.useState(s||r.initialValue),u=()=>n().filter(p=>!(p.autoCreate&&p.isThrough)).map(p=>({label:o(p.title),value:p.name}));return m.useEffect(()=>{const p=u();if(i(p),s){const h=p.find(g=>g.value===s);d((h==null?void 0:h.label)||s)}},[]),a.jsx("div",{children:a.jsx(I.AutoComplete,{disabled:t,showSearch:!0,popupMatchSelectWidth:!1,value:c,options:l,onSearch:p=>{const h=u();if(p){const g=h.filter(v=>v.label.toLowerCase().includes(p.toLowerCase()));i(g)}else i(h)},onChange:(p,h)=>{var g;(g=e==null?void 0:e.onChange)==null||g.call(e,p),d(h.label||p)}})})},{displayName:"ThroughCollection"}),$U=Object.freeze(Object.defineProperty({__proto__:null,FieldValidation:_x,ForeignKey:BU,SourceCollection:NU,SourceForeignKey:MU,SourceKey:DU,TargetForeignKey:RU,TargetKey:EU,ThroughCollection:qU,ThroughForeignKey:AU},Symbol.toStringTag,{value:"Module"})),OU=(e,t)=>Object.keys(t).map(o=>{const n=t[o];return T(f({},n),{key:o,children:Object.keys(e[o]||{}).filter(l=>!e[o][l].hidden).map(l=>{const i=e[o][l];return f({value:l,label:i.title,name:l},e[o][l])}).sort((l,i)=>l.order-i.order)})}).sort((o,n)=>o.order-n.order),Kx=()=>{const e=wt();return m.useMemo(()=>{const t=e.collectionFieldInterfaceManager.getFieldInterfaces(),o=e.collectionFieldInterfaceManager.getFieldInterfaceGroups(),n=t.reduce((l,i)=>{const r=i.group||"basic";return l[r]||(l[r]=[]),l[r].push(i),l},{});return OU(n,o)},[e])},LU=e=>{var t,o,n;return(n=(o=(t=e.properties)==null?void 0:t.layout)==null?void 0:o.properties)==null?void 0:n.primaryKey};w.observer(e=>{const{schema:t,label:o}=e,n=se(),l=qr.useAntdToken(),i=m.useMemo(()=>({container:{backgroundColor:l.colorFillAlter,marginBottom:l.marginLG,padding:l.paddingSM+l.paddingXXS},title:{color:l.colorText},description:{marginTop:l.marginXS,color:l.colorTextDescription},tag:{background:"none"}}),[l.colorFillAlter,l.colorText,l.colorTextDescription,l.marginLG,l.marginXS,l.paddingSM,l.paddingXXS]);return t?a.jsxs("div",{style:i.container,children:[a.jsxs("div",{style:i.title,children:[o,": ",a.jsx(I.Tag,{style:i.tag,children:n(t.title)})]}),t.description?a.jsx("div",{style:i.description,children:n(t.description)}):null]}):null},{displayName:"Summary"});const VU=({dataSource:e})=>{const{t}=K.useTranslation(),o=[{title:t("Field name"),dataIndex:"name",key:"name"},{title:t("Field database type"),dataIndex:"rawType",key:"rawType"}];return(e==null?void 0:e.length)>0&&a.jsxs(a.Fragment,{children:[a.jsx(I.Divider,{plain:!0,orientation:"left",orientationMargin:"0",children:a.jsx("h3",{children:t("Unknown field type")})}),a.jsx("div",{style:{marginBottom:"15px"},children:t("The following field types are not compatible and do not support output and display")}),a.jsx(I.Table,{columns:o,dataSource:e,pagination:!1})]})},zU=(e,t)=>{const o=[];return e.forEach(n=>{const l=n.children.filter(i=>{var r;return(r=i==null?void 0:i.availableTypes)==null?void 0:r.includes(t)});o.push({label:n.label,key:n.key,children:l})}),o.filter(n=>n.children.length>0)},_U=e=>{const{databaseView:t,viewName:o,sources:n,schema:l}=e,{data:i}=m.useContext(Oi),r=Te(),{t:s}=K.useTranslation(),[c,d]=m.useState(!1),[u,p]=m.useState([]),[h,g]=m.useState([]),[v,x]=m.useState(n),[b,y]=m.useState([]),F=S.useField(),k=S.useForm(),{getCollection:C,getInterface:j,getCollectionFields:P,getInheritCollections:M,getParentCollectionFields:R}=ie(),N=se(),D=Kx().filter(B=>!["relation","systemInfo"].includes(B.key));m.useEffect(()=>{const B=[];v.forEach(E=>{var U;const V=C(E),z=M(E).map(H=>{const G=R(H,E);return{type:"group",key:H,label:s("Parent collection fields")+s(`(${C(H).title})`),children:G.filter(W=>!["hasOne","hasMany","belongsToMany"].includes(W==null?void 0:W.type)).map(W=>{var Q;return{value:W.name,label:s((Q=W.uiSchema)==null?void 0:Q.title)}})}}),_=(U=V.fields.filter(H=>!["obo","oho","m2m","o2m"].includes(H==null?void 0:H.interface)))==null?void 0:U.map(H=>{var G;return{value:H.name,key:H.name,label:s(((G=H.uiSchema)==null?void 0:G.title)||H.name)}}).concat(z);B.push({value:E,label:s(V.title||V.name),children:_})}),g(B)},[v,t]),m.useEffect(()=>{t&&(d(!0),r.resource("dbViews").get({filterByTk:o,schema:l}).then(({data:B})=>{var E,U;if(B){d(!1),p([]);const V=(U=Object.values((E=B==null?void 0:B.data)==null?void 0:E.fields))==null?void 0:U.map(z=>{var _,H;const G=(i==null?void 0:i.data.find(W=>W.name===z.name))||z;if(!(G!=null&&G.uiSchema)){const W=j(z.interface);G.uiSchema=(W==null?void 0:W.default.uiSchema)||{}}return z.source?T(f({},z),{uiSchema:T(f({},L.omit(G.uiSchema,"rawTitle")),{title:((_=G.uiSchema)==null?void 0:_.title)||G.name})}):T(f({},G),{uiSchema:T(f({},L.omit(G.uiSchema,"rawTitle")),{title:((H=G.uiSchema)==null?void 0:H.title)||G.name})})});F.value=V,setTimeout(()=>{var z,_,H;p(V),k.setValuesIn("sources",(z=B.data)==null?void 0:z.sources),x((_=B.data)==null?void 0:_.sources),y((H=B==null?void 0:B.data)==null?void 0:H.unsupportedFields)})}}).catch)},[t]);const q=(B,E)=>{const U=L.cloneDeep(u);U[E]=B,p(U),F.value=U.map(V=>{var z,_,H;const G=typeof V.source=="string"?V.source:(H=(_=(z=V.source)==null?void 0:z.filter)==null?void 0:_.call(z,Boolean))==null?void 0:H.join(".");return T(f({},V),{source:G})})},$=[{title:s("Field name"),dataIndex:"name",key:"name",width:130},{title:s("Field source"),dataIndex:"source",key:"source",width:200,render:(B,E,U)=>a.jsx(I.Cascader,{defaultValue:typeof B=="string"?B==null?void 0:B.split("."):B,allowClear:!0,style:{width:"100%"},options:N(h),onChange:(V,z)=>{var _;const H=(_=P(V==null?void 0:V[0]))==null?void 0:_.find(G=>G.name===L.last(V));q(T(f({},E),{source:V,uiSchema:H==null?void 0:H.uiSchema}),U)},placeholder:s("Select field source")})},{title:s("Field type"),dataIndex:"type",width:140,key:"type",render:(B,E,U)=>{const V=u[U];return V!=null&&V.source||!(V!=null&&V.possibleTypes)?a.jsx(I.Tag,{children:B}):a.jsx(I.Select,{defaultValue:B,popupMatchSelectWidth:!1,style:{width:"100%"},options:(V==null?void 0:V.possibleTypes.map(z=>({label:z,value:z})))||[],onChange:z=>q(T(f({},V),{type:z}),U)})}},{title:s("Field interface"),dataIndex:"interface",key:"interface",width:150,render:(B,E,U)=>{const V=u[U],z=zU(D,V.type);return V.source?B:a.jsx(I.Select,{defaultValue:B,style:{width:"100%"},popupMatchSelectWidth:!1,onChange:_=>{q(T(f({},V),{interface:_}),U)},children:z.map(_=>a.jsx(I.Select.OptGroup,{label:N(_.label),children:_.children.map(H=>a.jsx(I.Select.Option,{value:H.name,children:N(H.label)},H.value))},_.key))})}},{title:s("Field display name"),dataIndex:"title",key:"title",width:180,render:(B,E,U)=>{var V;const z=u[U];return a.jsx(I.Input,{defaultValue:((V=z==null?void 0:z.uiSchema)==null?void 0:V.title)||B,onChange:_=>q(T(f({},z),{uiSchema:T(f({},L.omit(z==null?void 0:z.uiSchema,"rawTitle")),{title:_.target.value})}),U)})}}];return a.jsxs(I.Spin,{spinning:c,children:[u.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"ant-formily-item-label",style:{display:"flex",padding:"0 0 8px"},children:[a.jsx("div",{className:"ant-formily-item-label-content",children:a.jsx("span",{children:a.jsx("label",{children:s("Fields")})})}),a.jsx("span",{className:"ant-formily-item-colon",children:":"})]}),a.jsx(I.Table,{bordered:!0,size:"middle",columns:$,dataSource:u,scroll:{y:300},pagination:!1,rowClassName:"editable-row"},o)]}),a.jsx(VU,{dataSource:b})]})};function KU(e,t){return t.viewName===e.viewName&&t.schema===e.schema&&t.source===e.source}const Bw=m.memo(_U,KU);Bw.displayName="PreviewFields";const UU=["lineString","point","circle","polygon"],HU=e=>{const{databaseView:t,schema:o,viewName:n,fields:l}=e,[i,r]=m.useState([]),[s,c]=m.useState([]),d=se(),[u,p]=m.useState(!1),{getInterface:h,getCollectionFields:g}=ie(),v=Te(),{t:x}=K.useTranslation(),b=S.useForm();m.useEffect(()=>{t&&y()},[n,o]),m.useEffect(()=>{const k=F(l);r(k)},[b.values.fields]);const y=()=>{const k={};b.values.fields.map(C=>{UU.includes(C.type)&&(k[C.name]=C.type)}),p(!0),v.resource("dbViews").query({filterByTk:n,schema:o,fieldTypes:k}).then(({data:C})=>{C&&(p(!1),c((C==null?void 0:C.data)||[]))}).catch},F=k=>{var C;return(C=k.filter(j=>j.source||j.interface))==null?void 0:C.map(j=>{var P,M,R,N,D,q;const $=typeof(j==null?void 0:j.source)=="string"?(P=j==null?void 0:j.source)==null?void 0:P.split("."):j==null?void 0:j.source,B=(R=(M=g($==null?void 0:$[0]))==null?void 0:M.find(V=>V.name===($==null?void 0:$[1])))==null?void 0:R.uiSchema,E=((N=j==null?void 0:j.uiSchema)==null?void 0:N.title)||(B==null?void 0:B.title)||j.name,U=j.source?B:(q=(D=h(j.interface))==null?void 0:D.default)==null?void 0:q.uiSchema;return{title:d(E),dataIndex:j.name,key:j.name,width:200,render:(V,z,_)=>{const H=z[j.name],G={type:"object",properties:{[j.name]:{name:`${j.name}`,"x-component":U&&$?"CollectionField":"Input","x-read-pretty":!0,"x-collection-field":$==null?void 0:$.join("."),default:j.interface==="json"?JSON.stringify(H):H}}};return a.jsx(io,{ellipsis:!0,children:a.jsx(S.RecursionField,{schema:G,name:_,onlyRenderProperties:!0})})}}})};return a.jsx(I.Spin,{spinning:u,children:a.jsxs("div",{style:{marginBottom:22},children:[a.jsxs("div",{className:"ant-formily-item-label",style:{marginTop:24,display:"flex",padding:"0 0 8px"},children:[a.jsx("div",{className:"ant-formily-item-label-content",children:a.jsx("span",{children:a.jsx("label",{children:x("Preview")})})}),a.jsx("span",{className:"ant-formily-item-colon",children:":"})]},n),(i==null?void 0:i.length)>0&&a.jsx(a.Fragment,{children:a.jsx(I.Table,{size:"middle",pagination:!1,bordered:!0,columns:i,dataSource:s,scroll:{x:1e3,y:300}},`${n}-preview`)})]})},"preview")},xd=m.createContext(null);xd.displayName="AsyncDataContext";const qw=e=>{const t=e,{value:o,request:n,children:l}=t,i=ne(t,["value","request","children"]),r=Ue(n,f({},i));return o?a.jsx(xd.Provider,{value:o,children:l}):a.jsx(xd.Provider,{value:r,children:l})},Np=()=>m.useContext(xd),GU=(e,t)=>e.toLowerCase().includes("id")?"id":typeof t=="number"?Number.isInteger(t)?"integer":"number":typeof t=="boolean"?"checkbox":Me(t).isValid()?"datetime":"input",WU=()=>{const e=S.useForm(),{sources:t=[]}=e.values,{t:o}=K.useTranslation(),{getCollection:n,getInheritCollections:l,getParentCollectionFields:i}=ie(),r=[];return t.forEach(s=>{var c;const d=n(s),u=l(s).map(h=>{const g=i(h,s);return{type:"group",key:h,label:o("Parent collection fields")+o(`(${n(h).title})`),children:g.filter(v=>!["hasOne","hasMany","belongsToMany"].includes(v==null?void 0:v.type)).map(v=>{var x;return{value:v.name,label:o((x=v.uiSchema)==null?void 0:x.title)}})}});if(!d)return;const p=(c=d.fields.filter(h=>!["hasOne","hasMany","belongsToMany","belongsTo"].includes(h==null?void 0:h.type)))==null?void 0:c.map(h=>{var g;return{value:h.name,label:o((g=h.uiSchema)==null?void 0:g.title)}});r.push({value:s,label:o(d.title),children:[...p,...u]})}),r},$w=S.observer(()=>{var e,t,o,n;const{t:l}=K.useTranslation(),[i,r]=m.useState([]),{data:s,error:c,loading:d}=Np(),{data:u,fields:p}=s||{},h=S.useField(),{data:g}=m.useContext(Oi),v=se(),{getInterface:x,getCollectionField:b}=ie(),y=Kx(),F=m.useMemo(()=>y.filter(R=>!["relation"].includes(R.key)).map((R,N)=>({key:N,label:v(R.label),options:R.children.map((D,q)=>({value:D.name,key:`${N}-${q}`,label:v(D.label)}))})),[v]),k=WU(),C=m.useRef(x);if(m.useEffect(()=>{var R;const N=new Map;d||(u&&u.length?Object.entries((u==null?void 0:u[0])||{}).forEach(([q,$])=>{var B;const E=p[q],U=GU(q,$),V=(B=C.current(U))==null?void 0:B.default,z=(E==null?void 0:E.uiSchema)||(V==null?void 0:V.uiSchema)||{};N.set(q,{name:q,interface:(E==null?void 0:E.interface)||U,type:(E==null?void 0:E.type)||(V==null?void 0:V.type),source:E==null?void 0:E.source,uiSchema:f({title:q},z)})}):Object.entries(p||{}).forEach(([q,$])=>N.set(q,T(f({name:q,type:"string"},$),{uiSchema:f({title:q},($==null?void 0:$.uiSchema)||{})})))),(R=h.value)!=null&&R.length&&h.value.forEach(q=>{N.has(q.name)&&N.set(q.name,q)});const D=Array.from(N.values());D.length&&(r(D),h.setValue(D))},[d,u,h,p,g]),d)return a.jsx(I.Spin,{});if(!u&&!c)return a.jsx(I.Alert,{showIcon:!0,message:l("Please use a valid SELECT or WITH AS statement")});const j=c;if(j){const R=((n=(o=(t=(e=j==null?void 0:j.response)==null?void 0:e.data)==null?void 0:t.errors)==null?void 0:o.map)==null?void 0:n.call(o,N=>N.message).join(`
|
|
1609
|
+
`,children:c("References")}),a.jsx("a",{href:"https://joi.dev/api/",target:"_blank",rel:"noreferrer",children:c("Joi API")})]})]})]})});_x.displayName="FieldValidation";const vd=["string","bigInt","integer","uuid","uid","nanoid"],MU=S.observer(()=>{const e=$e(),{getCollection:t}=ie(),o=e!=null&&e.collectionName?t(e.collectionName):e,n=S.useField();S.useForm();const{getCollectionFields:l}=ie();return a.jsx("div",{children:a.jsx(I.Select,{allowClear:!0,placeholder:"留空时,自动生成 FK 字段",disabled:n.disabled,value:n.value,options:l(o.name).filter(i=>i.type).map(i=>{var r;return{label:((r=i==null?void 0:i.uiSchema)==null?void 0:r.title)||i.name,value:i.name}})})})},{displayName:"SourceForeignKey"}),AU=S.observer(()=>{const e=S.useField(),t=S.useForm(),{getCollectionFields:o}=ie();return a.jsx("div",{children:a.jsx(I.Select,{allowClear:!0,popupMatchSelectWidth:!1,placeholder:"留空时,自动生成 FK 字段",disabled:e.disabled,value:e.value,options:o(t.values.through).filter(n=>n.type).map(n=>{var l;return{label:((l=n==null?void 0:n.uiSchema)==null?void 0:l.title)||n.name,value:n.name}})})})},{displayName:"ThroughForeignKey"}),RU=S.observer(()=>{const e=S.useField(),t=S.useForm(),{getCollectionFields:o}=ie();return a.jsx("div",{children:a.jsx(I.Select,{allowClear:!0,popupMatchSelectWidth:!1,placeholder:"留空时,自动生成 FK 字段",disabled:e.disabled,value:e.value,options:o(t.values.target).filter(n=>n.type).map(n=>{var l;return{label:((l=n==null?void 0:n.uiSchema)==null?void 0:l.title)||n.name,value:n.name}})})})},{displayName:"TargetForeignKey"}),NU=S.observer(()=>{const e=$e(),{getCollection:t}=ie(),o=e!=null&&e.collectionName?t(e.collectionName):e,n=se();return a.jsx("div",{children:a.jsx(I.Select,{disabled:!0,popupMatchSelectWidth:!1,value:o.name,options:[{value:o.name,label:n(o.title)}]})})},{displayName:"SourceCollection"}),DU=S.observer(e=>{var t,o;const{sourceKey:n,collectionName:l,name:i}=$e(),{getCollection:r}=ie(),s=S.useField(),c=se(),d=(t=r(l||i).fields)==null?void 0:t.filter(u=>u.primaryKey||u.unique).map(u=>{var p;return{value:u.name,label:c(((p=u.uiSchema)==null?void 0:p.title)||u.name)}});return m.useEffect(()=>{var u;s.initialValue=n||((u=d==null?void 0:d[0])==null?void 0:u.value)},[]),a.jsx("div",{children:a.jsx(I.Select,{disabled:n,options:d,defaultValue:n||((o=d==null?void 0:d[0])==null?void 0:o.value),onChange:e==null?void 0:e.onChange,showSearch:!0,filterOption:(u,p)=>p==null?void 0:p.label.toLowerCase().includes(u.toLowerCase())})})},{displayName:"SourceKey"}),EU=S.observer(e=>{const{value:t,disabled:o}=e,{targetKey:n,target:l,type:i}=$e(),{getCollection:r}=ie(),[s,c]=m.useState([]),[d,u]=m.useState(t||n),p=S.useForm(),h=se(),g=S.useField();return g.required=!0,m.useEffect(()=>{var v;if(l){const x=L.castArray(r(l).filterTargetKey);c((v=r(l).fields)==null?void 0:v.filter(b=>b.primaryKey||b.unique?!0:x.length===1?x[0]===b.name:i==="hasMany"&&vd.includes(b.type)).map(b=>{var y;return{value:b.name,label:h(((y=b==null?void 0:b.uiSchema)==null?void 0:y.title)||b.title||b.name)}}))}},[]),a.jsx("div",{children:a.jsx(I.Select,{showSearch:!0,options:s,onDropdownVisibleChange:v=>O(void 0,null,function*(){var x;const{target:b,type:y}=p.values;if(b&&v){const F=L.castArray(r(b).filterTargetKey);c((x=r(b).fields)==null?void 0:x.filter(k=>k.primaryKey||k.unique?!0:F.length===1?F[0]===k.name:y==="hasMany"&&vd.includes(k.type)).map(k=>{var C;return{value:k.name,label:h(((C=k==null?void 0:k.uiSchema)==null?void 0:C.title)||k.title||k.name)}}))}}),onChange:v=>{var x;(x=e==null?void 0:e.onChange)==null||x.call(e,v),u(v)},value:d,disabled:o,filterOption:(v,x)=>x==null?void 0:x.label.toLowerCase().includes(v.toLowerCase())})})},{displayName:"TargetKey"}),BU=S.observer(e=>{const{disabled:t}=e,[o,n]=m.useState([]),{getCollection:l}=ie(),i=$e(),r=S.useField(),{collectionName:s,target:c,type:d,through:u,name:p,template:h}=i,g=i[r.props.name],v=se(),x=S.useForm(),[b,y]=m.useState(g||(h==="view"?null:r.initialValue)),[F,k]=m.useState([]);return m.useEffect(()=>{var C;const j=["belongsTo"].includes(d)?s:["belongsToMany"].includes(d)?u:c,P=(C=l(j))==null?void 0:C.fields;if(P){const M=P==null?void 0:P.filter(R=>vd.includes(R.type)).map(R=>{var N;return{value:R.name,label:v(((N=R.uiSchema)==null?void 0:N.title)||R.name)}});if(n(M),k(M),g){const R=M.find(N=>N.value===g);y((R==null?void 0:R.label)||g)}}},[d]),a.jsx("div",{children:a.jsx(h==="view"?I.Select:I.AutoComplete,{disabled:t,value:b,options:o,showSearch:!0,onDropdownVisibleChange:C=>O(void 0,null,function*(){var j;const{target:P,type:M,through:R}=x.values,N=["belongsTo"].includes(M)?s||p:["belongsToMany"].includes(M)?R:P;if(N&&C){const D=((j=l(N))==null?void 0:j.fields)||[];n(D==null?void 0:D.filter(q=>vd.includes(q.type)).map(q=>{var $;return{value:q.name,label:v((($=q.uiSchema)==null?void 0:$.title)||q.name)}}))}}),onChange:(C,j)=>{var P;(P=e==null?void 0:e.onChange)==null||P.call(e,C),y(j.label||C)},onSearch:C=>{if(C){const j=C.toLocaleLowerCase(),P=o.filter(M=>M.label.toLocaleLowerCase().includes(j));n(P)}else n(F)}})})},{displayName:"ForeignKey"}),qU=S.observer(e=>{const{disabled:t}=e,o=se(),{getCollections:n}=ie(),[l,i]=m.useState([]),r=S.useField(),s=$e()[r.props.name],[c,d]=m.useState(s||r.initialValue),u=()=>n().filter(p=>!(p.autoCreate&&p.isThrough)).map(p=>({label:o(p.title),value:p.name}));return m.useEffect(()=>{const p=u();if(i(p),s){const h=p.find(g=>g.value===s);d((h==null?void 0:h.label)||s)}},[]),a.jsx("div",{children:a.jsx(I.AutoComplete,{disabled:t,showSearch:!0,popupMatchSelectWidth:!1,value:c,options:l,onSearch:p=>{const h=u();if(p){const g=h.filter(v=>v.label.toLowerCase().includes(p.toLowerCase()));i(g)}else i(h)},onChange:(p,h)=>{var g;(g=e==null?void 0:e.onChange)==null||g.call(e,p),d(h.label||p)}})})},{displayName:"ThroughCollection"}),$U=Object.freeze(Object.defineProperty({__proto__:null,FieldValidation:_x,ForeignKey:BU,SourceCollection:NU,SourceForeignKey:MU,SourceKey:DU,TargetForeignKey:RU,TargetKey:EU,ThroughCollection:qU,ThroughForeignKey:AU},Symbol.toStringTag,{value:"Module"})),OU=(e,t)=>Object.keys(t).map(o=>{const n=t[o];return T(f({},n),{key:o,children:Object.keys(e[o]||{}).filter(l=>!e[o][l].hidden).map(l=>{const i=e[o][l];return f({value:l,label:i.title,name:l},e[o][l])}).sort((l,i)=>l.order-i.order)})}).sort((o,n)=>o.order-n.order),Kx=()=>{const e=wt();return m.useMemo(()=>{const t=e.collectionFieldInterfaceManager.getFieldInterfaces(),o=e.collectionFieldInterfaceManager.getFieldInterfaceGroups(),n=t.reduce((l,i)=>{const r=i.group||"basic";return l[r]||(l[r]=[]),l[r].push(i),l},{});return OU(n,o)},[e])},LU=e=>{var t,o,n;return(n=(o=(t=e.properties)==null?void 0:t.layout)==null?void 0:o.properties)==null?void 0:n.primaryKey};w.observer(e=>{const{schema:t,label:o}=e,n=se(),l=qr.useAntdToken(),i=m.useMemo(()=>({container:{backgroundColor:l.colorFillAlter,marginBottom:l.marginLG,padding:l.paddingSM+l.paddingXXS},title:{color:l.colorText},description:{marginTop:l.marginXS,color:l.colorTextDescription},tag:{background:"none"}}),[l.colorFillAlter,l.colorText,l.colorTextDescription,l.marginLG,l.marginXS,l.paddingSM,l.paddingXXS]);return t?a.jsxs("div",{style:i.container,children:[a.jsxs("div",{style:i.title,children:[o,": ",a.jsx(I.Tag,{style:i.tag,children:n(t.title)})]}),t.description?a.jsx("div",{style:i.description,children:n(t.description)}):null]}):null},{displayName:"Summary"});const VU=({dataSource:e})=>{const{t}=K.useTranslation(),o=[{title:t("Field name"),dataIndex:"name",key:"name"},{title:t("Field database type"),dataIndex:"rawType",key:"rawType"}];return(e==null?void 0:e.length)>0&&a.jsxs(a.Fragment,{children:[a.jsx(I.Divider,{plain:!0,orientation:"left",orientationMargin:"0",children:a.jsx("h3",{children:t("Unknown field type")})}),a.jsx("div",{style:{marginBottom:"15px"},children:t("The following field types are not compatible and do not support output and display")}),a.jsx(I.Table,{columns:o,dataSource:e,pagination:!1})]})},zU=(e,t)=>{const o=[];return e.forEach(n=>{const l=n.children.filter(i=>{var r;return(r=i==null?void 0:i.availableTypes)==null?void 0:r.includes(t)});o.push({label:n.label,key:n.key,children:l})}),o.filter(n=>n.children.length>0)},_U=e=>{const{databaseView:t,viewName:o,sources:n,schema:l}=e,{data:i}=m.useContext(Oi),r=Te(),{t:s}=K.useTranslation(),[c,d]=m.useState(!1),[u,p]=m.useState([]),[h,g]=m.useState([]),[v,x]=m.useState(n),[b,y]=m.useState([]),F=S.useField(),k=S.useForm(),{getCollection:C,getInterface:j,getCollectionFields:P,getInheritCollections:M,getParentCollectionFields:R}=ie(),N=se(),D=Kx().filter(B=>!["relation","systemInfo"].includes(B.key));m.useEffect(()=>{const B=[];v.forEach(E=>{var U;const V=C(E),z=M(E).map(H=>{const G=R(H,E);return{type:"group",key:H,label:s("Parent collection fields")+s(`(${C(H).title})`),children:G.filter(W=>!["hasOne","hasMany","belongsToMany"].includes(W==null?void 0:W.type)).map(W=>{var Q;return{value:W.name,label:s((Q=W.uiSchema)==null?void 0:Q.title)}})}}),_=(U=V.fields.filter(H=>!["obo","oho","m2m","o2m"].includes(H==null?void 0:H.interface)))==null?void 0:U.map(H=>{var G;return{value:H.name,key:H.name,label:s(((G=H.uiSchema)==null?void 0:G.title)||H.name)}}).concat(z);B.push({value:E,label:s(V.title||V.name),children:_})}),g(B)},[v,t]),m.useEffect(()=>{t&&(d(!0),r.resource("dbViews").get({filterByTk:o,schema:l}).then(({data:B})=>{var E,U;if(B){d(!1),p([]);const V=(U=Object.values((E=B==null?void 0:B.data)==null?void 0:E.fields))==null?void 0:U.map(z=>{var _,H;const G=(i==null?void 0:i.data.find(W=>W.name===z.name))||z;if(!(G!=null&&G.uiSchema)){const W=j(z.interface);G.uiSchema=(W==null?void 0:W.default.uiSchema)||{}}return z.source?T(f({},z),{uiSchema:T(f({},L.omit(G.uiSchema,"rawTitle")),{title:((_=G.uiSchema)==null?void 0:_.title)||G.name})}):T(f({},G),{uiSchema:T(f({},L.omit(G.uiSchema,"rawTitle")),{title:((H=G.uiSchema)==null?void 0:H.title)||G.name})})});F.value=V,setTimeout(()=>{var z,_,H;p(V),k.setValuesIn("sources",(z=B.data)==null?void 0:z.sources),x((_=B.data)==null?void 0:_.sources),y((H=B==null?void 0:B.data)==null?void 0:H.unsupportedFields)})}}).catch)},[t]);const q=(B,E)=>{const U=L.cloneDeep(u);U[E]=B,p(U),F.value=U.map(V=>{var z,_,H;const G=typeof V.source=="string"?V.source:(H=(_=(z=V.source)==null?void 0:z.filter)==null?void 0:_.call(z,Boolean))==null?void 0:H.join(".");return T(f({},V),{source:G})})},$=[{title:s("Field name"),dataIndex:"name",key:"name",width:130},{title:s("Field source"),dataIndex:"source",key:"source",width:200,render:(B,E,U)=>a.jsx(I.Cascader,{defaultValue:typeof B=="string"?B==null?void 0:B.split("."):B,allowClear:!0,style:{width:"100%"},options:N(h),onChange:(V,z)=>{var _;const H=(_=P(V==null?void 0:V[0]))==null?void 0:_.find(G=>G.name===L.last(V));q(T(f({},E),{source:V,uiSchema:H==null?void 0:H.uiSchema}),U)},placeholder:s("Select field source")})},{title:s("Field type"),dataIndex:"type",width:140,key:"type",render:(B,E,U)=>{const V=u[U];return V!=null&&V.source||!(V!=null&&V.possibleTypes)?a.jsx(I.Tag,{children:B}):a.jsx(I.Select,{defaultValue:B,popupMatchSelectWidth:!1,style:{width:"100%"},options:(V==null?void 0:V.possibleTypes.map(z=>({label:z,value:z})))||[],onChange:z=>q(T(f({},V),{type:z}),U)})}},{title:s("Field interface"),dataIndex:"interface",key:"interface",width:150,render:(B,E,U)=>{const V=u[U],z=zU(D,V.type);return V.source?B:a.jsx(I.Select,{defaultValue:B,style:{width:"100%"},popupMatchSelectWidth:!1,onChange:_=>{q(T(f({},V),{interface:_}),U)},children:z.map(_=>a.jsx(I.Select.OptGroup,{label:N(_.label),children:_.children.map(H=>a.jsx(I.Select.Option,{value:H.name,children:N(H.label)},H.value))},_.key))})}},{title:s("Field display name"),dataIndex:"title",key:"title",width:180,render:(B,E,U)=>{var V;const z=u[U];return a.jsx(I.Input,{defaultValue:((V=z==null?void 0:z.uiSchema)==null?void 0:V.title)||B,onChange:_=>q(T(f({},z),{uiSchema:T(f({},L.omit(z==null?void 0:z.uiSchema,"rawTitle")),{title:_.target.value})}),U)})}}];return a.jsxs(I.Spin,{spinning:c,children:[u.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"ant-formily-item-label",style:{display:"flex",padding:"0 0 8px"},children:[a.jsx("div",{className:"ant-formily-item-label-content",children:a.jsx("span",{children:a.jsx("label",{children:s("Fields")})})}),a.jsx("span",{className:"ant-formily-item-colon",children:":"})]}),a.jsx(I.Table,{bordered:!0,size:"middle",columns:$,dataSource:u,scroll:{y:300},pagination:!1,rowClassName:"editable-row"},o)]}),a.jsx(VU,{dataSource:b})]})};function KU(e,t){return t.viewName===e.viewName&&t.schema===e.schema&&t.source===e.source}const Bw=m.memo(_U,KU);Bw.displayName="PreviewFields";const UU=["lineString","point","circle","polygon"],HU=e=>{const{databaseView:t,schema:o,viewName:n,fields:l}=e,[i,r]=m.useState([]),[s,c]=m.useState([]),d=se(),[u,p]=m.useState(!1),{getInterface:h,getCollectionFields:g}=ie(),v=Te(),{t:x}=K.useTranslation(),b=S.useForm();m.useEffect(()=>{t&&y()},[n,o]),m.useEffect(()=>{const k=F(l);r(k)},[b.values.fields]);const y=()=>{const k={};b.values.fields.map(C=>{UU.includes(C.type)&&(k[C.name]=C.type)}),p(!0),v.resource("dbViews").query({filterByTk:n,schema:o,fieldTypes:k}).then(({data:C})=>{C&&(p(!1),c((C==null?void 0:C.data)||[]))}).catch},F=k=>{var C;return(C=k.filter(j=>j.source||j.interface))==null?void 0:C.map(j=>{var P,M,R,N,D,q;const $=typeof(j==null?void 0:j.source)=="string"?(P=j==null?void 0:j.source)==null?void 0:P.split("."):j==null?void 0:j.source,B=(R=(M=g($==null?void 0:$[0]))==null?void 0:M.find(V=>V.name===($==null?void 0:$[1])))==null?void 0:R.uiSchema,E=((N=j==null?void 0:j.uiSchema)==null?void 0:N.title)||(B==null?void 0:B.title)||j.name,U=j.source?B:(q=(D=h(j.interface))==null?void 0:D.default)==null?void 0:q.uiSchema;return{title:d(E),dataIndex:j.name,key:j.name,width:200,render:(V,z,_)=>{const H=z[j.name],G={type:"object",properties:{[j.name]:{name:`${j.name}`,"x-component":U&&$?"CollectionField":"Input","x-read-pretty":!0,"x-collection-field":$==null?void 0:$.join("."),default:j.interface==="json"?JSON.stringify(H):H}}};return a.jsx(io,{ellipsis:!0,children:a.jsx(S.RecursionField,{schema:G,name:_,onlyRenderProperties:!0})})}}})};return a.jsx(I.Spin,{spinning:u,children:a.jsxs("div",{style:{marginBottom:22},children:[a.jsxs("div",{className:"ant-formily-item-label",style:{marginTop:24,display:"flex",padding:"0 0 8px"},children:[a.jsx("div",{className:"ant-formily-item-label-content",children:a.jsx("span",{children:a.jsx("label",{children:x("Preview")})})}),a.jsx("span",{className:"ant-formily-item-colon",children:":"})]},n),(i==null?void 0:i.length)>0&&a.jsx(a.Fragment,{children:a.jsx(I.Table,{size:"middle",pagination:!1,bordered:!0,columns:i,dataSource:s,scroll:{x:1e3,y:300}},`${n}-preview`)})]})},"preview")},xd=m.createContext(null);xd.displayName="AsyncDataContext";const qw=e=>{const t=e,{value:o,request:n,children:l}=t,i=ne(t,["value","request","children"]),r=Ue(n,f({},i));return o?a.jsx(xd.Provider,{value:o,children:l}):a.jsx(xd.Provider,{value:r,children:l})},Np=()=>m.useContext(xd),GU=(e,t)=>e.toLowerCase().includes("id")?"id":typeof t=="number"?Number.isInteger(t)?"integer":"number":typeof t=="boolean"?"checkbox":Me(t).isValid()?"datetime":"input",WU=()=>{const e=S.useForm(),{sources:t=[]}=e.values,{t:o}=K.useTranslation(),{getCollection:n,getInheritCollections:l,getParentCollectionFields:i}=ie(),r=[];return t.forEach(s=>{var c;const d=n(s),u=l(s).map(h=>{const g=i(h,s);return{type:"group",key:h,label:o("Parent collection fields")+o(`(${n(h).title})`),children:g.filter(v=>!["hasOne","hasMany","belongsToMany"].includes(v==null?void 0:v.type)).map(v=>{var x;return{value:v.name,label:o((x=v.uiSchema)==null?void 0:x.title)}})}});if(!d)return;const p=(c=d.fields.filter(h=>!["hasOne","hasMany","belongsToMany","belongsTo"].includes(h==null?void 0:h.type)))==null?void 0:c.map(h=>{var g;return{value:h.name,label:o((g=h.uiSchema)==null?void 0:g.title)}});r.push({value:s,label:o(d.title),children:[...p,...u]})}),r},$w=S.observer(()=>{var e,t,o,n;const{t:l}=K.useTranslation(),[i,r]=m.useState([]),{data:s,error:c,loading:d}=Np(),{data:u,fields:p}=s||{},h=S.useField(),{data:g}=m.useContext(Oi),v=se(),{getInterface:x,getCollectionField:b}=ie(),y=Kx(),F=m.useMemo(()=>y.filter(R=>!["relation"].includes(R.key)).map((R,N)=>({key:N,label:v(R.label),options:R.children.map((D,q)=>({value:D.name,key:`${N}-${q}`,label:v(D.label)}))})),[v]),k=WU(),C=m.useRef(x);if(m.useEffect(()=>{var R;const N=new Map;d||(u&&u.length?Object.entries((u==null?void 0:u[0])||{}).forEach(([q,$])=>{var B;const E=p[q],U=GU(q,$),V=(B=C.current(U))==null?void 0:B.default,z=(E==null?void 0:E.uiSchema)||(V==null?void 0:V.uiSchema)||{};N.set(q,{name:q,interface:(E==null?void 0:E.interface)||U,type:(E==null?void 0:E.type)||(V==null?void 0:V.type),source:E==null?void 0:E.source,uiSchema:f({title:q},z)})}):Object.entries(p||{}).forEach(([q,$])=>N.set(q,T(f({name:q,type:"string"},$),{uiSchema:f({title:q},($==null?void 0:$.uiSchema)||{})})))),(R=h.value)!=null&&R.length&&h.value.forEach(q=>{N.has(q.name)&&N.set(q.name,q)});const D=Array.from(N.values());D.length&&(r(D),h.setValue(D))},[d,u,h,p,g]),d)return a.jsx(I.Spin,{});if(!u&&!c)return a.jsx(I.Alert,{showIcon:!0,message:l("Please use a valid SELECT or WITH AS statement")});const j=c;if(j){const R=((n=(o=(t=(e=j==null?void 0:j.response)==null?void 0:e.data)==null?void 0:t.errors)==null?void 0:o.map)==null?void 0:n.call(o,N=>N.message).join(`
|
|
1610
1610
|
`))||j.message;return a.jsx(I.Alert,{showIcon:!0,message:`${l("SQL error: ")}${R}`,type:"error"})}const P=(R,N)=>{const D=[...i];D.splice(N,1,R),r(D),h.setValue(D.map(q=>{var $,B,E;return T(f({},q),{source:typeof q.source=="string"?q.source:((E=(B=($=q.source)==null?void 0:$.filter)==null?void 0:B.call($,Boolean))==null?void 0:E.join("."))||null})}))},M=[{title:l("Field name"),dataIndex:"name",key:"name",width:130},{title:l("Field source"),dataIndex:"source",key:"source",width:200,render:(R,N,D)=>{const q=i[D];return a.jsx(I.Cascader,{defaultValue:typeof R=="string"?R==null?void 0:R.split("."):R,allowClear:!0,options:v(k),placeholder:l("Select field source"),onChange:$=>{let B=p[$==null?void 0:$[1]];B!=null&&B.interface||(B=b(($==null?void 0:$.join("."))||"")),P(T(f({},q),{source:$,interface:B==null?void 0:B.interface,type:B==null?void 0:B.type,uiSchema:B==null?void 0:B.uiSchema}),D)}})}},{title:l("Field interface"),dataIndex:"interface",key:"interface",width:150,render:(R,N,D)=>{var q;const $=i[D];return $.source?a.jsx(I.Tag,{children:v((q=x(R))==null?void 0:q.title)||R}):a.jsx(I.Select,{defaultValue:$.interface||"input",style:{width:"100%"},popupMatchSelectWidth:!1,onChange:B=>{var E,U,V,z,_;const H=x(B);P(T(f({},$),{interface:B||null,uiSchema:T(f({},(E=H==null?void 0:H.default)==null?void 0:E.uiSchema),{title:((V=(U=H==null?void 0:H.default)==null?void 0:U.uiSchema)==null?void 0:V.title)||((z=$.uiSchema)==null?void 0:z.title)}),type:(_=H==null?void 0:H.default)==null?void 0:_.type}),D)},allowClear:!0,options:F})}},{title:l("Field display name"),dataIndex:"title",key:"title",width:180,render:(R,N,D)=>{var q,$;const B=i[D];return a.jsx(I.Input,{value:((q=B.uiSchema)==null?void 0:q.title)||R,defaultValue:(($=B.uiSchema)==null?void 0:$.title)!==void 0?B.uiSchema.title:B==null?void 0:B.name,onChange:E=>P(T(f({},B),{uiSchema:T(f({},B==null?void 0:B.uiSchema),{title:E.target.value})}),D)})}}];return a.jsx(I.Table,{bordered:!0,size:"small",columns:M,dataSource:i,scroll:{y:300},pagination:!1,rowClassName:"editable-row",rowKey:"name"})},{displayName:"FieldsConfigure"}),Ow=S.observer(()=>{const{data:e,loading:t,error:o}=Np(),{data:n}=e||{},{t:l}=K.useTranslation(),i=(S.useForm().values.fields||[]).reduce((c,d)=>{var u;return c[d.name]=(u=d==null?void 0:d.uiSchema)==null?void 0:u.title,c},{}),r=o?[]:Object.keys((n==null?void 0:n[0])||{}).map(c=>{const d=i[c];return{title:S.Schema.compile(d||c,{t:l}),dataIndex:c,key:c}}),s=o?[]:n==null?void 0:n.map((c,d)=>{const u=Object.entries(c).reduce((p,[h,g])=>{if(typeof g!="string")return p[h]=g,p;const v=S.Schema.compile(g,{t:l});return p[h]=l(v),p},{});return T(f({},u),{key:d})});return a.jsx(I.Table,{bordered:!0,dataSource:s,columns:r,scroll:{x:r.length*150,y:300},loading:t,rowKey:"key"})},{displayName:"PreviewTable"}),Lw=e=>{const t=Te(),o=S.useForm(),n=$e();let{manual:l}=e;l=l===void 0?!0:l;const i=Ue(d=>t.resource("sqlCollection").execute({values:{sql:d}}).then(u=>{var p;return((p=u==null?void 0:u.data)==null?void 0:p.data)||{data:[],fields:[],sources:[]}}),{manual:!0,onSuccess:d=>{const{sources:u}=d,p=o.values.sources||[];o.setValuesIn("sources",Array.from(new Set([...p,...u])))}}),{run:r}=i,s=o.values.sql||n.sql,c=m.useRef(!0);return m.useEffect(()=>{s&&c.current&&r(s),c.current=!1},[l,r,s]),a.jsx(qw,{value:i,children:e.children})},YU=({disabled:e})=>{const{t}=K.useTranslation(),{run:o,loading:n,error:l}=Np(),i=S.useField(),r=()=>{i.value&&o(i.value)},s=()=>{!e&&!i.value||(e||o(i.value),i.setComponentProps({disabled:!e}))};return m.useEffect(()=>{l&&i.setComponentProps({disabled:!1})},[i,l]),a.jsxs("div",{className:Z.css`
|
|
1611
1611
|
position: relative;
|
|
1612
1612
|
.ant-input {
|