plugin-block-cross-join 0.1.2 → 0.1.4

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/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # plugin-block-cross-join
2
+
3
+ ## Overview
4
+ Create a block that joins and displays data from multiple collections across different datasources in a single unified table.
5
+
6
+ ## Features
7
+ - **Cross-Datasource Joins**: Combine data from PostgreSQL, MSSQL, MySQL, etc., into one view.
8
+ - **Unified Table Block**: Displays joined records as a standard NocoBase table with sorting and filtering.
9
+ - **Virtual Relationships**: Define join conditions directly in the block configuration without altering database schemas.
10
+
11
+ ## Usage
12
+ 1. Activate the plugin in the Plugin Manager.
13
+ 2. On any page, click "Add Block" -> "Cross-Join Table".
14
+ 3. Select the primary collection.
15
+ 4. Click "Add Join" to select secondary collections (even from other datasources).
16
+ 5. Map the foreign keys / relationship fields.
17
+ 6. Configure the visible columns from both collections.
package/client-v2.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client-v2';
2
+ export { default } from './dist/client-v2';
package/client-v2.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client-v2/index.js');
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("plugin-block-cross-join",["react","@nocobase/client","@formily/react","@ant-design/icons","antd"],t):"object"==typeof exports?exports["plugin-block-cross-join"]=t(require("react"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("antd")):e["plugin-block-cross-join"]=t(e.react,e["@nocobase/client"],e["@formily/react"],e["@ant-design/icons"],e.antd)}(self,function(e,t,n,r,o){return function(){"use strict";var a={482:function(e){e.exports=r},505:function(e){e.exports=n},772:function(e){e.exports=t},721:function(e){e.exports=o},156:function(t){t.exports=e}},i={};function l(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return a[e](n,n.exports,l),n.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return!function(){l.r(c),l.d(c,{PluginBlockCrossJoinClient:function(){return _},default:function(){return N}});var e=l(772),t=l(156),n=l.n(t),r=l(505);function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t,n,r,o,a,i){try{var l=e[a](i),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var u=(0,t.createContext)(null),s=function(o){var l,c,s=o.children,f=(0,r.useFieldSchema)(),p=(0,e.useAPIClient)(),d=(null==f?void 0:f["x-decorator-props"])||{},m=d.config,y=(0,t.useMemo)(function(){return m},[JSON.stringify(m)]),b=i((0,t.useState)([]),2),v=b[0],h=b[1],g=i((0,t.useState)(!1),2),S=g[0],w=g[1],O=i((0,t.useState)(1),2),C=O[0],j=O[1],E=i((0,t.useState)((null==(c=d.params)?void 0:c.pageSize)||20),2),x=E[0],k=E[1],P=i((0,t.useState)(0),2),I=P[0],T=P[1],B=(0,t.useCallback)((l=function(){var e,t,n,r;return function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var c=[a,l];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:if(!(null==y||null==(e=y.primarySource)?void 0:e.collection))return[2];w(!0),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,p.request({url:"crossJoin:query",method:"post",data:{config:y,page:C,pageSize:x}})];case 2:return h((null==(r=null==(n=o.sent())?void 0:n.data)?void 0:r.data)||[]),T((null==r||null==(t=r.meta)?void 0:t.count)||0),[3,5];case 3:return console.error("CrossJoin query failed:",o.sent()),h([]),[3,5];case 4:return w(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=l.apply(e,t);function i(e){a(o,n,r,i,c,"next",e)}function c(e){a(o,n,r,i,c,"throw",e)}i(void 0)})}),[p,y,C,x]);return(0,t.useEffect)(function(){B()},[B]),n().createElement(u.Provider,{value:{data:v,loading:S,pagination:{page:C,pageSize:x,total:I},config:y,refresh:B,setPage:j,setPageSize:k}},s)},f=l(721);function p(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var d=function(){var e,r=(0,t.useContext)(u),o=(0,t.useMemo)(function(){if(!(null==r||null==(i=r.data)?void 0:i.length))return[];var e=r.config;if(null==e||null==(l=e.columns)?void 0:l.length){var t=[],n=!0,o=!1,a=void 0;try{for(var i,l,c,u=e.columns[Symbol.iterator]();!(n=(c=u.next()).done);n=!0){var s=c.value;if(null==(y=s.jsonExpand)?void 0:y.length){var f=!0,d=!1,m=void 0;try{for(var y,b,v=s.jsonExpand[Symbol.iterator]();!(f=(b=v.next()).done);f=!0){var h=b.value,g=s.alias?"".concat(s.alias,".").concat(h):"".concat(s.field,".").concat(h);t.push({title:g,dataIndex:g,key:g,ellipsis:!0,render:function(e){return null!=e?String(e):"-"}})}}catch(e){d=!0,m=e}finally{try{f||null==v.return||v.return()}finally{if(d)throw m}}}else{var S=s.alias||s.field;t.push({title:S,dataIndex:S,key:S,ellipsis:!0,render:function(e){return null==e?"-":(void 0===e?"undefined":p(e))==="object"?JSON.stringify(e):String(e)}})}}}catch(e){o=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return t}return Object.keys(r.data[0]).map(function(e){return{title:e,dataIndex:e,key:e,ellipsis:!0,render:function(t,n){var r=n[e];return null==r?"-":(void 0===r?"undefined":p(r))==="object"?JSON.stringify(r):String(r)}}})},[null==r?void 0:r.data,null==r?void 0:r.config]);return r?r.loading?n().createElement("div",{style:{textAlign:"center",padding:40}},n().createElement(f.Spin,null)):(null==(e=r.data)?void 0:e.length)?n().createElement(f.Table,{dataSource:r.data,columns:o,rowKey:function(e,t){return String(t)},size:"middle",scroll:{x:"max-content"},pagination:{current:r.pagination.page,pageSize:r.pagination.pageSize,total:r.pagination.total,showSizeChanger:!0,showTotal:function(e){return"Total ".concat(e," rows")},onChange:function(e,t){r.setPage(e),r.setPageSize(t)}}}):n().createElement(f.Empty,{description:"No data"}):null},m=l(482);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(e,t)||S(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(e,t)}}var w=f.Typography.Text;function O(){var n=(0,e.useDataSourceManager)(),r=(null==n?void 0:n.getDataSources())||[];return(0,t.useMemo)(function(){return r.filter(function(e){return"loaded"===e.status}).map(function(e){return{label:e.displayName||e.key,value:e.key,ds:e}})},[r])}function C(n){var r=(0,e.useDataSourceManager)();return(0,t.useMemo)(function(){if(!n||!r)return[];var e=r.getDataSource(n);return e?(e.collectionManager.getCollections()||[]).map(function(e){return{label:e.title||e.name,value:e.name}}):[]},[r,n])}function j(n,r){var o=(0,e.useDataSourceManager)();return(0,t.useMemo)(function(){if(!n||!r||!o)return[];var e=o.getDataSource(n);if(!e)return[];var t=e.collectionManager.getCollection(r);return t?(t.getFields()||[]).map(function(e){var t;return{label:(null==(t=e.uiSchema)?void 0:t.title)||e.name,value:e.name,type:e.type,interface:e.interface}}):[]},[o,n,r])}var E=function(e){var t=e.value,r=e.onChange,o=O(),a=C(t.dataSource);return n().createElement(f.Form,{layout:"vertical"},n().createElement(f.Form.Item,{label:"Datasource"},n().createElement(f.Select,{value:t.dataSource,options:o,placeholder:"Select datasource",onChange:function(e){return r({dataSource:e,collection:""})},showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())}})),n().createElement(f.Form.Item,{label:"Collection"},n().createElement(f.Select,{value:t.collection||void 0,options:a,placeholder:"Select collection",onChange:function(e){return r(v(b({},t),{collection:e}))},showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())},disabled:!t.dataSource})))},x=function(e){var t=e.join,r=e.index,o=e.primaryDs,a=e.primaryCollection,i=e.onChange,l=e.onRemove,c=O(),u=C(t.dataSource),s=j(o,a),p=j(t.dataSource,t.collection);return n().createElement("div",{style:{border:"1px solid #d9d9d9",borderRadius:6,padding:16,marginBottom:12}},n().createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:8}},n().createElement(w,{strong:!0},"Join #",r+1),n().createElement(f.Button,{type:"text",danger:!0,icon:n().createElement(m.DeleteOutlined,null),onClick:function(){return l(r)}})),n().createElement(f.Form,{layout:"vertical",size:"small"},n().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12}},n().createElement(f.Form.Item,{label:"Datasource",style:{marginBottom:8}},n().createElement(f.Select,{value:t.dataSource,options:c,onChange:function(e){return i(r,v(b({},t),{dataSource:e,collection:"",rightField:""}))},showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())}})),n().createElement(f.Form.Item,{label:"Collection",style:{marginBottom:8}},n().createElement(f.Select,{value:t.collection||void 0,options:u,onChange:function(e){return i(r,v(b({},t),{collection:e,rightField:""}))},disabled:!t.dataSource,showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())}}))),n().createElement(f.Form.Item,{label:"Join Type",style:{marginBottom:8}},n().createElement(f.Radio.Group,{value:t.joinType,onChange:function(e){return i(r,v(b({},t),{joinType:e.target.value}))}},n().createElement(f.Radio,{value:"left"},"Left Join"),n().createElement(f.Radio,{value:"inner"},"Inner Join"))),n().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12}},n().createElement(f.Form.Item,{label:"Left Field (primary)",style:{marginBottom:0}},n().createElement(f.Select,{value:t.leftField||void 0,options:s,onChange:function(e){return i(r,v(b({},t),{leftField:e}))},placeholder:"Field from primary",showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())}})),n().createElement(f.Form.Item,{label:"Right Field (join)",style:{marginBottom:0}},n().createElement(f.Select,{value:t.rightField||void 0,options:p,onChange:function(e){return i(r,v(b({},t),{rightField:e}))},placeholder:"Field from join table",disabled:!t.collection,showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())}})))))},k=function(e){var t=e.joins,r=e.primaryDs,o=e.primaryCollection,a=e.onChange,i=function(e,n){var r=g(t);r[e]=n,a(r)},l=function(e){a(t.filter(function(t,n){return n!==e}))};return n().createElement("div",null,t.map(function(e,t){return n().createElement(x,{key:t,join:e,index:t,primaryDs:r,primaryCollection:o,onChange:i,onRemove:l})}),n().createElement(f.Button,{type:"dashed",icon:n().createElement(m.PlusOutlined,null),onClick:function(){a(g(t).concat([{dataSource:"main",collection:"",joinType:"left",leftField:"",rightField:""}]))},block:!0},"Add Join"))},P=function(e){var r=e.columns,o=e.primaryDs,a=e.primaryCollection,i=(e.joins,e.onChange),l=j(o,a),c=(0,t.useMemo)(function(){var e=[],t=!0,n=!1,r=void 0;try{for(var o,i=l[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var c=o.value;e.push({source:0,sourceName:a,field:c.value,label:"".concat(a,".").concat(c.label),type:c.type})}}catch(e){n=!0,r=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw r}}return e},[l,a]),u=(0,t.useCallback)(function(){i(c.map(function(e){return{source:e.source,field:e.field,selected:!0}}))},[c,i]),s=[{title:"Include",dataIndex:"selected",width:70,render:function(e,t,o){return n().createElement(f.Checkbox,{checked:!1!==t.selected,onChange:function(e){var t=g(r);t[o]=v(b({},t[o]),{selected:e.target.checked}),i(t)}})}},{title:"Source",dataIndex:"source",width:100,render:function(e){return 0===e?"Primary":"Join #".concat(e)}},{title:"Field",dataIndex:"field",width:150},{title:"Alias",dataIndex:"alias",width:150,render:function(e,t,o){return n().createElement(f.Input,{size:"small",value:t.alias||"",placeholder:t.field,onChange:function(e){var t=g(r);t[o]=v(b({},t[o]),{alias:e.target.value||void 0}),i(t)}})}}];return n().createElement("div",null,n().createElement("div",{style:{marginBottom:12}},n().createElement(f.Button,{size:"small",onClick:u},"Auto-populate from sources")),r.length>0?n().createElement(f.Table,{dataSource:r,columns:s,rowKey:function(e,t){return String(t)},size:"small",pagination:!1,scroll:{y:300}}):n().createElement(w,{type:"secondary"},'Click "Auto-populate" to add fields from all configured sources, or they will be auto-detected at runtime.'))},I=function(e){var r=e.visible,o=e.onCancel,a=e.onSubmit,i=e.initialConfig,l=h((0,t.useState)((null==i?void 0:i.primarySource)||{dataSource:"main",collection:""}),2),c=l[0],u=l[1],s=h((0,t.useState)((null==i?void 0:i.joins)||[]),2),p=s[0],d=s[1],m=h((0,t.useState)((null==i?void 0:i.columns)||[]),2),y=m[0],b=m[1],v=c.dataSource&&c.collection;return n().createElement(f.Modal,{title:"Configure Cross Join",open:r,onCancel:o,onOk:function(){a({primarySource:c,joins:p,columns:y.filter(function(e){return!1!==e.selected}).map(function(e){return e.selected,function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,["selected"])})})},okButtonProps:{disabled:!v},width:720,destroyOnClose:!0},n().createElement(f.Tabs,{items:[{key:"primary",label:"Primary Source",children:n().createElement(E,{value:c,onChange:u})},{key:"joins",label:"Joins (".concat(p.length,")"),children:n().createElement(k,{joins:p,primaryDs:c.dataSource,primaryCollection:c.collection,onChange:d})},{key:"columns",label:"Columns",children:n().createElement(P,{columns:y,primaryDs:c.dataSource,primaryCollection:c.collection,joins:p,onChange:b})}]}))};function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var B=function(){var r,o,a,i=(0,e.useSchemaInitializer)().insert,l=(0,e.useSchemaInitializerItem)(),c=(r=(0,t.useState)(!1),function(e){if(Array.isArray(e))return e}(r)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(r,2)||function(e,t){if(e){if("string"==typeof e)return T(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return T(e,t)}}(r,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=c[0],s=c[1];return n().createElement(n().Fragment,null,n().createElement(e.SchemaInitializerItem,(o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},l),a=a={icon:n().createElement(m.MergeCellsOutlined,null),onClick:function(){return s(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(a)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(a)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(a,e))}),o)),n().createElement(I,{visible:u,onCancel:function(){return s(!1)},onSubmit:function(e){i({type:"void","x-settings":"blockSettings:crossJoin","x-toolbar":"BlockSchemaToolbar","x-decorator":"CrossJoinBlockProvider","x-decorator-props":{config:e,params:{pageSize:20}},"x-component":"CardItem","x-component-props":{name:"crossJoin"},properties:{table:{type:"void","x-component":"CrossJoinTable"}}}),s(!1)}}))};function J(e,t,n,r,o,a,i){try{var l=e[a](i),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}var A=new e.SchemaSettings({name:"blockSettings:crossJoin",items:[{name:"title",Component:e.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:e.SchemaSettingsBlockHeightItem},{name:"editMapping",type:"modal",useComponentProps:function(){var e;return{title:"Edit Mapping",onSubmit:(e=function(){return function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var c=[a,l];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){return[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){J(a,r,o,i,l,"next",e)}function l(e){J(a,r,o,i,l,"throw",e)}i(void 0)})})}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]});function F(e,t,n,r,o,a,i){try{var l=e[a](i),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function M(e,t,n){return(M=q()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&z(o,n.prototype),o}).apply(null,arguments)}function D(e){return(D=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function z(e,t){return(z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function L(e){var t="function"==typeof Map?new Map:void 0;return(L=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return M(e,arguments,D(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),z(n,e)})(e)}function q(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(q=function(){return!!e})()}var R=function(t){var r=t.children;return n().createElement(e.SchemaComponentOptions,{components:{CrossJoinBlockProvider:s,CrossJoinTable:d,CrossJoinBlockInitializer:B}},r)},_=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=D(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,q()?Reflect.construct(e,t||[],D(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&z(n,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var c=[a,l];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){return t.app.use(R),t.app.schemaSettingsManager.add(A),t.app.schemaInitializerManager.addItem("page:addBlock","otherBlocks.crossJoin",{title:'{{t("Cross Join")}}',Component:"CrossJoinBlockInitializer"}),t.app.schemaInitializerManager.addItem("popup:common:addBlock","otherBlocks.crossJoin",{title:'{{t("Cross Join")}}',Component:"CrossJoinBlockInitializer"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){F(a,r,o,i,l,"next",e)}function l(e){F(a,r,o,i,l,"throw",e)}i(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(L(e.Plugin)),N=_}(),c}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("antd"),require("@formily/react"),require("@nocobase/client"),require("@ant-design/icons")):"function"==typeof define&&define.amd?define("plugin-block-cross-join",["react","antd","@formily/react","@nocobase/client","@ant-design/icons"],t):"object"==typeof exports?exports["plugin-block-cross-join"]=t(require("react"),require("antd"),require("@formily/react"),require("@nocobase/client"),require("@ant-design/icons")):e["plugin-block-cross-join"]=t(e.react,e.antd,e["@formily/react"],e["@nocobase/client"],e["@ant-design/icons"])}(self,function(e,t,r,n,o){return function(){"use strict";var a={375:function(e){e.exports=o},230:function(e){e.exports=r},342:function(e){e.exports=n},59:function(e){e.exports=t},155:function(t){t.exports=e}},i={};function l(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return a[e](r,r.exports,l),r.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(c=l.g.location+"");var c,u=l.g.document;if(!c&&u&&(u.currentScript&&"SCRIPT"===u.currentScript.tagName.toUpperCase()&&(c=u.currentScript.src),!c)){var s=u.getElementsByTagName("script");if(s.length)for(var f=s.length-1;f>-1&&(!c||!/^http(s?):/.test(c));)c=s[f--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");l.p=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var p={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/plugin-block-cross-join/dist/client/")}if(!e){var n=window.__nocobase_modern_client_prefix__||"v",o="/"+(n=String(n).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",i=a.indexOf(o);e=i>=0?a.slice(0,i+1):"/"}e&&(e=e.replace(RegExp("/"+n+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-block-cross-join/dist/client/"}l.p=e}(),!function(){l.r(p),l.d(p,{PluginBlockCrossJoinClient:function(){return q},default:function(){return $}});var e=l(342),t=l(155),r=l.n(t),n=l(230);function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function a(e,t,r,n,o,a,i){try{var l=e[a](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,o)}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var c=(0,t.createContext)(null),u=function(o){var l,u=o.children,s=(0,n.useFieldSchema)(),f=(0,e.useAPIClient)(),p=(null==s?void 0:s["x-decorator-props"])||{},d=p.config,m=(0,t.useMemo)(function(){return d},[JSON.stringify(d)]),y=i((0,t.useState)([]),2),b=y[0],v=y[1],h=i((0,t.useState)(!1),2),g=h[0],S=h[1],w=i((0,t.useState)(1),2),O=w[0],j=w[1],C=i((0,t.useState)((null==(l=p.params)?void 0:l.pageSize)||20),2),E=C[0],x=C[1],k=i((0,t.useState)(0),2),P=k[0],I=k[1],T=(0,t.useCallback)(function(){var e;return(e=function(){var e,t,r,n;return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:c(0)}),l(i,"throw",{value:c(1)}),l(i,"return",{value:c(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function c(l){return function(c){var u=[l,c];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:if(!(null==m||null==(e=m.primarySource)?void 0:e.collection))return[2];S(!0),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,f.request({url:"crossJoin:query",method:"post",data:{config:m,page:O,pageSize:E}})];case 2:return v((null==(n=null==(r=o.sent())?void 0:r.data)?void 0:n.data)||[]),I((null==n||null==(t=n.meta)?void 0:t.count)||0),[3,5];case 3:return console.error("CrossJoin query failed:",o.sent()),v([]),[3,5];case 4:return S(!1),[7];case 5:return[2]}})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function l(e){a(i,n,o,l,c,"next",e)}function c(e){a(i,n,o,l,c,"throw",e)}l(void 0)})})()},[f,m,O,E]);return(0,t.useEffect)(function(){T()},[T]),r().createElement(c.Provider,{value:{data:b,loading:g,pagination:{page:O,pageSize:E,total:P},config:m,refresh:T,setPage:j,setPageSize:x}},u)},s=l(59);function f(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var d=function(){var e,n=(0,t.useContext)(c),o=(0,t.useMemo)(function(){if(!(null==n||null==(i=n.data)?void 0:i.length))return[];var e=n.config;if(null==e||null==(l=e.columns)?void 0:l.length){var t=[],r=!0,o=!1,a=void 0;try{for(var i,l,c,u=e.columns[Symbol.iterator]();!(r=(c=u.next()).done);r=!0){var s=c.value;if(null==(y=s.jsonExpand)?void 0:y.length){var p=!0,d=!1,m=void 0;try{for(var y,b,v=s.jsonExpand[Symbol.iterator]();!(p=(b=v.next()).done);p=!0){var h=b.value,g=s.alias?"".concat(s.alias,".").concat(h):"".concat(s.field,".").concat(h);t.push({title:g,dataIndex:g,key:g,ellipsis:!0,render:function(e){return null!=e?String(e):"-"}})}}catch(e){d=!0,m=e}finally{try{p||null==v.return||v.return()}finally{if(d)throw m}}}else{var S=s.alias||s.field;t.push({title:S,dataIndex:S,key:S,ellipsis:!0,render:function(e){return null==e?"-":(void 0===e?"undefined":f(e))==="object"?JSON.stringify(e):String(e)}})}}}catch(e){o=!0,a=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw a}}return t}return Object.keys(n.data[0]).map(function(e){return{title:e,dataIndex:e,key:e,ellipsis:!0,render:function(t,r){var n=r[e];return null==n?"-":(void 0===n?"undefined":f(n))==="object"?JSON.stringify(n):String(n)}}})},[null==n?void 0:n.data,null==n?void 0:n.config]);return n?n.loading?r().createElement("div",{style:{textAlign:"center",padding:40}},r().createElement(s.Spin,null)):(null==(e=n.data)?void 0:e.length)?r().createElement(s.Table,{dataSource:n.data,columns:o,rowKey:function(e,t){return String(t)},size:"middle",scroll:{x:"max-content"},pagination:{current:n.pagination.page,pageSize:n.pagination.pageSize,total:n.pagination.total,showSizeChanger:!0,showTotal:function(e){return"Total ".concat(e," rows")},onChange:function(e,t){n.setPage(e),n.setPageSize(t)}}}):r().createElement(s.Empty,{description:"No data"}):null},m=l(375);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||S(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){if(e){if("string"==typeof e)return y(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return y(e,t)}}var w=s.Typography.Text;function O(){var r=(0,e.useDataSourceManager)(),n=(null==r?void 0:r.getDataSources())||[];return(0,t.useMemo)(function(){return n.filter(function(e){return"loaded"===e.status}).map(function(e){return{label:e.displayName||e.key,value:e.key,ds:e}})},[n])}function j(r){var n=(0,e.useDataSourceManager)();return(0,t.useMemo)(function(){if(!r||!n)return[];var e=n.getDataSource(r);return e?(e.collectionManager.getCollections()||[]).map(function(e){return{label:e.title||e.name,value:e.name}}):[]},[n,r])}function C(r,n){var o=(0,e.useDataSourceManager)();return(0,t.useMemo)(function(){if(!r||!n||!o)return[];var e=o.getDataSource(r);if(!e)return[];var t=e.collectionManager.getCollection(n);return t?(t.getFields()||[]).map(function(e){var t;return{label:(null==(t=e.uiSchema)?void 0:t.title)||e.name,value:e.name,type:e.type,interface:e.interface}}):[]},[o,r,n])}var E=function(e){var t=e.value,n=e.onChange,o=O(),a=j(t.dataSource);return r().createElement(s.Form,{layout:"vertical"},r().createElement(s.Form.Item,{label:"Datasource"},r().createElement(s.Select,{value:t.dataSource,options:o,placeholder:"Select datasource",onChange:function(e){return n({dataSource:e,collection:""})},showSearch:!0,filterOption:function(e,t){var r;return null==t||null==(r=t.label)?void 0:r.toLowerCase().includes(e.toLowerCase())}})),r().createElement(s.Form.Item,{label:"Collection"},r().createElement(s.Select,{value:t.collection||void 0,options:a,placeholder:"Select collection",onChange:function(e){return n(v(b({},t),{collection:e}))},showSearch:!0,filterOption:function(e,t){var r;return null==t||null==(r=t.label)?void 0:r.toLowerCase().includes(e.toLowerCase())},disabled:!t.dataSource})))},x=function(e){var t=e.join,n=e.index,o=e.primaryDs,a=e.primaryCollection,i=e.onChange,l=e.onRemove,c=O(),u=j(t.dataSource),f=C(o,a),p=C(t.dataSource,t.collection);return r().createElement("div",{style:{border:"1px solid #d9d9d9",borderRadius:6,padding:16,marginBottom:12}},r().createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:8}},r().createElement(w,{strong:!0},"Join #",n+1),r().createElement(s.Button,{type:"text",danger:!0,icon:r().createElement(m.DeleteOutlined,null),onClick:function(){return l(n)}})),r().createElement(s.Form,{layout:"vertical",size:"small"},r().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12}},r().createElement(s.Form.Item,{label:"Datasource",style:{marginBottom:8}},r().createElement(s.Select,{value:t.dataSource,options:c,onChange:function(e){return i(n,v(b({},t),{dataSource:e,collection:"",rightField:""}))},showSearch:!0,filterOption:function(e,t){var r;return null==t||null==(r=t.label)?void 0:r.toLowerCase().includes(e.toLowerCase())}})),r().createElement(s.Form.Item,{label:"Collection",style:{marginBottom:8}},r().createElement(s.Select,{value:t.collection||void 0,options:u,onChange:function(e){return i(n,v(b({},t),{collection:e,rightField:""}))},disabled:!t.dataSource,showSearch:!0,filterOption:function(e,t){var r;return null==t||null==(r=t.label)?void 0:r.toLowerCase().includes(e.toLowerCase())}}))),r().createElement(s.Form.Item,{label:"Join Type",style:{marginBottom:8}},r().createElement(s.Radio.Group,{value:t.joinType,onChange:function(e){return i(n,v(b({},t),{joinType:e.target.value}))}},r().createElement(s.Radio,{value:"left"},"Left Join"),r().createElement(s.Radio,{value:"inner"},"Inner Join"))),r().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12}},r().createElement(s.Form.Item,{label:"Left Field (primary)",style:{marginBottom:0}},r().createElement(s.Select,{value:t.leftField||void 0,options:f,onChange:function(e){return i(n,v(b({},t),{leftField:e}))},placeholder:"Field from primary",showSearch:!0,filterOption:function(e,t){var r;return null==t||null==(r=t.label)?void 0:r.toLowerCase().includes(e.toLowerCase())}})),r().createElement(s.Form.Item,{label:"Right Field (join)",style:{marginBottom:0}},r().createElement(s.Select,{value:t.rightField||void 0,options:p,onChange:function(e){return i(n,v(b({},t),{rightField:e}))},placeholder:"Field from join table",disabled:!t.collection,showSearch:!0,filterOption:function(e,t){var r;return null==t||null==(r=t.label)?void 0:r.toLowerCase().includes(e.toLowerCase())}})))))},k=function(e){var t=e.joins,n=e.primaryDs,o=e.primaryCollection,a=e.onChange,i=function(e,r){var n=g(t);n[e]=r,a(n)},l=function(e){a(t.filter(function(t,r){return r!==e}))};return r().createElement("div",null,t.map(function(e,t){return r().createElement(x,{key:t,join:e,index:t,primaryDs:n,primaryCollection:o,onChange:i,onRemove:l})}),r().createElement(s.Button,{type:"dashed",icon:r().createElement(m.PlusOutlined,null),onClick:function(){a(g(t).concat([{dataSource:"main",collection:"",joinType:"left",leftField:"",rightField:""}]))},block:!0},"Add Join"))},P=function(e){var n=e.columns,o=e.primaryDs,a=e.primaryCollection,i=(e.joins,e.onChange),l=C(o,a),c=(0,t.useMemo)(function(){var e=[],t=!0,r=!1,n=void 0;try{for(var o,i=l[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var c=o.value;e.push({source:0,sourceName:a,field:c.value,label:"".concat(a,".").concat(c.label),type:c.type})}}catch(e){r=!0,n=e}finally{try{t||null==i.return||i.return()}finally{if(r)throw n}}return e},[l,a]),u=(0,t.useCallback)(function(){i(c.map(function(e){return{source:e.source,field:e.field,selected:!0}}))},[c,i]),f=[{title:"Include",dataIndex:"selected",width:70,render:function(e,t,o){return r().createElement(s.Checkbox,{checked:!1!==t.selected,onChange:function(e){var t=g(n);t[o]=v(b({},t[o]),{selected:e.target.checked}),i(t)}})}},{title:"Source",dataIndex:"source",width:100,render:function(e){return 0===e?"Primary":"Join #".concat(e)}},{title:"Field",dataIndex:"field",width:150},{title:"Alias",dataIndex:"alias",width:150,render:function(e,t,o){return r().createElement(s.Input,{size:"small",value:t.alias||"",placeholder:t.field,onChange:function(e){var t=g(n);t[o]=v(b({},t[o]),{alias:e.target.value||void 0}),i(t)}})}}];return r().createElement("div",null,r().createElement("div",{style:{marginBottom:12}},r().createElement(s.Button,{size:"small",onClick:u},"Auto-populate from sources")),n.length>0?r().createElement(s.Table,{dataSource:n,columns:f,rowKey:function(e,t){return String(t)},size:"small",pagination:!1,scroll:{y:300}}):r().createElement(w,{type:"secondary"},'Click "Auto-populate" to add fields from all configured sources, or they will be auto-detected at runtime.'))},I=function(e){var n=e.visible,o=e.onCancel,a=e.onSubmit,i=e.initialConfig,l=h((0,t.useState)((null==i?void 0:i.primarySource)||{dataSource:"main",collection:""}),2),c=l[0],u=l[1],f=h((0,t.useState)((null==i?void 0:i.joins)||[]),2),p=f[0],d=f[1],m=h((0,t.useState)((null==i?void 0:i.columns)||[]),2),y=m[0],b=m[1],v=c.dataSource&&c.collection;return r().createElement(s.Modal,{title:"Configure Cross Join",open:n,onCancel:o,onOk:function(){a({primarySource:c,joins:p,columns:y.filter(function(e){return!1!==e.selected}).map(function(e){return e.selected,function(e,t){if(null==e)return{};var r,n,o,a={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,r=Reflect.ownKeys(Object(e));o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}if(a=function(e,t){if(null==e)return{};var r,n,o={},a=Object.getOwnPropertyNames(e);for(n=0;n<a.length;n++)r=a[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}(e,["selected"])})})},okButtonProps:{disabled:!v},width:720,destroyOnClose:!0},r().createElement(s.Tabs,{items:[{key:"primary",label:"Primary Source",children:r().createElement(E,{value:c,onChange:u})},{key:"joins",label:"Joins (".concat(p.length,")"),children:r().createElement(k,{joins:p,primaryDs:c.dataSource,primaryCollection:c.collection,onChange:d})},{key:"columns",label:"Columns",children:r().createElement(P,{columns:y,primaryDs:c.dataSource,primaryCollection:c.collection,joins:p,onChange:b})}]}))};function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var _=function(){var n,o,a,i=(0,e.useSchemaInitializer)().insert,l=(0,e.useSchemaInitializerItem)(),c=function(e){if(Array.isArray(e))return e}(n=(0,t.useState)(!1))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw r}}return o}}(n)||function(e){if(e){if("string"==typeof e)return T(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return T(e,2)}}(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=c[0],s=c[1];return r().createElement(r().Fragment,null,r().createElement(e.SchemaInitializerItem,(o=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},l),a=a={icon:r().createElement(m.MergeCellsOutlined,null),onClick:function(){return s(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(a)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(a)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(a,e))}),o)),r().createElement(I,{visible:u,onCancel:function(){return s(!1)},onSubmit:function(e){i({type:"void","x-settings":"blockSettings:crossJoin","x-toolbar":"BlockSchemaToolbar","x-decorator":"CrossJoinBlockProvider","x-decorator-props":{config:e,params:{pageSize:20}},"x-component":"CardItem","x-component-props":{name:"crossJoin"},properties:{table:{type:"void","x-component":"CrossJoinTable"}}}),s(!1)}}))};function A(e,t,r,n,o,a,i){try{var l=e[a](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,o)}var B=new e.SchemaSettings({name:"blockSettings:crossJoin",items:[{name:"title",Component:e.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:e.SchemaSettingsBlockHeightItem},{name:"editMapping",type:"modal",useComponentProps:function(){return{title:"Edit Mapping",onSubmit:function(){var e;return(e=function(){return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:c(0)}),l(i,"throw",{value:c(1)}),l(i,"return",{value:c(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function c(l){return function(c){var u=[l,c];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){A(a,n,o,i,l,"next",e)}function l(e){A(a,n,o,i,l,"throw",e)}i(void 0)})})()}}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]});function F(e,t,r,n,o,a,i){try{var l=e[a](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,o)}function J(e,t,r){return(J=R()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&D(o,r.prototype),o}).apply(null,arguments)}function M(e){return(M=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t){return(D=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function z(e){var t="function"==typeof Map?new Map:void 0;return(z=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return J(e,arguments,M(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),D(r,e)})(e)}function R(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(R=function(){return!!e})()}var L=function(t){var n=t.children;return r().createElement(e.SchemaComponentOptions,{components:{CrossJoinBlockProvider:u,CrossJoinTable:d,CrossJoinBlockInitializer:_}},n)},q=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=M(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,R()?Reflect.construct(e,t||[],M(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&D(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:c(0)}),l(i,"throw",{value:c(1)}),l(i,"return",{value:c(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function c(l){return function(c){var u=[l,c];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.app.use(L),this.app.schemaSettingsManager.add(B),this.app.schemaInitializerManager.addItem("page:addBlock","otherBlocks.crossJoin",{title:'{{t("Cross Join")}}',Component:"CrossJoinBlockInitializer"}),this.app.schemaInitializerManager.addItem("popup:common:addBlock","otherBlocks.crossJoin",{title:'{{t("Cross Join")}}',Component:"CrossJoinBlockInitializer"}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){F(a,n,o,i,l,"next",e)}function l(e){F(a,n,o,i,l,"throw",e)}i(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(z(e.Plugin)),$=q}(),p}()});
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@nocobase/client-v2")):"function"==typeof define&&define.amd?define("plugin-block-cross-join/client-v2",["@nocobase/client-v2"],e):"object"==typeof exports?exports["plugin-block-cross-join/client-v2"]=e(require("@nocobase/client-v2")):t["plugin-block-cross-join/client-v2"]=e(t["@nocobase/client-v2"])}(self,function(t){return function(){"use strict";var e={485:function(e){e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.g.importScripts&&(o=n.g.location+"");var o,i=n.g.document;if(!o&&i&&(i.currentScript&&"SCRIPT"===i.currentScript.tagName.toUpperCase()&&(o=i.currentScript.src),!o)){var c=i.getElementsByTagName("script");if(c.length)for(var u=c.length-1;u>-1&&(!o||!/^http(s?):/.test(o));)o=c[u--].src}if(!o)throw Error("Automatic publicPath is not supported in this browser");n.p=o.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var a={};return!function(){var t="",e="u">typeof document?document.currentScript:null;if(e&&e.src&&(t=e.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!t){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),t=r+"static/plugins/plugin-block-cross-join/dist/client-v2/")}if(!t){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(t=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var c=window.location.pathname||"/",u=c.indexOf(i);t=u>=0?c.slice(0,u+1):"/"}t&&(t=t.replace(RegExp("/"+o+"/?$"),"/")),t||(t="/"),"/"!==t.charAt(t.length-1)&&(t+="/"),t+="static/plugins/plugin-block-cross-join/dist/client-v2/"}n.p=t}(),!function(){n.r(a),n.d(a,{default:function(){return l}});var t=n(485);function e(t,e,r,n,o,i,c){try{var u=t[i](c),a=u.value}catch(t){r(t);return}u.done?e(a):Promise.resolve(a).then(n,o)}function r(t,e,n){return(r=u()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&i(o,r.prototype),o}).apply(null,arguments)}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t){var e="function"==typeof Map?new Map:void 0;return(c=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return r(t,arguments,o(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),i(n,t)})(t)}function u(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(u=function(){return!!t})()}var l=function(t){var r;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,e;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,e=arguments,t=o(t),function(t,e){var r;if(e&&("object"==((r=e)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,u()?Reflect.construct(t,e||[],o(this).constructor):t.apply(this,e))}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&i(n,t),r=[{key:"load",value:function(){var t;return(t=function(){return function(t,e){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(c,"next",{value:a(0)}),u(c,"throw",{value:a(1)}),u(c,"return",{value:a(2)}),"function"==typeof Symbol&&u(c,Symbol.iterator,{value:function(){return this}}),c;function a(u){return function(a){var l=[u,a];if(r)throw TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=e.call(t,i)}catch(t){l=[6,t],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(t){return[2]})},function(){var r=this,n=arguments;return new Promise(function(o,i){var c=t.apply(r,n);function u(t){e(c,o,i,u,a,"next",t)}function a(t){e(c,o,i,u,a,"throw",t)}u(void 0)})})()}}],function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}(n.prototype,r),n}(c(t.Plugin))}(),a}()});
@@ -10,9 +10,10 @@
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
12
  "@ant-design/icons": "5.6.1",
13
- "@nocobase/client": "2.0.38",
13
+ "@nocobase/client": "2.1.6",
14
14
  "@formily/react": "2.3.7",
15
15
  "antd": "5.24.2",
16
- "@nocobase/server": "2.0.38",
17
- "@nocobase/actions": "2.0.38"
16
+ "@nocobase/client-v2": "2.1.6",
17
+ "@nocobase/server": "2.1.6",
18
+ "@nocobase/actions": "2.1.6"
18
19
  };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var cross_join_exports = {};
28
+ __export(cross_join_exports, {
29
+ default: () => cross_join_default
30
+ });
31
+ module.exports = __toCommonJS(cross_join_exports);
32
+ var cross_join_default = {
33
+ name: "crossJoin",
34
+ dumpRules: "skip",
35
+ autoGenId: true,
36
+ createdAt: false,
37
+ updatedAt: false,
38
+ fields: [
39
+ {
40
+ name: "name",
41
+ type: "string"
42
+ }
43
+ ]
44
+ };
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var plugin_exports = {};
28
38
  __export(plugin_exports, {
@@ -32,7 +42,11 @@ __export(plugin_exports, {
32
42
  module.exports = __toCommonJS(plugin_exports);
33
43
  var import_server = require("@nocobase/server");
34
44
  var import_cross_join_query = require("./actions/cross-join-query");
45
+ var import_path = __toESM(require("path"));
35
46
  class PluginBlockCrossJoinServer extends import_server.Plugin {
47
+ async beforeLoad() {
48
+ await this.db.import({ directory: import_path.default.resolve(__dirname, "collections") });
49
+ }
36
50
  async load() {
37
51
  this.app.resourcer.define({
38
52
  name: "crossJoin",
package/package.json CHANGED
@@ -1,33 +1,44 @@
1
- {
2
- "name": "plugin-block-cross-join",
3
- "displayName": "Block: Cross Join",
4
- "displayName.zh-CN": "区块:跨数据源联合查询",
5
- "description": "Create a block that joins and displays data from multiple collections across different datasources in a single unified table.",
6
- "description.zh-CN": "创建一个区块,可以跨不同数据源联合查询多个表的数据,并在单一表格中展示。",
7
- "version": "0.1.2",
8
- "license": "Apache-2.0",
9
- "main": "./dist/server/index.js",
10
- "files": [
11
- "dist",
12
- "client.js",
13
- "client.d.ts",
14
- "server.js",
15
- "server.d.ts"
16
- ],
17
- "devDependencies": {
18
- "@ant-design/icons": "5.x",
19
- "@formily/react": "2.x",
20
- "@formily/shared": "2.x",
21
- "antd": "5.x",
22
- "react": "^18.2.0",
23
- "react-i18next": "^11.15.1"
24
- },
25
- "peerDependencies": {
26
- "@nocobase/client": "2.x",
27
- "@nocobase/server": "2.x",
28
- "@nocobase/data-source-manager": "2.x"
29
- },
30
- "keywords": [
31
- "Blocks"
32
- ]
33
- }
1
+ {
2
+ "name": "plugin-block-cross-join",
3
+ "displayName": "Block: Cross Join",
4
+ "displayName.zh-CN": "区块:跨数据源联合查询",
5
+ "description": "Create a block that joins and displays data from multiple collections across different datasources in a single unified table.",
6
+ "description.zh-CN": "创建一个区块,可以跨不同数据源联合查询多个表的数据,并在单一表格中展示。",
7
+ "version": "0.1.4",
8
+ "license": "Apache-2.0",
9
+ "main": "dist/server/index.js",
10
+ "files": [
11
+ "dist",
12
+ "client.js",
13
+ "client.d.ts",
14
+ "server.js",
15
+ "server.d.ts",
16
+ "client-v2.js",
17
+ "client-v2.d.ts",
18
+ "src"
19
+ ],
20
+ "devDependencies": {
21
+ "@ant-design/icons": "5.x",
22
+ "@formily/react": "2.x",
23
+ "@formily/shared": "2.x",
24
+ "antd": "5.x",
25
+ "react": "^18.2.0",
26
+ "react-i18next": "^11.15.1"
27
+ },
28
+ "peerDependencies": {
29
+ "@nocobase/client": "2.x",
30
+ "@nocobase/server": "2.x",
31
+ "@nocobase/data-source-manager": "2.x",
32
+ "@nocobase/client-v2": "2.x",
33
+ "@nocobase/flow-engine": "2.x"
34
+ },
35
+ "keywords": [
36
+ "Blocks"
37
+ ],
38
+ "nocobase": {
39
+ "supportedVersions": [
40
+ "2.x"
41
+ ],
42
+ "editionLevel": 0
43
+ }
44
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ import React, { useState } from 'react';
11
+ import { MergeCellsOutlined } from '@ant-design/icons';
12
+ import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@nocobase/client';
13
+ import { CrossJoinConfigurator } from './CrossJoinConfigurator';
14
+ import { createCrossJoinBlockUISchema } from './createBlockUISchema';
15
+
16
+ export const CrossJoinBlockInitializer: React.FC = () => {
17
+ const { insert } = useSchemaInitializer();
18
+ const itemConfig = useSchemaInitializerItem();
19
+ const [visible, setVisible] = useState(false);
20
+
21
+ return (
22
+ <>
23
+ <SchemaInitializerItem {...itemConfig} icon={<MergeCellsOutlined />} onClick={() => setVisible(true)} />
24
+ <CrossJoinConfigurator
25
+ visible={visible}
26
+ onCancel={() => setVisible(false)}
27
+ onSubmit={(config) => {
28
+ insert(createCrossJoinBlockUISchema(config));
29
+ setVisible(false);
30
+ }}
31
+ />
32
+ </>
33
+ );
34
+ };
@@ -0,0 +1,88 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ import React, { createContext, useContext, useEffect, useState, useCallback, useMemo } from 'react';
11
+ import { useFieldSchema } from '@formily/react';
12
+ import { useAPIClient } from '@nocobase/client';
13
+
14
+ interface CrossJoinContextValue {
15
+ data: Record<string, any>[];
16
+ loading: boolean;
17
+ pagination: { page: number; pageSize: number; total: number };
18
+ config: any;
19
+ refresh: () => void;
20
+ setPage: (page: number) => void;
21
+ setPageSize: (size: number) => void;
22
+ }
23
+
24
+ const CrossJoinContext = createContext<CrossJoinContextValue | null>(null);
25
+
26
+ export const useCrossJoinContext = () => {
27
+ return useContext(CrossJoinContext);
28
+ };
29
+
30
+ export const CrossJoinBlockProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
31
+ const fieldSchema = useFieldSchema();
32
+ const api = useAPIClient();
33
+ const decoratorProps = fieldSchema?.['x-decorator-props'] || {};
34
+ const rawConfig = decoratorProps.config;
35
+ // eslint-disable-next-line react-hooks/exhaustive-deps
36
+ const config = useMemo(() => rawConfig, [JSON.stringify(rawConfig)]);
37
+
38
+ const [data, setData] = useState<Record<string, any>[]>([]);
39
+ const [loading, setLoading] = useState(false);
40
+ const [page, setPage] = useState(1);
41
+ const [pageSize, setPageSize] = useState(decoratorProps.params?.pageSize || 20);
42
+ const [total, setTotal] = useState(0);
43
+
44
+ const fetchData = useCallback(async () => {
45
+ if (!config?.primarySource?.collection) return;
46
+
47
+ setLoading(true);
48
+ try {
49
+ const res = await api.request({
50
+ url: 'crossJoin:query',
51
+ method: 'post',
52
+ data: {
53
+ config,
54
+ page,
55
+ pageSize,
56
+ },
57
+ });
58
+ const body = res?.data;
59
+ setData(body?.data || []);
60
+ setTotal(body?.meta?.count || 0);
61
+ } catch (err) {
62
+ console.error('CrossJoin query failed:', err);
63
+ setData([]);
64
+ } finally {
65
+ setLoading(false);
66
+ }
67
+ }, [api, config, page, pageSize]);
68
+
69
+ useEffect(() => {
70
+ fetchData();
71
+ }, [fetchData]);
72
+
73
+ return (
74
+ <CrossJoinContext.Provider
75
+ value={{
76
+ data,
77
+ loading,
78
+ pagination: { page, pageSize, total },
79
+ config,
80
+ refresh: fetchData,
81
+ setPage,
82
+ setPageSize,
83
+ }}
84
+ >
85
+ {children}
86
+ </CrossJoinContext.Provider>
87
+ );
88
+ };