@nocobase/plugin-ui-templates 3.0.0-alpha.11 → 3.0.0-alpha.13
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/dist/client/{285.4bc78a19e0774a30.js → 285.5eb4562bd2428b91.js} +1 -1
- package/dist/client/934.0cc4e03a5a8aad6a.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +8 -8
- package/package.json +2 -2
- package/dist/client/934.5dd36051e3d71be1.js +0 -10
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_ui_templates=self.webpackChunk_nocobase_plugin_ui_templates||[]).push([["285"],{964:function(e,t,r){r.r(t),r.d(t,{ReferenceBlockModel:function(){return B}});var n=r(155),o=r.n(n),l=r(773),i=r.n(l),a=r(694),s=r(488),u=r(485),c=r(898),d=r(912),f=r(420),p=r(396),v=r(277);function h(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 g(e,t,r,n,o,l,i){try{var a=e[l](i),s=a.value}catch(e){r(e);return}a.done?t(s):Promise.resolve(s).then(n,o)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var l=e.apply(t,r);function i(e){g(l,n,o,i,a,"next",e)}function a(e){g(l,n,o,i,a,"throw",e)}i(void 0)})}}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e,t,r){return(b="u">typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=S(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(r||e):o.value}})(e,t,r||e)}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function T(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){y(e,t,r[t])})}return e}function w(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 P(e,t){if(t&&("object"===x(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function M(e,t){return(M=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(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 l=[],i=!0,a=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(l.push(r.value),!t||l.length!==t);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw n}}return l}}(e,t)||F(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 x(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function F(e,t){if(e){if("string"==typeof e)return h(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 h(e,t)}}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(E=function(){return!!e})()}function R(e,t){var r,n,o,l={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),a=Object.defineProperty;return a(i,"next",{value:s(0)}),a(i,"throw",{value:s(1)}),a(i,"return",{value:s(2)}),"function"==typeof Symbol&&a(i,Symbol.iterator,{value:function(){return this}}),i;function s(a){return function(s){var u=[a,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(l=0)),l;)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 l.label++,{value:u[1],done:!1};case 5:l.label++,n=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){l.label=u[1];break}if(6===u[0]&&l.label<o[1]){l.label=o[1],o=u;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(u);break}o[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}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}}}}var O=Symbol.for("nocobase.referenceBlockTargetContextBridge"),I=Symbol.for("nocobase.referenceBlockTargetEventBridge.originalDispatch"),A=Symbol.for("nocobase.referenceBlockTemplateFallback.originalGetStepParams"),j=Symbol.for("nocobase.referenceBlockTargetOwnContextMissing");function U(e,t){var r,n,o,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null==(r=null==t?void 0:t.filterByTk)||""===r||(null!=(n=null==t?void 0:t.collectionName)?n:null==l?void 0:l.collectionName)!==(null==e?void 0:e.collectionName))return!0;var i=null!=(o=null==t?void 0:t.dataSourceKey)?o:null==l?void 0:l.dataSourceKey;return null!=i&&""!==String(i).trim()&&i!==(null==e?void 0:e.dataSourceKey)}var B=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(e){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");t=r,n=[e],t=S(t),y(o=P(this,E()?Reflect.construct(t,n||[],S(this).constructor):t.apply(this,n)),"settingsMenuLevel",2),y(o,"_scopedEngine",void 0),y(o,"_targetModel",void 0),y(o,"_localProps",void 0),y(o,"_resolvedTargetUid",void 0),y(o,"_invalidTargetUid",void 0);var t,n,o,l=new Proxy(o,{get:function(e,t,r){var n=e._targetModel;if(n){if("props"===t)return n.props;if("setProps"===t&&"function"==typeof n.setProps)return function(){for(var t=arguments.length,r=Array(t),o=0;o<t;o++)r[o]=arguments[o];var l=n.setProps.apply(n,function(e){if(Array.isArray(e))return h(e)}(r)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||F(r)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());try{e.props=n.props}catch(e){}return l};if("getProps"===t&&"function"==typeof n.getProps)return n.getProps.bind(n)}if(t in e){var o=Reflect.get(e,t,e);return"function"==typeof o&&"constructor"!==t?o.bind(e):o}if(n){var l=Reflect.get(n,t,n);if("function"==typeof l&&"constructor"!==t)return l.bind(n);if(void 0!==l)return l}},set:function(e,t,r,n){var o=e._targetModel;if(o&&"props"===t){var l=Reflect.set(o,t,r,o);try{e.props=o.props}catch(e){}return l}return t in e?Reflect.set(e,t,r,e):o&&t in o?Reflect.set(o,t,r,o):Reflect.set(e,t,r,e)},has:function(e,t){if(t in e)return!0;var r=e._targetModel;return!!r&&t in r},ownKeys:function(e){var t=new Set(Reflect.ownKeys(e)),r=e._targetModel;if(r){var n=!0,o=!1,l=void 0;try{for(var i,a=Reflect.ownKeys(r)[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var s=i.value;t.add(s)}}catch(e){o=!0,l=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw l}}}return Array.from(t)},getOwnPropertyDescriptor:function(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r)return r;var n=e._targetModel;if(n)return Object.getOwnPropertyDescriptor(n,t)||void 0}});return P(o,l)}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&M(r,e),t=[{key:"_getFilterStateTarget",value:function(){return this._targetModel}},{key:"_getReferenceFilterManager",value:function(){var e;return null==(e=this.context)?void 0:e.filterManager}},{key:"_markShellInitialFilterRefreshHandled",value:function(){var e,t,r=this,n=null==(t=this._getReferenceFilterManager())||null==(e=t.getFilterConfigs)?void 0:e.call(t);Array.isArray(n)&&new Set(n.filter(function(e){return e.targetId===r.uid&&"string"==typeof e.filterId&&e.filterId}).map(function(e){return e.filterId})).forEach(function(e){try{var t,n,o,l,i,a=null==(n=r.flowEngine)||null==(t=n.getModel)?void 0:t.call(n,e);null==a||null==(i=a.context)||null==(l=i.blockModel)||null==(o=l.markInitialTargetRefreshHandled)||o.call(l,r.uid)}catch(e){}})}},{key:"_createTargetFilterManager",value:function(e){var t=this,r=this._getReferenceFilterManager();if(r){var n=function(r){return r===e.uid?t.uid:r};return new Proxy(r,{get:function(e,t){if("prepareFiltersForTarget"===t){if("function"!=typeof e.prepareFiltersForTarget)return;return function(t){var r;return null==(r=e.prepareFiltersForTarget)?void 0:r.call(e,n(t))}}if("bindToTarget"===t){if("function"!=typeof e.bindToTarget)return;return function(t){var r;return null==(r=e.bindToTarget)?void 0:r.call(e,n(t))}}var r=Reflect.get(e,t,e);return"function"==typeof r?r.bind(e):r}})}}},{key:"setFilterActive",value:function(e,t){b(S(r.prototype),"setFilterActive",this).call(this,e,t);var n,o=this._getFilterStateTarget();null==o||null==(n=o.setFilterActive)||n.call(o,e,t)}},{key:"hasActiveFilters",value:function(){var e,t;return b(S(r.prototype),"hasActiveFilters",this).call(this)||(null==(t=this._getFilterStateTarget())||null==(e=t.hasActiveFilters)?void 0:e.call(t))===!0}},{key:"removeFilterSource",value:function(e){var t,n;b(S(r.prototype),"removeFilterSource",this).call(this,e),null==(n=this._getFilterStateTarget())||null==(t=n.removeFilterSource)||t.call(n,e)}},{key:"getDataLoadingMode",value:function(){var e,t;return(null==(t=this._getFilterStateTarget())||null==(e=t.getDataLoadingMode)?void 0:e.call(t))||b(S(r.prototype),"getDataLoadingMode",this).call(this)}},{key:"_restoreTemplateFallbackPatch",value:function(e){if(e){var t=e[A];t&&(e.getStepParams=t,delete e[A],this._refreshTargetResourceState(e))}}},{key:"_restoreTargetEventBridge",value:function(e){if(e){var t=e[I];t&&(e.dispatchEvent=t,delete e[I])}}},{key:"_getForwardedTargetEventFlows",value:function(e){return!e||b(S(r.prototype),"getEvent",this).call(this,e)?new Map:new Map(Array.from(this.getFlows().entries()).filter(function(t){var r=k(t,2)[1],n=null==r?void 0:r.on;return!!n&&("string"==typeof n?n===e:(void 0===n?"undefined":x(n))==="object"&&n.eventName===e)}))}},{key:"_shouldForwardTargetEvent",value:function(e,t){return!(!t||!e||b(S(r.prototype),"getEvent",this).call(this,e))&&!!t.getEvent(e)}},{key:"_applyTargetEventBridge",value:function(e){if(e&&!e[I]){var t=e.dispatchEvent;if("function"==typeof t){e[I]=t;var r=this;e.dispatchEvent=function(n,o,l){return m(function(){var i,a,s,u,c,d,f;return R(this,function(p){switch(p.label){case 0:if(!r._shouldForwardTargetEvent(n,e)||!(u=r._getForwardedTargetEventFlows(n)).size)return[2,t.call(this,n,o,l)];c=null==(i=this.getFlows)?void 0:i.bind(this),d=null==(a=this.getFlow)?void 0:a.bind(this),f=null==(s=this.getStepParams)?void 0:s.bind(this),this.getFlows=function(){var e=c?c():new Map,t=!0,r=!1,n=void 0;try{for(var o,l=u.entries()[Symbol.iterator]();!(t=(o=l.next()).done);t=!0){var i=k(o.value,2),a=i[0],s=i[1];e.has(a)||e.set(a,s)}}catch(e){r=!0,n=e}finally{try{t||null==l.return||l.return()}finally{if(r)throw n}}return e},this.getFlow=function(e){return u.has(e)?u.get(e):null==d?void 0:d(e)},this.getStepParams=function(e,t){if(u.has(e)){var n=r.getStepParams(e,t);if(void 0!==n)return n}return null==f?void 0:f(e,t)},p.label=1;case 1:return p.trys.push([1,,3,4]),[4,t.call(this,n,o,l)];case 2:return[2,p.sent()];case 3:return this.getFlows=c,this.getFlow=d,this.getStepParams=f,[7];case 4:return[2]}})}).call(this)}}}}},{key:"_shouldTemplateFallbackToList",value:function(e){var t,r,n;return U(e,(null===this||void 0===this||null==(r=this.context)||null==(t=r.view)?void 0:t.inputArgs)||{},(null==(n=this.getStepParams)?void 0:n.call(this,"resourceSettings","init"))||{})}},{key:"_refreshTargetResourceState",value:function(e){if(e){var t,r,n,o,l,i,s,u,c,d=(null==(t=e.getStepParams)?void 0:t.call(e,"resourceSettings","init"))||{},f=null==e||null==(r=e.association)?void 0:r.type,p="hasOne"===f||"belongsTo"===f||Object.keys(d).includes("filterByTk"),v=null==(n=e.context)?void 0:n.resource,h=(null==v||null==(o=v.getAppends)?void 0:o.call(v))||[];if(!v||p&&!_(v,a.SingleRecordResource)||!p&&!_(v,a.MultiRecordResource))try{null==(i=e.context)||null==(l=i.removeCache)||l.call(i,"resource")}catch(e){}h.length&&(null==(c=e.context)||null==(u=c.resource)||null==(s=u.addAppends)||s.call(u,h))}}},{key:"_applyTemplateFallbackPatchState",value:function(e){if(e){var t,r,n=this.getStepParams("referenceSettings","useTemplate")||{},o=String((null==n?void 0:n.templateUid)||"").trim(),l=(null==n?void 0:n.mode)||(null==(t=this.getStepParams("referenceSettings","target")||{})?void 0:t.mode)||"reference",i=null==e||null==(r=e.constructor)?void 0:r.name;if(!(o&&"copy"!==l)||"DetailsBlockModel"!==i&&"EditFormModel"!==i)return void this._restoreTemplateFallbackPatch(e);if(!e[A]){var a=e.getStepParams;e[A]=a;var s=this;e.getStepParams=function(e,t){var r=a.call(this,e,t);if("resourceSettings"===e&&"init"===t&&r&&(void 0===r?"undefined":x(r))==="object"&&Object.prototype.hasOwnProperty.call(r,"filterByTk")&&s._shouldTemplateFallbackToList(r)){var n=T({},r);return delete n.filterByTk,n}return r}}this._refreshTargetResourceState(e)}}},{key:"_bridgeTargetContext",value:function(e,t){var r=this;if((null==e?void 0:e.context)&&this.context){var n=e.context;if(!n[O]){var o=new a.FlowContext;o.defineProperty("engine",{value:t}),o.defineProperty("filterManager",{cache:!1,get:function(){return r._createTargetFilterManager(e)}}),o.addDelegate(this.context),e.context.addDelegate(o),n[O]=!0}}}},{key:"_attachRuntimeTarget",value:function(e){e.parent=this}},{key:"_setRuntimeTargetSubModel",value:function(e){var t,r,n,o,l;this._attachRuntimeTarget(e),this.subModels.target=e,null==(r=this.emitter)||null==(t=r.emit)||t.call(r,"onSubModelAdded",e),null==(l=this.flowEngine)||null==(o=l.emitter)||null==(n=o.emit)||n.call(o,"model:subModel:added",{parentUid:this.uid,parent:this,subKey:"target",model:e})}},{key:"_bindReferenceFiltersToResolvedTarget",value:function(){return m(function(){var e,t,r,n,o;return R(this,function(l){switch(l.label){case 0:if(e=this,!(null==(n=this._getReferenceFilterManager())?void 0:n.prepareFiltersForTarget)&&!(null==n?void 0:n.bindToTarget))return[2];return[4,null==(t=n.prepareFiltersForTarget)?void 0:t.call(n,this.uid)];case 1:return o=l.sent(),null==(r=n.bindToTarget)||r.call(n,this.uid),null==o||o.forEach(function(t){var r;null==t||null==(r=t.markInitialTargetRefreshHandled)||r.call(t,e.uid)}),[2]}})}).call(this)}},{key:"title",get:function(){var e;return(null==(e=this._targetModel)?void 0:e.title)||b(S(r.prototype),"title",this)}},{key:"getEvents",value:function(){var e=b(S(r.prototype),"getEvents",this).call(this),t=null==(a=this._targetModel)||null==(i=a.getEvents)?void 0:i.call(a);if(!t)return e;var n=!0,o=!1,l=void 0;try{for(var i,a,s,u=t.entries()[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){var c=k(s.value,2),d=c[0],f=c[1];e.has(d)||e.set(d,f)}}catch(e){o=!0,l=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw l}}return e}},{key:"getEvent",value:function(e){var t,n;return b(S(r.prototype),"getEvent",this).call(this,e)||(null==(n=this._targetModel)||null==(t=n.getEvent)?void 0:t.call(n,e))}},{key:"onInit",value:function(e){var t=this;b(S(r.prototype),"onInit",this).call(this,e),this._localProps=this.props,this.context.defineProperty("refModel",{get:function(){return t._targetModel},cache:!1});var n=function(e){var r,n,o=null==(r=t._targetModel)?void 0:r.context;if(!o||!o.has(e))return j;try{return o._getOwnProperty(e,(null==(n=o.createProxy)?void 0:n.call(o))||o)}catch(e){return j}};["collection","dataSource","resource","association","resourceName"].forEach(function(e){t.context.defineProperty(e,{cache:!1,get:function(){var r,o,l=n(e);return l!==j?l:null==(o=t.parent)||null==(r=o.context)?void 0:r[e]}})}),this._markShellInitialFilterRefreshHandled()}},{key:"setProps",value:function(e,t){var n=this._targetModel;if(n&&"function"==typeof n.setProps){n.setProps(e,t),this.props=n.props;return}b(S(r.prototype),"setProps",this).call(this,e,t),this._localProps=this.props}},{key:"getProps",value:function(){var e=this._targetModel;return e&&"function"==typeof e.getProps?e.getProps():b(S(r.prototype),"getProps",this).call(this)}},{key:"_getTargetUidFromParams",value:function(){var e=this.getStepParams("referenceSettings","target")||{};return((null==e?void 0:e.targetUid)||"").trim()||void 0}},{key:"_syncExtraTitle",value:function(e){if(!e)return void this.setExtraTitle("");var t=this.context.t("Reference template",{ns:[s.CU,"client"],nsMode:"fallback"}),r=this.getStepParams("referenceSettings","useTemplate")||{},n=(null==r?void 0:r.templateName)||(null==r?void 0:r.templateUid);this.setExtraTitle(n?"".concat(t,": ").concat(n):t)}},{key:"_ensureScopedEngine",value:function(){return this._scopedEngine=(0,v.Ob)(this.flowEngine,this._scopedEngine),(0,v.YT)(this._scopedEngine,this.context),this._scopedEngine}},{key:"_resolveFinalTarget",value:function(e){return m(function(){var t,r,n,o,l,i,a;return R(this,function(s){switch(s.label){case 0:t=this._ensureScopedEngine(),r=new Set,n=e,o=0,s.label=1;case 1:if(!(o<20))return[3,4];if(!n||r.has(n)||n===this.uid)return[2,null];return r.add(n),[4,t.loadModel({uid:n})];case 2:if(!(i=s.sent()))return[2,null];if("ReferenceBlockModel"!==i.constructor.name)return[2,i];if(!(a=null==(l=i.getStepParams("referenceSettings","target"))?void 0:l.targetUid)||"string"!=typeof a||!a.trim())return[2,null];n=String(a).trim(),s.label=3;case 3:return o++,[3,1];case 4:return[2,null]}})}).call(this)}},{key:"onDispatchEventStart",value:function(e){return m(function(){var t,r,n,o,l,i,a,s,u,c,d,f,p,v,h,g,m,y,b,S,_;return R(this,function(T){switch(T.label){case 0:if("beforeRender"!==e)return[2];if(this._markShellInitialFilterRefreshHandled(),!(o=((null==(n=(null==(t=(r=this).getStepParams)?void 0:t.call(r,"referenceSettings","target"))||{})?void 0:n.targetUid)||"").trim()||void 0))return this._syncExtraTitle(!1),(l=this.subModels.target)&&(this._restoreTargetEventBridge(l),this._restoreTemplateFallbackPatch(l),null==(a=this.emitter)||null==(i=a.emit)||i.call(a,"onSubModelRemoved",l),null==(s=this._scopedEngine)||s.removeModel(l.uid)),this._targetModel=void 0,this._resolvedTargetUid=void 0,this._invalidTargetUid=void 0,this.subModels.target=void 0,this._localProps&&(this.props=this._localProps),[2];if(this._syncExtraTitle(!0),this._resolvedTargetUid===o&&this._targetModel)return this._invalidTargetUid=void 0,this._applyTargetEventBridge(this._targetModel),this._applyTemplateFallbackPatchState(this._targetModel),this.props=this._targetModel.props,[2];return this._invalidTargetUid=void 0,[4,this._resolveFinalTarget(o)];case 1:if(u=T.sent())return[3,4];return[4,new Promise(function(e){return setTimeout(e,50)})];case 2:if(T.sent(),(((null==(f=(null==(c=(d=this).getStepParams)?void 0:c.call(d,"referenceSettings","target"))||{})?void 0:f.targetUid)||"").trim()||void 0)!==o)return[2];return[4,this._resolveFinalTarget(o)];case 3:u=T.sent(),T.label=4;case 4:if(!u)return(p=this.subModels.target)&&(this._restoreTargetEventBridge(p),this._restoreTemplateFallbackPatch(p),null==(h=this.emitter)||null==(v=h.emit)||v.call(h,"onSubModelRemoved",p),null==(g=this._scopedEngine)||g.removeModel(p.uid)),this._targetModel=void 0,this._resolvedTargetUid=void 0,this._invalidTargetUid=o,this.subModels.target=void 0,this._localProps&&(this.props=this._localProps),[2];return m=this._ensureScopedEngine(),this._bridgeTargetContext(u,m),this._applyTargetEventBridge(u),(null==(y=this.subModels.target)?void 0:y.uid)!==u.uid?(y&&(this._restoreTargetEventBridge(y),this._restoreTemplateFallbackPatch(y)),this._applyTemplateFallbackPatchState(u),this._setRuntimeTargetSubModel(u),y&&(null==(b=this._scopedEngine)||b.removeModel(y.uid))):(this.subModels.target=u,null==(_=this.emitter)||null==(S=_.emit)||S.call(_,"onSubModelReplaced",{oldModel:y,newModel:u}),this._applyTemplateFallbackPatchState(u)),this._targetModel=u,this._resolvedTargetUid=o,this._invalidTargetUid=void 0,this.props=u.props,[4,this._bindReferenceFiltersToResolvedTarget()];case 5:return T.sent(),[2]}})}).call(this)}},{key:"destroy",value:function(){var e=this,t=this;return m(function(){return R(this,function(n){switch(n.label){case 0:try{this._restoreTargetEventBridge(this._targetModel),this._restoreTemplateFallbackPatch(this._targetModel),(0,v.KC)(this._scopedEngine)}finally{this._scopedEngine=void 0}return[4,b(S(r.prototype),"destroy",e).call(t)];case 1:return[2,n.sent()]}})}).call(this)}},{key:"serialize",value:function(){var e=this.subModels,t=Object.prototype.hasOwnProperty.call(e,"target"),n=e.target;t&&delete e.target;try{var o=b(S(r.prototype),"serialize",this).call(this);return o.subModels&&0===Object.keys(o.subModels).length&&delete o.subModels,o}finally{t&&(e.target=n)}}},{key:"renderComponent",value:function(){var e,t=null==(e=this.subModels)?void 0:e.target,r=this._getTargetUidFromParams();if(!t)return r?this._invalidTargetUid===r?(0,v.Qj)(this,"invalid"):(0,v.Qj)(this,"resolving"):(0,v.Qj)(this,"unconfigured");var n=this._ensureScopedEngine();return o().createElement(v.vx,{engine:n,model:t})}},{key:"render",value:function(){return o().createElement("div",{ref:this.context.ref},this.renderComponent())}}],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}(u.BlockModel);B.registerFlow({key:"referenceSettings",sort:-999,title:(0,s.eh)("Select block template"),steps:{useTemplate:{preset:!0,hideInSettings:!0,sort:-10,title:(0,s.eh)("Select block template"),uiSchema:function(e){var t,r=e.model||{},n=(null==(t=r.getStepParams)?void 0:t.call(r,"referenceSettings","useTemplate"))||{},o=((null==n?void 0:n.templateUid)||"").trim(),l=!!r.isNew,i=null==e?void 0:e.api,a=function(){try{var e,t,n=(null==(e=r.getStepParams)?void 0:e.call(r,"resourceSettings","init"))||{},o=(0,d.tf)(null==n?void 0:n.associationName);if(o)return o;var l=(null==r?void 0:r.context)||{},i=(0,d.tf)(null==l||null==(t=l.association)?void 0:t.resourceName);if(i)return i;var a=null==l?void 0:l.resource;if(a){var s="function"==typeof a.getAssociationName?(0,d.tf)(a.getAssociationName()):"";if(s)return s;var u="function"==typeof a.getResourceName?(0,d.tf)(a.getResourceName()):"";if(u)return u}}catch(e){}return""}();return{templateUid:{title:(0,s.eh)("Template"),"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!0,filterOption:!1,allowClear:!0,placeholder:(0,s.eh)("Search templates"),disabled:!l&&!!o,optionLabelProp:"label",dropdownMatchSelectWidth:!0,getPopupContainer:function(){return document.body},optionRender:c.y},default:o||void 0,"x-validator":[{required:!0}],"x-reactions":[function(t){(0,f.Gg)(t,function(t,n,o){return m(function(){return R(this,function(l){var s;return[2,(s={page:n,pageSize:o},m(function(){var n,o,l,u,p,v,h,g,m;return R(this,function(y){switch(y.label){case 0:n=Math.max(1,Number((null==s?void 0:s.page)||1)),o=Math.max(1,Number((null==s?void 0:s.pageSize)||d.yl)),y.label=1;case 1:return y.trys.push([1,3,,4]),[4,null==i||null==(u=i.resource)||null==(l=u.call(i,"flowModelTemplates"))?void 0:l.list({page:n,pageSize:o,search:t||void 0,filter:{$and:[{$or:[{type:{$notIn:["popup"]}},{type:null},{type:""}]}]}})];case 2:return p=y.sent(),h=(v=(0,d.RN)(p)).rows,g=v.count,m=h.length,[2,{options:h.map(function(t,l){var i,s=t.name||t.uid||"",u=t.description,f=(i=t||{},a?(0,d.kE)(e,i,{associationName:a},{checkResource:!1,associationMatch:"associationResourceOnly"}):function(e,t,r){var n=(0,d.tf)(null==r?void 0:r.associationName),o=n.includes(".")?n.split(".").filter(Boolean)[0]:"";if(o){var l,i,a,s,u=(null==t||null==(i=t.context)||null==(l=i.view)?void 0:l.inputArgs)||(null==e||null==(a=e.view)?void 0:a.inputArgs)||{},c=(0,d.tf)(null==u?void 0:u.collectionName);if(!c)return(0,d.kE)(e,r,{associationName:""},{checkResource:!1,associationMatch:"associationResourceOnly"});var f=(0,d.tf)(null==u?void 0:u.dataSourceKey)||"main",p=(0,d.tf)(null==r?void 0:r.dataSourceKey);if(p&&f&&p!==f)return(0,d.yg)(e,"Template data source mismatch",{expected:"".concat(f,"/").concat(c),actual:"".concat(p,"/").concat(o)});if(o!==c)return(0,d.yg)(e,"Template collection mismatch",{expected:c,actual:o});if(!(null!=(s=null==u?void 0:u.filterByTk)&&""!==String(s).trim()||(null==u?void 0:u.record)))return(0,d.kE)(e,r,{associationName:""},{checkResource:!1,associationMatch:"associationResourceOnly"})}}(e,r,i));return{__idx:(n-1)*o+l,label:(0,c.H)(s),value:t.uid,description:u,disabled:!!f,disabledReason:f,rawName:s}}).slice().sort(f.hl),hasMore:(0,d.dE)({page:n,pageSize:o,rowsLength:m,count:g})}];case 3:return console.error("fetch template options failed",y.sent()),[2,{options:[],hasMore:!1}];case 4:return[2]}})})())]})})()},{pageSize:d.yl,composingKey:"__templateComposing"})}]},templateName:{"x-hidden":!0,"x-component":"Input",default:null==n?void 0:n.templateName},templateDescription:{"x-hidden":!0,"x-component":"Input",default:null==n?void 0:n.templateDescription},mode:{title:(0,s.eh)("Mode"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:(0,s.eh)("Reference"),value:"reference"},{label:(0,s.eh)("Duplicate"),value:"copy"}],default:(null==n?void 0:n.mode)||"reference"},modeDescriptionReference:{type:"void","x-decorator":"FormItem","x-decorator-props":{colon:!1},"x-component":"Alert","x-component-props":{type:"info",showIcon:!1,message:(0,s.eh)("Reference mode description")},"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "copy"}}'}}}},modeDescriptionDuplicate:{type:"void","x-decorator":"FormItem","x-decorator-props":{colon:!1},"x-component":"Alert","x-component-props":{type:"info",showIcon:!1,message:(0,s.eh)("Duplicate mode description")},"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] !== "copy"}}'}}}}}},beforeParamsSave:function(e,t){return m(function(){var r,n,o,l,i,a,s,u,c;return R(this,function(d){switch(d.label){case 0:if(!(r=((null==t?void 0:t.templateUid)||"").trim()))return[2];if(n=null==e?void 0:e.api,o=null,!(null==n?void 0:n.resource))return[3,4];d.label=1;case 1:return d.trys.push([1,3,,4]),[4,n.resource("flowModelTemplates").get({filterByTk:r})];case 2:return o=(null==(i=d.sent())||null==(l=i.data)?void 0:l.data)||i,[3,4];case 3:return console.warn("fetch template failed",d.sent()),[3,4];case 4:if(a=null==o?void 0:o.targetUid,!("copy"===((null==t?void 0:t.mode)||"reference")&&a))return[3,7];if(!(null==(c=null==(u=e.model.constructor.globalFlowRegistry.getFlow("referenceSettings"))||null==(s=u.steps)?void 0:s.target)?void 0:c.beforeParamsSave))return[3,6];return[4,c.beforeParamsSave(e,{targetUid:a,mode:"copy",templateUid:r})];case 5:d.sent(),d.label=6;case 6:case 7:return[2]}})})()},handler:function(e,t){return m(function(){var r,n,o,l,i,a,s,u,c,d,f,p,v,h,g,m,y,b,S,_,P,M;return R(this,function(k){switch(k.label){case 0:if(!(a=((null==t?void 0:t.templateUid)||"").trim())||"copy"===(s=(null==t?void 0:t.mode)||"reference"))return[2];if(u=null==e?void 0:e.api,c=null,!(null==u?void 0:u.resource))return[3,4];k.label=1;case 1:return k.trys.push([1,3,,4]),[4,u.resource("flowModelTemplates").get({filterByTk:a})];case 2:return c=(null==(f=k.sent())||null==(d=f.data)?void 0:d.data)||f,[3,4];case 3:return console.warn("fetch template failed",k.sent()),[3,4];case 4:return p=(null==c?void 0:c.name)||(null==t?void 0:t.templateName),v=(null==c?void 0:c.description)||(null==t?void 0:t.templateDescription),h=null==c?void 0:c.targetUid,g=e.model.getStepParams("referenceSettings","useTemplate")||{},e.model.setStepParams("referenceSettings","useTemplate",w(T({},g),{templateUid:a,templateName:p,templateDescription:v,targetUid:h||(null==g?void 0:g.targetUid),mode:s})),h&&(m=e.model.getStepParams("referenceSettings","target")||{},e.model.setStepParams("referenceSettings","target",w(T({},m),{targetUid:h,mode:s}))),y=e.model.getStepParams("resourceSettings","init")||{},b=null!=(r=null==c?void 0:c.dataSourceKey)?r:null==y?void 0:y.dataSourceKey,S=null!=(n=null==c?void 0:c.collectionName)?n:null==y?void 0:y.collectionName,_=null!=(o=null==c?void 0:c.associationName)?o:null==y?void 0:y.associationName,P=null!=(l=null==c?void 0:c.filterByTk)?l:null==y?void 0:y.filterByTk,M=null!=(i=null==c?void 0:c.sourceId)?i:null==y?void 0:y.sourceId,(b||S||_||P||M)&&e.model.setStepParams("resourceSettings","init",w(T({},y),{dataSourceKey:b,collectionName:S,associationName:_,filterByTk:P,sourceId:M})),[2]}})})()}},target:{preset:!0,hideInSettings:!0,title:(0,s.eh)("Template settings"),uiSchema:function(e){var t,r,n=e.model||{},o=(null==(t=n.getStepParams)?void 0:t.call(n,"referenceSettings","target"))||{},l=((null==o?void 0:o.targetUid)||"").trim(),i=!!n.isNew,a=(null==(r=n.getStepParams)?void 0:r.call(n,"referenceSettings","useTemplate"))||{},u=!!(null==a?void 0:a.templateUid),c=n._resolvedTargetUid,d=n._targetModel,f=!i&&!!l&&!!d&&c===l||u;return{targetUid:{title:(0,s.eh)("Block UID"),"x-component":"Input","x-decorator":"FormItem","x-decorator-props":{tooltip:f?(0,s.eh)("Block UID is already set and cannot be modified"):void 0},"x-component-props":{disabled:f},"x-validator":[{format:"string",required:!0}]},mode:{title:(0,s.eh)("Mode"),"x-component":"Radio.Group","x-decorator":"FormItem","x-component-props":{disabled:u},enum:[{label:(0,s.eh)("Reference"),value:"reference"},{label:(0,s.eh)("Duplicate"),value:"copy"}]},copyNotice:{type:"void","x-decorator":"FormItem","x-component":"Alert","x-component-props":{type:"warning",showIcon:!0,message:(0,s.eh)("Some configurations using uid may need to be reconfigured")},"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] !== "copy"}}'}}}}}},defaultParams:function(){return{mode:"reference"}},beforeParamsSave:function(e,t){return m(function(){var r,n,o,l,a,s,u,c,d,f,v,h,g,m,y,b,S,_,P,M,k,F,E,O,I,A,j,B,N,D,C,K,z,L,$,G,H,Q,q,V,Y;return R(this,function(R){switch(R.label){case 0:if(r=((null==t?void 0:t.targetUid)||"").trim(),"copy"!==((null==t?void 0:t.mode)||"reference")||!r)return[2];return n=((null==t?void 0:t.templateUid)||"").trim(),[4,(o=e.engine).duplicateModel(r)];case 1:if(!(l=R.sent()))return[2];if(n&&("DetailsBlockModel"===(a=String((null==l?void 0:l.use)||""))||"EditFormModel"===a)&&(c=null==l||null==(u=l.stepParams)||null==(s=u.resourceSettings)?void 0:s.init)&&(void 0===c?"undefined":x(c))==="object"&&Object.prototype.hasOwnProperty.call(c,"filterByTk")&&U(c,(null==(v=e.model)||null==(f=v.context)||null==(d=f.view)?void 0:d.inputArgs)||{},(null==(g=e.model)||null==(h=g.getStepParams)?void 0:h.call(g,"resourceSettings","init"))||{})&&delete c.filterByTk,y=(m=e.model).parent,b=m.subKey,S=m.subType,!y||!b)return e.exit(),[2];if(_=-1,"array"===S&&(_=Array.isArray(P=y.subModels[b]||[])?P.findIndex(function(e){return(null==e?void 0:e.uid)===m.uid}):-1)<0&&(_=P.length),M=w(T({},l),{parentId:y.uid,subKey:b,subType:S,sortIndex:_>=0?_:0}),(k=o.createModel(M)).setParent(y),k.sortIndex=_>=0?_:0,!m.isNew)return[3,6];return"array"===S?(Array.isArray(I=y.subModels[b])||(y.subModels[b]=[],I=y.subModels[b]),(A=I.findIndex(function(e){return(null==e?void 0:e.uid)===m.uid}))>=0?I.splice(A,1,k):I.push(k),I.forEach(function(e,t){return e.sortIndex=t})):y.setSubModel(b,k),o.removeModel(m.uid),k.isNew=!0,null==(E=y.emitter)||null==(F=E.emit)||F.call(E,"onSubModelAdded",k),[4,null==(O=k.afterAddAsSubModel)?void 0:O.call(k)];case 2:return R.sent(),[4,e.api.request({method:"POST",url:"flowModels:attach",params:{uid:k.uid,parentId:y.uid,subKey:b,subType:S}})];case 3:return R.sent(),[4,k.save()];case 4:return R.sent(),k.isNew=!1,[4,y.saveStepParams()];case 5:return R.sent(),y.rerender(),[3,17];case 6:if("array"!==S)return[3,8];if(Array.isArray(B=y.subModels[b])||(y.subModels[b]=[],B=y.subModels[b]),N=Math.min(Math.max(_,0),B.length),B.splice(N,0,k),B.forEach(function(e,t){return e.sortIndex=t}),!(0,p.z)(y,m.uid,k.uid)&&(null==(D=y.getStepParams("gridSettings","grid")||{})?void 0:D.rows)&&"object"===x(D.rows)){C=i().cloneDeep(D.rows),K=!0,z=!1,L=void 0;try{for($=Object.keys(C)[Symbol.iterator]();!(K=(G=$.next()).done);K=!0)if(H=C[G.value],Array.isArray(H)){for(Q=0;Q<H.length;Q++)if(q=H[Q],Array.isArray(q))for(V=0;V<q.length;V++)q[V]===m.uid&&(q[V]=k.uid)}}catch(e){z=!0,L=e}finally{try{K||null==$.return||$.return()}finally{if(z)throw L}}y.setStepParams("gridSettings","grid",{rows:C,sizes:D.sizes||{}}),y.setProps("rows",C)}return[4,null==(j=k.afterAddAsSubModel)?void 0:j.call(k)];case 7:return R.sent(),[3,10];case 8:return y.setSubModel(b,k),[4,null==(Y=k.afterAddAsSubModel)?void 0:Y.call(k)];case 9:R.sent(),R.label=10;case 10:return[4,k.save()];case 11:if(R.sent(),k.isNew=!1,!("array"===S&&o.modelRepository))return[3,14];return[4,o.modelRepository.findOne({uid:m.uid})];case 12:if(!(R.sent()&&"function"==typeof o.modelRepository.move))return[3,14];return[4,o.modelRepository.move(k.uid,m.uid,"before")];case 13:R.sent(),R.label=14;case 14:return[4,o.destroyModel(m.uid)];case 15:return R.sent(),[4,y.saveStepParams()];case 16:R.sent(),R.label=17;case 17:return e.exit(),[2]}})})()}}}}),B.registerFlow({key:"cardSettings",steps:{}}),B.define({label:(0,s.eh)("Block template"),group:(0,a.escapeT)("Other blocks"),createModelOptions:{use:"ReferenceBlockModel"},sort:900})},277:function(e,t,r){r.d(t,{KC:function(){return c},Ob:function(){return s},Qj:function(){return f},YT:function(){return u},vx:function(){return v}});var n=r(155),o=r.n(n),l=r(59),i=r(694),a=r(488);function s(e,t){return null!=t?t:(0,i.createBlockScopedEngine)(e)}function u(e,t){(null==e?void 0:e.context)&&t&&e.context.defineProperty("view",{cache:!1,get:function(){return t.view}})}function c(e){var t;null==e||null==(t=e.unlinkFromStack)||t.call(e)}function d(e,t){var r=null==e?void 0:e.translate;return"function"!=typeof r?t:r(t,{ns:[a.CU,"client"]})||t}function f(e,t){return"unconfigured"===t?o().createElement(l.Card,null,o().createElement(l.Empty,{image:l.Empty.PRESENTED_IMAGE_SIMPLE,description:d(e,"Please configure target block")})):"resolving"===t?o().createElement(l.Card,null,o().createElement(l.Skeleton,{active:!0,title:!1,paragraph:{rows:3}})):o().createElement(l.Card,null,o().createElement(l.Result,{status:"error",subTitle:d(e,"Target block is invalid")}))}var p=function(e){var t=e.engine,r=e.model,n=(0,i.useFlowViewContext)(),l=o().useMemo(function(){var e,r=new i.FlowContext;return r.defineProperty("engine",{value:t}),r.addDelegate(t.context),n&&(null!=(e=i.FlowContext)&&"u">typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](n):n instanceof e)&&r.addDelegate(n),r},[t,n]);return o().createElement(i.FlowViewContextProvider,{context:l},o().createElement(i.FlowModelRenderer,{key:r.uid,model:r,showFlowSettings:!1,showErrorFallback:!0}))},v=function(e){var t=e.engine,r=e.model;return o().createElement(i.FlowEngineProvider,{engine:t},o().createElement(p,{engine:t,model:r}))}}}]);
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_ui_templates=self.webpackChunk_nocobase_plugin_ui_templates||[]).push([["285"],{964:function(e,t,r){r.r(t),r.d(t,{ReferenceBlockModel:function(){return B}});var n=r(155),o=r.n(n),l=r(773),i=r.n(l),a=r(694),u=r(488),s=r(485),c=r(898),d=r(912),f=r(420),p=r(396),v=r(277);function g(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 h(e,t,r,n,o,l,i){try{var a=e[l](i),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var l=e.apply(t,r);function i(e){h(l,n,o,i,a,"next",e)}function a(e){h(l,n,o,i,a,"throw",e)}i(void 0)})}}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e,t,r){return(b="u">typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=S(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(r||e):o.value}})(e,t,r||e)}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function w(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){y(e,t,r[t])})}return e}function T(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 P(e,t){if(t&&("object"===x(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function M(e,t){return(M=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(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 l=[],i=!0,a=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(l.push(r.value),!t||l.length!==t);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw n}}return l}}(e,t)||F(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 x(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function F(e,t){if(e){if("string"==typeof e)return g(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 g(e,t)}}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(E=function(){return!!e})()}function R(e,t){var r,n,o,l={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),a=Object.defineProperty;return a(i,"next",{value:u(0)}),a(i,"throw",{value:u(1)}),a(i,"return",{value:u(2)}),"function"==typeof Symbol&&a(i,Symbol.iterator,{value:function(){return this}}),i;function u(a){return function(u){var s=[a,u];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(l=0)),l;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,n=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){l.label=s[1];break}if(6===s[0]&&l.label<o[1]){l.label=o[1],o=s;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(s);break}o[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var O=Symbol.for("nocobase.referenceBlockTargetContextBridge"),I=Symbol.for("nocobase.referenceBlockTargetEventBridge.originalDispatch"),A=Symbol.for("nocobase.referenceBlockTemplateFallback.originalGetStepParams"),j=Symbol.for("nocobase.referenceBlockTargetOwnContextMissing");function U(e,t){var r,n,o,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null==(r=null==t?void 0:t.filterByTk)||""===r||(null!=(n=null==t?void 0:t.collectionName)?n:null==l?void 0:l.collectionName)!==(null==e?void 0:e.collectionName))return!0;var i=null!=(o=null==t?void 0:t.dataSourceKey)?o:null==l?void 0:l.dataSourceKey;return null!=i&&""!==String(i).trim()&&i!==(null==e?void 0:e.dataSourceKey)}var B=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(e){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");t=r,n=[e],t=S(t),y(o=P(this,E()?Reflect.construct(t,n||[],S(this).constructor):t.apply(this,n)),"settingsMenuLevel",2),y(o,"_scopedEngine",void 0),y(o,"_targetModel",void 0),y(o,"_localProps",void 0),y(o,"_resolvedTargetUid",void 0),y(o,"_invalidTargetUid",void 0);var t,n,o,l=new Proxy(o,{get:function(e,t,r){var n=e._targetModel;if(n){if("props"===t)return n.props;if("setProps"===t&&"function"==typeof n.setProps)return function(){for(var t=arguments.length,r=Array(t),o=0;o<t;o++)r[o]=arguments[o];var l=n.setProps.apply(n,function(e){if(Array.isArray(e))return g(e)}(r)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||F(r)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());try{e.props=n.props}catch(e){}return l};if("getProps"===t&&"function"==typeof n.getProps)return n.getProps.bind(n)}if(t in e){var o=Reflect.get(e,t,e);return"function"==typeof o&&"constructor"!==t?o.bind(e):o}if(n){var l=Reflect.get(n,t,n);if("function"==typeof l&&"constructor"!==t)return l.bind(n);if(void 0!==l)return l}},set:function(e,t,r,n){var o=e._targetModel;if(o&&"props"===t){var l=Reflect.set(o,t,r,o);try{e.props=o.props}catch(e){}return l}return t in e?Reflect.set(e,t,r,e):o&&t in o?Reflect.set(o,t,r,o):Reflect.set(e,t,r,e)},has:function(e,t){if(t in e)return!0;var r=e._targetModel;return!!r&&t in r},ownKeys:function(e){var t=new Set(Reflect.ownKeys(e)),r=e._targetModel;if(r){var n=!0,o=!1,l=void 0;try{for(var i,a=Reflect.ownKeys(r)[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var u=i.value;t.add(u)}}catch(e){o=!0,l=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw l}}}return Array.from(t)},getOwnPropertyDescriptor:function(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r)return r;var n=e._targetModel;if(n)return Object.getOwnPropertyDescriptor(n,t)||void 0}});return P(o,l)}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&M(r,e),t=[{key:"_getFilterStateTarget",value:function(){return this._targetModel}},{key:"_getReferenceFilterManager",value:function(){var e;return null==(e=this.context)?void 0:e.filterManager}},{key:"_markShellInitialFilterRefreshHandled",value:function(){var e,t,r=this,n=null==(t=this._getReferenceFilterManager())||null==(e=t.getFilterConfigs)?void 0:e.call(t);Array.isArray(n)&&new Set(n.filter(function(e){return e.targetId===r.uid&&"string"==typeof e.filterId&&e.filterId}).map(function(e){return e.filterId})).forEach(function(e){try{var t,n,o,l,i,a=null==(n=r.flowEngine)||null==(t=n.getModel)?void 0:t.call(n,e);null==a||null==(i=a.context)||null==(l=i.blockModel)||null==(o=l.markInitialTargetRefreshHandled)||o.call(l,r.uid)}catch(e){}})}},{key:"_createTargetFilterManager",value:function(e){var t=this,r=this._getReferenceFilterManager();if(r){var n=function(r){return r===e.uid?t.uid:r};return new Proxy(r,{get:function(e,t){if("prepareFiltersForTarget"===t){if("function"!=typeof e.prepareFiltersForTarget)return;return function(t){var r;return null==(r=e.prepareFiltersForTarget)?void 0:r.call(e,n(t))}}if("bindToTarget"===t){if("function"!=typeof e.bindToTarget)return;return function(t){var r;return null==(r=e.bindToTarget)?void 0:r.call(e,n(t))}}var r=Reflect.get(e,t,e);return"function"==typeof r?r.bind(e):r}})}}},{key:"setFilterActive",value:function(e,t){b(S(r.prototype),"setFilterActive",this).call(this,e,t);var n,o=this._getFilterStateTarget();null==o||null==(n=o.setFilterActive)||n.call(o,e,t)}},{key:"hasActiveFilters",value:function(){var e,t;return b(S(r.prototype),"hasActiveFilters",this).call(this)||(null==(t=this._getFilterStateTarget())||null==(e=t.hasActiveFilters)?void 0:e.call(t))===!0}},{key:"removeFilterSource",value:function(e){var t,n;b(S(r.prototype),"removeFilterSource",this).call(this,e),null==(n=this._getFilterStateTarget())||null==(t=n.removeFilterSource)||t.call(n,e)}},{key:"getDataLoadingMode",value:function(){var e,t;return(null==(t=this._getFilterStateTarget())||null==(e=t.getDataLoadingMode)?void 0:e.call(t))||b(S(r.prototype),"getDataLoadingMode",this).call(this)}},{key:"_restoreTemplateFallbackPatch",value:function(e){if(e){var t=e[A];t&&(e.getStepParams=t,delete e[A],this._refreshTargetResourceState(e))}}},{key:"_restoreTargetEventBridge",value:function(e){if(e){var t=e[I];t&&(e.dispatchEvent=t,delete e[I])}}},{key:"_getForwardedTargetEventFlows",value:function(e){return!e||b(S(r.prototype),"getEvent",this).call(this,e)?new Map:new Map(Array.from(this.getFlows().entries()).filter(function(t){var r=k(t,2)[1],n=null==r?void 0:r.on;return!!n&&("string"==typeof n?n===e:(void 0===n?"undefined":x(n))==="object"&&n.eventName===e)}))}},{key:"_shouldForwardTargetEvent",value:function(e,t){return!(!t||!e||b(S(r.prototype),"getEvent",this).call(this,e))&&!!t.getEvent(e)}},{key:"_applyTargetEventBridge",value:function(e){if(e&&!e[I]){var t=e.dispatchEvent;if("function"==typeof t){e[I]=t;var r=this;e.dispatchEvent=function(n,o,l){return m(function(){var i,a,u,s,c,d,f;return R(this,function(p){switch(p.label){case 0:if(!r._shouldForwardTargetEvent(n,e)||!(s=r._getForwardedTargetEventFlows(n)).size)return[2,t.call(this,n,o,l)];c=null==(i=this.getFlows)?void 0:i.bind(this),d=null==(a=this.getFlow)?void 0:a.bind(this),f=null==(u=this.getStepParams)?void 0:u.bind(this),this.getFlows=function(){var e=c?c():new Map,t=!0,r=!1,n=void 0;try{for(var o,l=s.entries()[Symbol.iterator]();!(t=(o=l.next()).done);t=!0){var i=k(o.value,2),a=i[0],u=i[1];e.has(a)||e.set(a,u)}}catch(e){r=!0,n=e}finally{try{t||null==l.return||l.return()}finally{if(r)throw n}}return e},this.getFlow=function(e){return s.has(e)?s.get(e):null==d?void 0:d(e)},this.getStepParams=function(e,t){if(s.has(e)){var n=r.getStepParams(e,t);if(void 0!==n)return n}return null==f?void 0:f(e,t)},p.label=1;case 1:return p.trys.push([1,,3,4]),[4,t.call(this,n,o,l)];case 2:return[2,p.sent()];case 3:return this.getFlows=c,this.getFlow=d,this.getStepParams=f,[7];case 4:return[2]}})}).call(this)}}}}},{key:"_shouldTemplateFallbackToList",value:function(e){var t,r,n;return U(e,(null===this||void 0===this||null==(r=this.context)||null==(t=r.view)?void 0:t.inputArgs)||{},(null==(n=this.getStepParams)?void 0:n.call(this,"resourceSettings","init"))||{})}},{key:"_refreshTargetResourceState",value:function(e){if(e){var t,r,n,o,l,i,u,s,c,d=(null==(t=e.getStepParams)?void 0:t.call(e,"resourceSettings","init"))||{},f=null==e||null==(r=e.association)?void 0:r.type,p="hasOne"===f||"belongsTo"===f||Object.keys(d).includes("filterByTk"),v=null==(n=e.context)?void 0:n.resource,g=(null==v||null==(o=v.getAppends)?void 0:o.call(v))||[];if(!v||p&&!_(v,a.SingleRecordResource)||!p&&!_(v,a.MultiRecordResource))try{null==(i=e.context)||null==(l=i.removeCache)||l.call(i,"resource")}catch(e){}g.length&&(null==(c=e.context)||null==(s=c.resource)||null==(u=s.addAppends)||u.call(s,g))}}},{key:"_applyTemplateFallbackPatchState",value:function(e){if(e){var t,r,n=this.getStepParams("referenceSettings","useTemplate")||{},o=String((null==n?void 0:n.templateUid)||"").trim(),l=(null==n?void 0:n.mode)||(null==(t=this.getStepParams("referenceSettings","target")||{})?void 0:t.mode)||"reference",i=null==e||null==(r=e.constructor)?void 0:r.name;if(!(o&&"copy"!==l)||"DetailsBlockModel"!==i&&"EditFormModel"!==i)return void this._restoreTemplateFallbackPatch(e);if(!e[A]){var a=e.getStepParams;e[A]=a;var u=this;e.getStepParams=function(e,t){var r=a.call(this,e,t);if("resourceSettings"===e&&"init"===t&&r&&(void 0===r?"undefined":x(r))==="object"&&Object.prototype.hasOwnProperty.call(r,"filterByTk")&&u._shouldTemplateFallbackToList(r)){var n=w({},r);return delete n.filterByTk,n}return r}}this._refreshTargetResourceState(e)}}},{key:"_bridgeTargetContext",value:function(e,t){var r=this;if((null==e?void 0:e.context)&&this.context){var n=e.context;if(!n[O]){var o=new a.FlowContext;o.defineProperty("engine",{value:t}),o.defineProperty("filterManager",{cache:!1,get:function(){return r._createTargetFilterManager(e)}}),o.addDelegate(this.context),e.context.addDelegate(o),n[O]=!0}}}},{key:"_attachRuntimeTarget",value:function(e){e.parent=this}},{key:"_setRuntimeTargetSubModel",value:function(e){var t,r,n,o,l;this._attachRuntimeTarget(e),this.subModels.target=e,null==(r=this.emitter)||null==(t=r.emit)||t.call(r,"onSubModelAdded",e),null==(l=this.flowEngine)||null==(o=l.emitter)||null==(n=o.emit)||n.call(o,"model:subModel:added",{parentUid:this.uid,parent:this,subKey:"target",model:e})}},{key:"_bindReferenceFiltersToResolvedTarget",value:function(){return m(function(){var e,t,r,n,o;return R(this,function(l){switch(l.label){case 0:if(e=this,!(null==(n=this._getReferenceFilterManager())?void 0:n.prepareFiltersForTarget)&&!(null==n?void 0:n.bindToTarget))return[2];return[4,null==(t=n.prepareFiltersForTarget)?void 0:t.call(n,this.uid)];case 1:return o=l.sent(),null==(r=n.bindToTarget)||r.call(n,this.uid),null==o||o.forEach(function(t){var r;null==t||null==(r=t.markInitialTargetRefreshHandled)||r.call(t,e.uid)}),[2]}})}).call(this)}},{key:"title",get:function(){var e;return(null==(e=this._targetModel)?void 0:e.title)||b(S(r.prototype),"title",this)}},{key:"getEvents",value:function(){var e=b(S(r.prototype),"getEvents",this).call(this),t=null==(a=this._targetModel)||null==(i=a.getEvents)?void 0:i.call(a);if(!t)return e;var n=!0,o=!1,l=void 0;try{for(var i,a,u,s=t.entries()[Symbol.iterator]();!(n=(u=s.next()).done);n=!0){var c=k(u.value,2),d=c[0],f=c[1];e.has(d)||e.set(d,f)}}catch(e){o=!0,l=e}finally{try{n||null==s.return||s.return()}finally{if(o)throw l}}return e}},{key:"getEvent",value:function(e){var t,n;return b(S(r.prototype),"getEvent",this).call(this,e)||(null==(n=this._targetModel)||null==(t=n.getEvent)?void 0:t.call(n,e))}},{key:"onInit",value:function(e){var t=this;b(S(r.prototype),"onInit",this).call(this,e),this._localProps=this.props,this.context.defineProperty("refModel",{get:function(){return t._targetModel},cache:!1});var n=function(e){var r,n,o=null==(r=t._targetModel)?void 0:r.context;if(!o||!o.has(e))return j;try{return o._getOwnProperty(e,(null==(n=o.createProxy)?void 0:n.call(o))||o)}catch(e){return j}};["collection","dataSource","resource","association","resourceName"].forEach(function(e){t.context.defineProperty(e,{cache:!1,get:function(){var r,o,l=n(e);return l!==j?l:null==(o=t.parent)||null==(r=o.context)?void 0:r[e]}})}),this._markShellInitialFilterRefreshHandled()}},{key:"setProps",value:function(e,t){var n=this._targetModel;if(n&&"function"==typeof n.setProps){n.setProps(e,t),this.props=n.props;return}b(S(r.prototype),"setProps",this).call(this,e,t),this._localProps=this.props}},{key:"getProps",value:function(){var e=this._targetModel;return e&&"function"==typeof e.getProps?e.getProps():b(S(r.prototype),"getProps",this).call(this)}},{key:"_getTargetUidFromParams",value:function(){var e=this.getStepParams("referenceSettings","target")||{};return((null==e?void 0:e.targetUid)||"").trim()||void 0}},{key:"_syncExtraTitle",value:function(e){if(!e)return void this.setExtraTitle("");var t=this.context.t("Reference template",{ns:[u.CU,"client"],nsMode:"fallback"}),r=this.getStepParams("referenceSettings","useTemplate")||{},n=(null==r?void 0:r.templateName)||(null==r?void 0:r.templateUid);this.setExtraTitle(n?"".concat(t,": ").concat(n):t)}},{key:"_ensureScopedEngine",value:function(){return this._scopedEngine=(0,v.Ob)(this.flowEngine,this._scopedEngine),(0,v.YT)(this._scopedEngine,this.context),this._scopedEngine}},{key:"_resolveFinalTarget",value:function(e){return m(function(){var t,r,n,o,l,i,a;return R(this,function(u){switch(u.label){case 0:t=this._ensureScopedEngine(),r=new Set,n=e,o=0,u.label=1;case 1:if(!(o<20))return[3,4];if(!n||r.has(n)||n===this.uid)return[2,null];return r.add(n),[4,t.loadModel({uid:n})];case 2:if(!(i=u.sent()))return[2,null];if("ReferenceBlockModel"!==i.constructor.name)return[2,i];if(!(a=null==(l=i.getStepParams("referenceSettings","target"))?void 0:l.targetUid)||"string"!=typeof a||!a.trim())return[2,null];n=String(a).trim(),u.label=3;case 3:return o++,[3,1];case 4:return[2,null]}})}).call(this)}},{key:"onDispatchEventStart",value:function(e){return m(function(){var t,r,n,o,l,i,a,u,s,c,d,f,p,v,g,h,m,y,b,S,_;return R(this,function(w){switch(w.label){case 0:if("beforeRender"!==e)return[2];if(this._markShellInitialFilterRefreshHandled(),!(o=((null==(n=(null==(t=(r=this).getStepParams)?void 0:t.call(r,"referenceSettings","target"))||{})?void 0:n.targetUid)||"").trim()||void 0))return this._syncExtraTitle(!1),(l=this.subModels.target)&&(this._restoreTargetEventBridge(l),this._restoreTemplateFallbackPatch(l),null==(a=this.emitter)||null==(i=a.emit)||i.call(a,"onSubModelRemoved",l),null==(u=this._scopedEngine)||u.removeModel(l.uid)),this._targetModel=void 0,this._resolvedTargetUid=void 0,this._invalidTargetUid=void 0,this.subModels.target=void 0,this._localProps&&(this.props=this._localProps),[2];if(this._syncExtraTitle(!0),this._resolvedTargetUid===o&&this._targetModel)return this._invalidTargetUid=void 0,this._applyTargetEventBridge(this._targetModel),this._applyTemplateFallbackPatchState(this._targetModel),this.props=this._targetModel.props,[2];return this._invalidTargetUid=void 0,[4,this._resolveFinalTarget(o)];case 1:if(s=w.sent())return[3,4];return[4,new Promise(function(e){return setTimeout(e,50)})];case 2:if(w.sent(),(((null==(f=(null==(c=(d=this).getStepParams)?void 0:c.call(d,"referenceSettings","target"))||{})?void 0:f.targetUid)||"").trim()||void 0)!==o)return[2];return[4,this._resolveFinalTarget(o)];case 3:s=w.sent(),w.label=4;case 4:if(!s)return(p=this.subModels.target)&&(this._restoreTargetEventBridge(p),this._restoreTemplateFallbackPatch(p),null==(g=this.emitter)||null==(v=g.emit)||v.call(g,"onSubModelRemoved",p),null==(h=this._scopedEngine)||h.removeModel(p.uid)),this._targetModel=void 0,this._resolvedTargetUid=void 0,this._invalidTargetUid=o,this.subModels.target=void 0,this._localProps&&(this.props=this._localProps),[2];return m=this._ensureScopedEngine(),this._bridgeTargetContext(s,m),this._applyTargetEventBridge(s),(null==(y=this.subModels.target)?void 0:y.uid)!==s.uid?(y&&(this._restoreTargetEventBridge(y),this._restoreTemplateFallbackPatch(y)),this._applyTemplateFallbackPatchState(s),this._setRuntimeTargetSubModel(s),y&&(null==(b=this._scopedEngine)||b.removeModel(y.uid))):(this.subModels.target=s,null==(_=this.emitter)||null==(S=_.emit)||S.call(_,"onSubModelReplaced",{oldModel:y,newModel:s}),this._applyTemplateFallbackPatchState(s)),this._targetModel=s,this._resolvedTargetUid=o,this._invalidTargetUid=void 0,this.props=s.props,[4,this._bindReferenceFiltersToResolvedTarget()];case 5:return w.sent(),[2]}})}).call(this)}},{key:"destroy",value:function(){var e=this,t=this;return m(function(){return R(this,function(n){switch(n.label){case 0:try{this._restoreTargetEventBridge(this._targetModel),this._restoreTemplateFallbackPatch(this._targetModel),(0,v.KC)(this._scopedEngine)}finally{this._scopedEngine=void 0}return[4,b(S(r.prototype),"destroy",e).call(t)];case 1:return[2,n.sent()]}})}).call(this)}},{key:"serialize",value:function(){var e=this.subModels,t=Object.prototype.hasOwnProperty.call(e,"target"),n=e.target;t&&delete e.target;try{var o=b(S(r.prototype),"serialize",this).call(this);return o.subModels&&0===Object.keys(o.subModels).length&&delete o.subModels,o}finally{t&&(e.target=n)}}},{key:"renderComponent",value:function(){var e,t=null==(e=this.subModels)?void 0:e.target,r=this._getTargetUidFromParams();if(!t)return r?this._invalidTargetUid===r?(0,v.Qj)(this,"invalid"):(0,v.Qj)(this,"resolving"):(0,v.Qj)(this,"unconfigured");var n=this._ensureScopedEngine();return o().createElement(v.vx,{engine:n,model:t})}},{key:"render",value:function(){return o().createElement("div",{ref:this.context.ref},this.renderComponent())}}],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}(s.BlockModel);B.registerFlow({key:"referenceSettings",sort:-999,title:(0,u.eh)("Select block template"),steps:{useTemplate:{preset:!0,hideInSettings:!0,sort:-10,title:(0,u.eh)("Select block template"),uiSchema:function(e){var t,r=e.model||{},n=(null==(t=r.getStepParams)?void 0:t.call(r,"referenceSettings","useTemplate"))||{},o=((null==n?void 0:n.templateUid)||"").trim(),l=!!r.isNew,i=null==e?void 0:e.api,a=function(){try{var e,t,n=(null==(e=r.getStepParams)?void 0:e.call(r,"resourceSettings","init"))||{},o=(0,d.tf)(null==n?void 0:n.associationName);if(o)return o;var l=(null==r?void 0:r.context)||{},i=(0,d.tf)(null==l||null==(t=l.association)?void 0:t.resourceName);if(i)return i;var a=null==l?void 0:l.resource;if(a){var u="function"==typeof a.getAssociationName?(0,d.tf)(a.getAssociationName()):"";if(u)return u;var s="function"==typeof a.getResourceName?(0,d.tf)(a.getResourceName()):"";if(s)return s}}catch(e){}return""}();return{templateUid:{title:(0,u.eh)("Template"),"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!0,filterOption:!1,allowClear:!0,placeholder:(0,u.eh)("Search templates"),disabled:!l&&!!o,optionLabelProp:"label",dropdownMatchSelectWidth:!0,getPopupContainer:function(){return document.body},optionRender:c.y},default:o||void 0,"x-validator":[{required:!0}],"x-reactions":[function(t){(0,f.Gg)(t,function(t,n,o){return m(function(){return R(this,function(l){var u;return[2,(u={page:n,pageSize:o},m(function(){var n,o,l,s,p,v,g,h,m;return R(this,function(y){switch(y.label){case 0:n=Math.max(1,Number((null==u?void 0:u.page)||1)),o=Math.max(1,Number((null==u?void 0:u.pageSize)||d.yl)),y.label=1;case 1:return y.trys.push([1,3,,4]),[4,null==i||null==(s=i.resource)||null==(l=s.call(i,"flowModelTemplates"))?void 0:l.list({page:n,pageSize:o,search:t||void 0,filter:{$and:[{$or:[{type:{$notIn:["popup"]}},{type:null},{type:""}]}]}})];case 2:return p=y.sent(),g=(v=(0,d.RN)(p)).rows,h=v.count,m=g.length,[2,{options:g.map(function(t,l){var i,u=t.name||t.uid||"",s=t.description,f=(i=t||{},a?(0,d.kE)(e,i,{associationName:a},{checkResource:!1,associationMatch:"associationResourceOnly"}):function(e,t,r){var n=(0,d.tf)(null==r?void 0:r.associationName),o=n.includes(".")?n.split(".").filter(Boolean)[0]:"";if(o){var l,i,a,u,s=(null==t||null==(i=t.context)||null==(l=i.view)?void 0:l.inputArgs)||(null==e||null==(a=e.view)?void 0:a.inputArgs)||{},c=(0,d.tf)(null==s?void 0:s.collectionName);if(!c)return(0,d.kE)(e,r,{associationName:""},{checkResource:!1,associationMatch:"associationResourceOnly"});var f=(0,d.tf)(null==s?void 0:s.dataSourceKey)||"main",p=(0,d.tf)(null==r?void 0:r.dataSourceKey);if(p&&f&&p!==f)return(0,d.yg)(e,"Template data source mismatch",{expected:"".concat(f,"/").concat(c),actual:"".concat(p,"/").concat(o)});if(o!==c)return(0,d.yg)(e,"Template collection mismatch",{expected:c,actual:o});if(!(null!=(u=null==s?void 0:s.filterByTk)&&""!==String(u).trim()||(null==s?void 0:s.record)))return(0,d.kE)(e,r,{associationName:""},{checkResource:!1,associationMatch:"associationResourceOnly"})}}(e,r,i));return{__idx:(n-1)*o+l,label:(0,c.H)(u),value:t.uid,description:s,disabled:!!f,disabledReason:f,rawName:u}}).slice().sort(f.hl),hasMore:(0,d.dE)({page:n,pageSize:o,rowsLength:m,count:h})}];case 3:return console.error("fetch template options failed",y.sent()),[2,{options:[],hasMore:!1}];case 4:return[2]}})})())]})})()},{pageSize:d.yl,composingKey:"__templateComposing"})}]},templateName:{"x-hidden":!0,"x-component":"Input",default:null==n?void 0:n.templateName},templateDescription:{"x-hidden":!0,"x-component":"Input",default:null==n?void 0:n.templateDescription},mode:{title:(0,u.eh)("Mode"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:(0,u.eh)("Reference"),value:"reference"},{label:(0,u.eh)("Duplicate"),value:"copy"}],default:(null==n?void 0:n.mode)||"reference"},modeDescriptionReference:{type:"void","x-decorator":"FormItem","x-decorator-props":{colon:!1},"x-component":"Alert","x-component-props":{type:"info",showIcon:!1,message:(0,u.eh)("Reference mode description")},"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "copy"}}'}}}},modeDescriptionDuplicate:{type:"void","x-decorator":"FormItem","x-decorator-props":{colon:!1},"x-component":"Alert","x-component-props":{type:"info",showIcon:!1,message:(0,u.eh)("Duplicate mode description")},"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] !== "copy"}}'}}}}}},beforeParamsSave:function(e,t){return m(function(){var r,n,o,l,i,a,u,s,c;return R(this,function(d){switch(d.label){case 0:if(!(r=((null==t?void 0:t.templateUid)||"").trim()))return[2];if(n=null==e?void 0:e.api,o=null,!(null==n?void 0:n.resource))return[3,4];d.label=1;case 1:return d.trys.push([1,3,,4]),[4,n.resource("flowModelTemplates").get({filterByTk:r})];case 2:return o=(null==(i=d.sent())||null==(l=i.data)?void 0:l.data)||i,[3,4];case 3:return console.warn("fetch template failed",d.sent()),[3,4];case 4:if(a=null==o?void 0:o.targetUid,!("copy"===((null==t?void 0:t.mode)||"reference")&&a))return[3,7];if(!(null==(c=null==(s=e.model.constructor.globalFlowRegistry.getFlow("referenceSettings"))||null==(u=s.steps)?void 0:u.target)?void 0:c.beforeParamsSave))return[3,6];return[4,c.beforeParamsSave(e,{targetUid:a,mode:"copy",templateUid:r})];case 5:d.sent(),d.label=6;case 6:case 7:return[2]}})})()},handler:function(e,t){return m(function(){var r,n,o,l,i,a,u,s,c,d,f,p,v,g,h,m,y,b,S,_,P,M;return R(this,function(k){switch(k.label){case 0:if(!(a=((null==t?void 0:t.templateUid)||"").trim())||"copy"===(u=(null==t?void 0:t.mode)||"reference"))return[2];if(s=null==e?void 0:e.api,c=null,!(null==s?void 0:s.resource))return[3,4];k.label=1;case 1:return k.trys.push([1,3,,4]),[4,s.resource("flowModelTemplates").get({filterByTk:a})];case 2:return c=(null==(f=k.sent())||null==(d=f.data)?void 0:d.data)||f,[3,4];case 3:return console.warn("fetch template failed",k.sent()),[3,4];case 4:return p=(null==c?void 0:c.name)||(null==t?void 0:t.templateName),v=(null==c?void 0:c.description)||(null==t?void 0:t.templateDescription),g=null==c?void 0:c.targetUid,h=e.model.getStepParams("referenceSettings","useTemplate")||{},e.model.setStepParams("referenceSettings","useTemplate",T(w({},h),{templateUid:a,templateName:p,templateDescription:v,targetUid:g||(null==h?void 0:h.targetUid),mode:u})),g&&(m=e.model.getStepParams("referenceSettings","target")||{},e.model.setStepParams("referenceSettings","target",T(w({},m),{targetUid:g,mode:u}))),y=e.model.getStepParams("resourceSettings","init")||{},b=null!=(r=null==c?void 0:c.dataSourceKey)?r:null==y?void 0:y.dataSourceKey,S=null!=(n=null==c?void 0:c.collectionName)?n:null==y?void 0:y.collectionName,_=null!=(o=null==c?void 0:c.associationName)?o:null==y?void 0:y.associationName,P=null!=(l=null==c?void 0:c.filterByTk)?l:null==y?void 0:y.filterByTk,M=null!=(i=null==c?void 0:c.sourceId)?i:null==y?void 0:y.sourceId,(b||S||_||P||M)&&e.model.setStepParams("resourceSettings","init",T(w({},y),{dataSourceKey:b,collectionName:S,associationName:_,filterByTk:P,sourceId:M})),[2]}})})()}},target:{preset:!0,hideInSettings:!0,title:(0,u.eh)("Template settings"),uiSchema:function(e){var t,r,n=e.model||{},o=(null==(t=n.getStepParams)?void 0:t.call(n,"referenceSettings","target"))||{},l=((null==o?void 0:o.targetUid)||"").trim(),i=!!n.isNew,a=(null==(r=n.getStepParams)?void 0:r.call(n,"referenceSettings","useTemplate"))||{},s=!!(null==a?void 0:a.templateUid),c=n._resolvedTargetUid,d=n._targetModel,f=!i&&!!l&&!!d&&c===l||s;return{targetUid:{title:(0,u.eh)("Block UID"),"x-component":"Input","x-decorator":"FormItem","x-decorator-props":{tooltip:f?(0,u.eh)("Block UID is already set and cannot be modified"):void 0},"x-component-props":{disabled:f},"x-validator":[{format:"string",required:!0}]},mode:{title:(0,u.eh)("Mode"),"x-component":"Radio.Group","x-decorator":"FormItem","x-component-props":{disabled:s},enum:[{label:(0,u.eh)("Reference"),value:"reference"},{label:(0,u.eh)("Duplicate"),value:"copy"}]},copyNotice:{type:"void","x-decorator":"FormItem","x-component":"Alert","x-component-props":{type:"warning",showIcon:!0,message:(0,u.eh)("Some configurations using uid may need to be reconfigured")},"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] !== "copy"}}'}}}}}},defaultParams:function(){return{mode:"reference"}},beforeParamsSave:function(e,t){return m(function(){var r,n,o,l,a,u,s,c,d,f,v,g,h,m,y,b,S,_,P,M,k,F,E,O,I,A,j,B,N,D,C,K,z,L,$,G,H,Q,q,V,Y;return R(this,function(R){switch(R.label){case 0:if(r=((null==t?void 0:t.targetUid)||"").trim(),"copy"!==((null==t?void 0:t.mode)||"reference")||!r)return[2];return n=((null==t?void 0:t.templateUid)||"").trim(),[4,(o=e.engine).duplicateModel(r)];case 1:if(!(l=R.sent()))return[2];if(n&&("DetailsBlockModel"===(a=String((null==l?void 0:l.use)||""))||"EditFormModel"===a)&&(c=null==l||null==(s=l.stepParams)||null==(u=s.resourceSettings)?void 0:u.init)&&(void 0===c?"undefined":x(c))==="object"&&Object.prototype.hasOwnProperty.call(c,"filterByTk")&&U(c,(null==(v=e.model)||null==(f=v.context)||null==(d=f.view)?void 0:d.inputArgs)||{},(null==(h=e.model)||null==(g=h.getStepParams)?void 0:g.call(h,"resourceSettings","init"))||{})&&delete c.filterByTk,y=(m=e.model).parent,b=m.subKey,S=m.subType,!y||!b)return e.exit(),[2];if(_=-1,"array"===S&&(_=Array.isArray(P=y.subModels[b]||[])?P.findIndex(function(e){return(null==e?void 0:e.uid)===m.uid}):-1)<0&&(_=P.length),M=T(w({},l),{parentId:y.uid,subKey:b,subType:S,sortIndex:_>=0?_:0}),(k=o.createModel(M)).setParent(y),k.sortIndex=_>=0?_:0,!m.isNew)return[3,6];return"array"===S?(Array.isArray(I=y.subModels[b])||(y.subModels[b]=[],I=y.subModels[b]),(A=I.findIndex(function(e){return(null==e?void 0:e.uid)===m.uid}))>=0?I.splice(A,1,k):I.push(k),I.forEach(function(e,t){return e.sortIndex=t})):y.setSubModel(b,k),o.removeModel(m.uid),k.isNew=!0,null==(E=y.emitter)||null==(F=E.emit)||F.call(E,"onSubModelAdded",k),[4,null==(O=k.afterAddAsSubModel)?void 0:O.call(k)];case 2:return R.sent(),[4,e.api.request({method:"POST",url:"flowModels:attach",params:{uid:k.uid,parentId:y.uid,subKey:b,subType:S}})];case 3:return R.sent(),[4,k.save()];case 4:return R.sent(),k.isNew=!1,[4,y.saveStepParams()];case 5:return R.sent(),y.rerender(),[3,17];case 6:if("array"!==S)return[3,8];if(Array.isArray(B=y.subModels[b])||(y.subModels[b]=[],B=y.subModels[b]),N=Math.min(Math.max(_,0),B.length),B.splice(N,0,k),B.forEach(function(e,t){return e.sortIndex=t}),!(0,p.z)(y,m.uid,k.uid)&&(null==(D=y.getStepParams("gridSettings","grid")||{})?void 0:D.rows)&&"object"===x(D.rows)){C=i().cloneDeep(D.rows),K=!0,z=!1,L=void 0;try{for($=Object.keys(C)[Symbol.iterator]();!(K=(G=$.next()).done);K=!0)if(H=C[G.value],Array.isArray(H)){for(Q=0;Q<H.length;Q++)if(q=H[Q],Array.isArray(q))for(V=0;V<q.length;V++)q[V]===m.uid&&(q[V]=k.uid)}}catch(e){z=!0,L=e}finally{try{K||null==$.return||$.return()}finally{if(z)throw L}}y.setStepParams("gridSettings","grid",{rows:C,sizes:D.sizes||{}}),y.setProps("rows",C)}return[4,null==(j=k.afterAddAsSubModel)?void 0:j.call(k)];case 7:return R.sent(),[3,10];case 8:return y.setSubModel(b,k),[4,null==(Y=k.afterAddAsSubModel)?void 0:Y.call(k)];case 9:R.sent(),R.label=10;case 10:return[4,k.save()];case 11:if(R.sent(),k.isNew=!1,!("array"===S&&o.modelRepository))return[3,14];return[4,o.modelRepository.findOne({uid:m.uid})];case 12:if(!(R.sent()&&"function"==typeof o.modelRepository.move))return[3,14];return[4,o.modelRepository.move(k.uid,m.uid,"before")];case 13:R.sent(),R.label=14;case 14:return[4,o.destroyModel(m.uid)];case 15:return R.sent(),[4,y.saveStepParams()];case 16:R.sent(),R.label=17;case 17:return e.exit(),[2]}})})()}}}}),B.registerFlow({key:"cardSettings",steps:{}}),B.define({label:(0,u.eh)("Block template"),group:(0,a.escapeT)("Other blocks"),createModelOptions:{use:"ReferenceBlockModel"},sort:900})},277:function(e,t,r){r.d(t,{KC:function(){return c},Ob:function(){return u},Qj:function(){return f},YT:function(){return s},vx:function(){return v}});var n=r(155),o=r.n(n),l=r(59),i=r(694),a=r(488);function u(e,t){if(t)return t;var r=(0,i.createBlockScopedEngine)(e),n=r.context,o=new i.FlowContext;return o.defineProperty("engine",{value:r}),o.addDelegate(n),Object.defineProperty(r,"context",{configurable:!0,value:o}),r}function s(e,t){(null==e?void 0:e.context)&&t&&e.context.defineProperty("view",{cache:!1,get:function(){return t.view}})}function c(e){var t;null==e||null==(t=e.unlinkFromStack)||t.call(e)}function d(e,t){var r=null==e?void 0:e.translate;return"function"!=typeof r?t:r(t,{ns:[a.CU,"client"]})||t}function f(e,t){return"unconfigured"===t?o().createElement(l.Card,null,o().createElement(l.Empty,{image:l.Empty.PRESENTED_IMAGE_SIMPLE,description:d(e,"Please configure target block")})):"resolving"===t?o().createElement(l.Card,null,o().createElement(l.Skeleton,{active:!0,title:!1,paragraph:{rows:3}})):o().createElement(l.Card,null,o().createElement(l.Result,{status:"error",subTitle:d(e,"Target block is invalid")}))}var p=function(e){var t=e.engine,r=e.model,n=(0,i.useFlowViewContext)(),l=o().useMemo(function(){var e,r=new i.FlowContext;return r.defineProperty("engine",{value:t}),r.addDelegate(t.context),n&&(null!=(e=i.FlowContext)&&"u">typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](n):n instanceof e)&&r.addDelegate(n),r},[t,n]);return o().createElement(i.FlowViewContextProvider,{context:l},o().createElement(i.FlowModelRenderer,{key:r.uid,model:r,showFlowSettings:!1,showErrorFallback:!0}))},v=function(e){var t=e.engine,r=e.model;return o().createElement(i.FlowEngineProvider,{engine:t},o().createElement(p,{engine:t,model:r}))}}}]);
|
|
@@ -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
|
+
"use strict";(self.webpackChunk_nocobase_plugin_ui_templates=self.webpackChunk_nocobase_plugin_ui_templates||[]).push([["934"],{869:function(e,t,r){r.r(t),r.d(t,{ReferenceFormGridModel:function(){return E}});var n=r(155),i=r.n(n),o=r(694),a=r(401),l=r(488),u=r(277);function s(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 c(e,t,r,n,i,o,a){try{var l=e[o](a),u=l.value}catch(e){r(e);return}l.done?t(u):Promise.resolve(u).then(n,i)}function d(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){c(o,n,i,a,l,"next",e)}function l(e){c(o,n,i,a,l,"throw",e)}a(void 0)})}}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e,t,r){return(v="u">typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r||e):i.value}})(e,t,r||e)}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function p(e,t){if(t&&("object"===m(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var o=[],a=!0,l=!1;try{for(i=i.call(e);!(a=(r=i.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){l=!0,n=e}finally{try{a||null==i.return||i.return()}finally{if(l)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(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 s(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.")}()}function m(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}function S(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:u(0)}),l(a,"throw",{value:u(1)}),l(a,"return",{value:u(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function u(l){return function(u){var s=[l,u];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var w="referenceSettings",P=Symbol.for("nocobase.refGridHostBridge"),E=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(e){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");t=r,n=[e],t=h(t),f(i=p(this,_()?Reflect.construct(t,n||[],h(this).constructor):t.apply(this,n)),"_scopedEngine",void 0),f(i,"_targetRoot",void 0),f(i,"_targetGrid",void 0),f(i,"_resolvedTargetUid",void 0),f(i,"_invalidTargetUid",void 0);var t,n,i,o=new Set(["mapSubModels","filterSubModels","findSubModel","hasSubModel"]),a=new Proxy(i,{get:function(e,t){var r=e._targetGrid;if(r){if("subModels"===t)return r.subModels;if("string"==typeof t&&o.has(t)){var n=Reflect.get(r,t,r);return"function"==typeof n?n.bind(r):n}}if(t in e){var i=Reflect.get(e,t,e);return"function"==typeof i&&"constructor"!==t?i.bind(e):i}if(r){var a=Reflect.get(r,t,r);if("function"==typeof a&&"constructor"!==t)return a.bind(r);if(void 0!==a)return a}},has:function(e,t){if(t in e)return!0;var r=e._targetGrid;return!!r&&t in r},ownKeys:function(e){var t=new Set(Reflect.ownKeys(e)),r=e._targetGrid;if(r){var n=!0,i=!1,o=void 0;try{for(var a,l=Reflect.ownKeys(r)[Symbol.iterator]();!(n=(a=l.next()).done);n=!0){var u=a.value;t.add(u)}}catch(e){i=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(i)throw o}}}return Array.from(t)},getOwnPropertyDescriptor:function(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r)return r;var n=e._targetGrid;if(n)return Object.getOwnPropertyDescriptor(n,t)||void 0}});return p(i,a)}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&y(r,e),t=[{key:"_syncHostResourceAppends",value:function(e,t){if(e.addAppends){var r=new Set,n=function(e){var t,n="string"==typeof e?e.trim():"";if(n){r.add(n);var i=null==(t=n.split(".")[0])?void 0:t.trim();i&&r.add(i)}},i=function(e){var t=null==(s=e.getStepParams)?void 0:s.call(e,"fieldSettings","init");t&&(n(t.fieldPath),n(t.associationPathName));var r=e.subModels||{},a=!0,l=!1,u=void 0;try{for(var s,c,d=Object.values(r)[Symbol.iterator]();!(a=(c=d.next()).done);a=!0){var f=c.value;Array.isArray(f)?f.forEach(function(e){return g(e,o.FlowModel)&&i(e)}):g(f,o.FlowModel)&&i(f)}}catch(e){l=!0,u=e}finally{try{a||null==d.return||d.return()}finally{if(l)throw u}}};if(i(t),0!==r.size){var a=!0,l=!1,u=void 0;try{for(var s,c=r[Symbol.iterator]();!(a=(s=c.next()).done);a=!0){var d,f=s.value;null==(d=e.addAppends)||d.call(e,f)}}catch(e){l=!0,u=e}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}}}}},{key:"_ensureScopedEngine",value:function(){return this._scopedEngine=(0,u.Ob)(this.flowEngine,this._scopedEngine),this._scopedEngine}},{key:"_getTargetSettings",value:function(){var e=this.getStepParams(w,"useTemplate");if(e&&(void 0===e?"undefined":m(e))==="object"){var t=String(e.templateUid||"").trim(),r=String(e.targetUid||"").trim();if(t&&r)return{templateUid:t,templateName:String(e.templateName||"").trim()||void 0,targetUid:r,targetPath:String(e.targetPath||"").trim()||void 0}}}},{key:"_syncHostExtraTitle",value:function(e){var t,r,n,i,a=this.parent;if(a){var u=(null==a?void 0:a.isFork)&&a.master||a,s=[a];if(u&&u!==a&&g(u,o.FlowModel)&&s.push(u),null==u||null==(r=u.forks)||null==(t=r.forEach)||t.call(r,function(e){return g(e,o.FlowModel)&&s.push(e)}),!e)return void s.forEach(function(e){return e.setExtraTitle("")});var c=a.context.t("Reference template",{ns:[l.CU,"client"],nsMode:"fallback"}),d=a.context.t("(Fields only)",{ns:[l.CU,"client"],nsMode:"fallback"}),f=(null==(n=e.templateName)?void 0:n.trim())||(null==(i=e.templateUid)?void 0:i.trim())||"",v=f?"".concat(c,": ").concat(f," ").concat(d):"".concat(c," ").concat(d);s.forEach(function(e){return e.setExtraTitle(v.trim())})}}},{key:"addSubModel",value:function(e,t){if(!this._targetGrid)throw Error("[block-reference] Target grid is not resolved yet.");return this._targetGrid.addSubModel(e,t)}},{key:"setSubModel",value:function(e,t){if(!this._targetGrid)throw Error("[block-reference] Target grid is not resolved yet.");return this._targetGrid.setSubModel(e,t)}},{key:"getStepParams",value:function(e,t){if(!e||e===w||!this._targetGrid)return v(h(r.prototype),"getStepParams",this).call(this,e,t);if(t){var n,i,o,a,l=this._targetGrid.getStepParams(e,t);return void 0!==l?l:null==(a=this._targetRoot)||null==(o=a.getStepParams)?void 0:o.call(a,e,t)}var u=this._targetGrid.getStepParams(e),s=null==(i=this._targetRoot)||null==(n=i.getStepParams)?void 0:n.call(i,e);return s&&(void 0===s?"undefined":m(s))==="object"?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){f(e,t,r[t])})}return e}({},s,u||{}):u}},{key:"setStepParams",value:function(e,t,n){if("string"==typeof e)return e!==w&&this._targetGrid?"string"==typeof t&&void 0!==n?void this._targetGrid.setStepParams(e,t,n):void((void 0===t?"undefined":m(t))==="object"&&null!==t&&this._targetGrid.setStepParams(e,t)):void v(h(r.prototype),"setStepParams",this).call(this,e,t,n);if((void 0===e?"undefined":m(e))==="object"&&null!==e){var i={},o={},a=!0,l=!1,u=void 0;try{for(var s,c=Object.entries(e)[Symbol.iterator]();!(a=(s=c.next()).done);a=!0){var d=b(s.value,2),f=d[0],g=d[1];f!==w&&this._targetGrid?o[f]=g:i[f]=g}}catch(e){l=!0,u=e}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}Object.keys(i).length>0&&v(h(r.prototype),"setStepParams",this).call(this,i),Object.keys(o).length>0&&this._targetGrid&&this._targetGrid.setStepParams(o)}}},{key:"saveStepParams",value:function(){var e=this,t=this;return d(function(){var n,i,o,a,l,u,s,c,d;return S(this,function(f){switch(f.label){case 0:if(this._targetGrid)return[3,2];return[4,this.dispatchEvent("beforeRender")];case 1:f.sent(),f.label=2;case 2:if(this._targetGrid&&this.stepParams){n=!0,i=!1,o=void 0;try{for(a=Object.entries(this.stepParams)[Symbol.iterator]();!(n=(l=a.next()).done);n=!0)s=(u=b(l.value,2))[0],c=u[1],s!==w&&(void 0===c?"undefined":m(c))==="object"&&null!==c&&(this._targetGrid.setStepParams(s,c),delete this.stepParams[s])}catch(e){i=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}}return[4,v(h(r.prototype),"saveStepParams",e).call(t)];case 3:if(d=f.sent(),!this._targetGrid)return[3,5];return[4,this._targetGrid.saveStepParams()];case 4:f.sent(),f.label=5;case 5:return[2,d]}})}).call(this)}},{key:"onDispatchEventStart",value:function(e){return d(function(){var t,r,n,i,l,s,c,f,v,h,p,y,b;return S(this,function(m){switch(m.label){case 0:if(t=this,"beforeRender"!==e)return[2];if(!(n=this._getTargetSettings()))return this._syncHostExtraTitle(void 0),this._targetRoot=void 0,this._targetGrid=void 0,this._resolvedTargetUid=void 0,this._invalidTargetUid=void 0,[2];if(this._syncHostExtraTitle(n),"subModels.grid"!==(i=(null==(r=n.targetPath)?void 0:r.trim())||"subModels.grid"))throw Error("[block-reference] Only 'subModels.grid' is supported for ReferenceFormGridModel (got '".concat(i,"')."));if(this._resolvedTargetUid===n.targetUid&&this._targetGrid)return this._invalidTargetUid=void 0,[2];return l=this._ensureScopedEngine(),s=this.parent,(0,u.YT)(l,(null==s?void 0:s.context)||this.context),c=n.targetUid,f=this._targetGrid,v=this._resolvedTargetUid,h=this._invalidTargetUid,this._invalidTargetUid=void 0,[4,(p=function(){return d(function(){var e,t,r,u,d,f,v;return S(this,function(h){switch(h.label){case 0:return[4,l.loadModel({uid:c})];case 1:if(!(t=h.sent())||(t.setParent(s),r={hostUid:null==s?void 0:s.uid,hostUse:null==s?void 0:s.use,ref:{templateUid:n.templateUid,templateName:n.templateName,targetUid:c,targetPath:i,mountSubKey:"grid",mode:"reference"}},t.context.defineProperty(a.v,{value:r}),g(u=null==(e=t.subModels)?void 0:e.grid,o.FlowModel)&&(d=u),f=null==d?void 0:d.context,d&&(null==s?void 0:s.context)&&!(null==f?void 0:f[P])&&((v=new o.FlowContext).defineProperty("engine",{value:l}),v.addDelegate(s.context),d.context.addDelegate(v),d.context[P]=!0),!d))return[2,void 0];return s&&this._syncHostResourceAppends(s,d),[2,{root:t,grid:d}]}})}).call(t)})()];case 1:if(y=m.sent())return[3,4];return[4,new Promise(function(e){return setTimeout(e,50)})];case 2:if(m.sent(),(null==(b=this._getTargetSettings())?void 0:b.targetUid)!==c)return[2];return[4,p()];case 3:y=m.sent(),m.label=4;case 4:if(!y)return this._targetRoot=void 0,this._targetGrid=void 0,this._resolvedTargetUid=void 0,this._invalidTargetUid=c,(f||v||h!==c)&&this.rerender(),[2];return this._targetRoot=y.root,this._targetGrid=y.grid,this._resolvedTargetUid=c,this._invalidTargetUid=void 0,(f!==y.grid||v!==c||h)&&this.rerender(),[2]}})}).call(this)}},{key:"clearForks",value:function(){try{this._syncHostExtraTitle(void 0),(0,u.KC)(this._scopedEngine)}finally{this._scopedEngine=void 0}v(h(r.prototype),"clearForks",this).call(this)}},{key:"destroy",value:function(){var e=this,t=this;return d(function(){return S(this,function(n){switch(n.label){case 0:try{(0,u.KC)(this._scopedEngine)}finally{this._scopedEngine=void 0}return[4,v(h(r.prototype),"destroy",e).call(t)];case 1:return[2,n.sent()]}})}).call(this)}},{key:"render",value:function(){var e=this._getTargetSettings();if(!e)return(0,u.Qj)(this,"unconfigured");var t=this._targetGrid;if(!t)return this._invalidTargetUid===e.targetUid?(0,u.Qj)(this,"invalid"):(0,u.Qj)(this,"resolving");var r=this._ensureScopedEngine();return i().createElement(u.vx,{engine:r,model:t})}}],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}(o.FlowModel);E.define({hide:!0})},277:function(e,t,r){r.d(t,{KC:function(){return c},Ob:function(){return u},Qj:function(){return f},YT:function(){return s},vx:function(){return h}});var n=r(155),i=r.n(n),o=r(59),a=r(694),l=r(488);function u(e,t){if(t)return t;var r=(0,a.createBlockScopedEngine)(e),n=r.context,i=new a.FlowContext;return i.defineProperty("engine",{value:r}),i.addDelegate(n),Object.defineProperty(r,"context",{configurable:!0,value:i}),r}function s(e,t){(null==e?void 0:e.context)&&t&&e.context.defineProperty("view",{cache:!1,get:function(){return t.view}})}function c(e){var t;null==e||null==(t=e.unlinkFromStack)||t.call(e)}function d(e,t){var r=null==e?void 0:e.translate;return"function"!=typeof r?t:r(t,{ns:[l.CU,"client"]})||t}function f(e,t){return"unconfigured"===t?i().createElement(o.Card,null,i().createElement(o.Empty,{image:o.Empty.PRESENTED_IMAGE_SIMPLE,description:d(e,"Please configure target block")})):"resolving"===t?i().createElement(o.Card,null,i().createElement(o.Skeleton,{active:!0,title:!1,paragraph:{rows:3}})):i().createElement(o.Card,null,i().createElement(o.Result,{status:"error",subTitle:d(e,"Target block is invalid")}))}var v=function(e){var t=e.engine,r=e.model,n=(0,a.useFlowViewContext)(),o=i().useMemo(function(){var e,r=new a.FlowContext;return r.defineProperty("engine",{value:t}),r.addDelegate(t.context),n&&(null!=(e=a.FlowContext)&&"u">typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](n):n instanceof e)&&r.addDelegate(n),r},[t,n]);return i().createElement(a.FlowViewContextProvider,{context:o},i().createElement(a.FlowModelRenderer,{key:r.uid,model:r,showFlowSettings:!1,showErrorFallback:!0}))},h=function(e){var t=e.engine,r=e.model;return i().createElement(a.FlowEngineProvider,{engine:t},i().createElement(v,{engine:t,model:r}))}},401:function(e,t,r){r.d(t,{v:function(){return n}});var n="__subModelReferenceHost"}}]);
|