@nocobase/plugin-workflow-dynamic-calculation 2.0.0-alpha.63 → 2.0.0-alpha.65

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.
@@ -9,6 +9,7 @@
9
9
  import React from 'react';
10
10
  import { SchemaInitializerItemType } from '@nocobase/client';
11
11
  import { Instruction, WorkflowVariableInput } from '@nocobase/plugin-workflow/client';
12
+ import { SubModelItem } from '@nocobase/flow-engine';
12
13
  declare function DynamicExpression({ value, onChange }: {
13
14
  value: any;
14
15
  onChange: any;
@@ -78,5 +79,11 @@ export default class extends Instruction {
78
79
  label: any;
79
80
  };
80
81
  useInitializers(node: any): SchemaInitializerItemType;
82
+ /**
83
+ * 2.0
84
+ */
85
+ getCreateModelMenuItem({ node }: {
86
+ node: any;
87
+ }): SubModelItem;
81
88
  }
82
89
  export {};
@@ -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("@formily/core"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react"),require("@formily/react"),require("@nocobase/evaluators/client"),require("@ant-design/icons"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-dynamic-calculation",["@formily/core","@nocobase/client","@nocobase/plugin-workflow/client","react","@formily/react","@nocobase/evaluators/client","@ant-design/icons","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-dynamic-calculation"]=t(require("@formily/core"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react"),require("@formily/react"),require("@nocobase/evaluators/client"),require("@ant-design/icons"),require("antd"),require("react-i18next")):e["@nocobase/plugin-workflow-dynamic-calculation"]=t(e["@formily/core"],e["@nocobase/client"],e["@nocobase/plugin-workflow/client"],e.react,e["@formily/react"],e["@nocobase/evaluators/client"],e["@ant-design/icons"],e.antd,e["react-i18next"])}(self,function(e,t,n,r,o,i,c,a,u){return function(){"use strict";var l={482:function(e){e.exports=c},563:function(t){t.exports=e},505:function(e){e.exports=o},772:function(e){e.exports=t},47:function(e){e.exports=i},433:function(e){e.exports=n},721:function(e){e.exports=a},156:function(e){e.exports=r},238:function(e){e.exports=u}},s={};function f(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return l[e](n,n.exports,f),n.exports}f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var n in t)f.o(t,n)&&!f.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};return!function(){f.r(p),f.d(p,{default:function(){return $}});var e=f(772),t=f(156),n=f.n(t),r=f(482),o=f(433),i=f(238),c="workflow-dynamic-calculation";function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}function y(e){var t;return!!["belongsTo","hasOne"].includes(e.type)&&((null==(t=this.getCollection(e.collectionName))?void 0:t.template)==="expression"||this.getCollectionFields(e.target).some(function(e){return"expression"===e.interface}))}function b(t){var r=t.value,i=t.onChange,c=(0,e.useCollectionManager_deprecated)(),a=c.getCollectionFields,u=c.getCollection,l=(0,o.useWorkflowVariableOptions)({types:[y.bind({getCollectionFields:a,getCollection:u})]});return n().createElement(e.Variable.Input,{value:r,onChange:i,scope:l})}var d=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function f(){var e,t,i;if(!(this instanceof f))throw TypeError("Cannot call a class as a function");return t=f,i=arguments,t=u(t),a(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,s()?Reflect.construct(t,i||[],u(this).constructor):t.apply(this,i)),"title",'{{t("Dynamic expression calculation", { ns: "'.concat(c,'" })}}')),a(e,"type","dynamic-calculation"),a(e,"group","calculation"),a(e,"description",'{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression is dynamic one from an expression collections.", { ns: "'.concat(c,'" })}}')),a(e,"icon",n().createElement(r.FunctionOutlined,null)),a(e,"fieldset",{expression:{type:"string",title:'{{t("Calculation expression", { ns: "'.concat(c,'" })}}'),"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:'{{t("Variable datasource", { ns: "'.concat(c,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}}),a(e,"components",{DynamicExpression:b,WorkflowVariableInput:o.WorkflowVariableInput,ValueBlock:o.ValueBlock}),e}return f.prototype=Object.create(e&&e.prototype,{constructor:{value:f,writable:!0,configurable:!0}}),e&&l(f,e),t=[{key:"useVariables",value:function(e,t){var n,r=e.key,i=e.title,c=t.types,u=t.fieldNames,l=void 0===u?o.defaultFieldNames:u;return c&&!c.some(function(e){return e in o.BaseTypeSets||Object.values(o.BaseTypeSets).some(function(t){return t.has(e)})})?null:(a(n={},l.value,r),a(n,l.label,i),n)}},{key:"useInitializers",value:function(e){var t;return{name:"#".concat(e.id),type:"item",title:null!=(t=e.title)?t:"#".concat(e.id),Component:o.ValueBlock.Initializer,node:e,resultTitle:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=n,(0,i.useTranslation)(c,t)).t)(e)}("Calculation result")}}}],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)}}(f.prototype,t),f}(o.Instruction),m=f(563),v=f(505),h=f(721);function g(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 O(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 w(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 x(e,t){if(e){if("string"==typeof e)return g(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 g(e,t)}}var j=(0,v.observer)(function(r){var i,c,a=r.onChange,u=(0,v.useField)(),l=(0,v.useForm)(),s=((function(e){if(Array.isArray(e))return g(e)})(i=u.path.segments.slice(0,-1))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||x(i)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat(["sourceCollection"]).join("."),f=(c=(0,t.useState)(l.getValuesIn(s)),function(e){if(Array.isArray(e))return e}(c)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],c=!0,a=!1;try{for(o=o.call(e);!(c=(n=o.next()).done)&&(i.push(n.value),i.length!==t);c=!0);}catch(e){a=!0,r=e}finally{try{c||null==o.return||o.return()}finally{if(a)throw r}}return i}}(c,2)||x(c,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.")}()),p=f[0],y=f[1],b=(0,e.useCompile)(),d=(0,e.useCollectionManager)();(0,v.useFormEffects)(function(){(0,m.onFormInitialValuesChange)(function(e){y(e.getValuesIn(s))}),(0,m.onFieldInputValueChange)(s,function(e){y(e.value),a(null)})});var h=(0,o.getCollectionFieldOptions)({collection:p,compile:b,collectionManager:d});return n().createElement(e.Variable.TextArea,w(O({},r),{scope:h}))},{displayName:"InternalExpression"}),P=(0,v.connect)(j,(0,v.mapReadPretty)(function(r){var a=(0,i.useTranslation)().t,u=(0,e.useRecord)(),l=(0,e.useCompile)(),s=(0,e.useCollectionManager)(),f=(0,t.useMemo)(function(){return(0,o.getCollectionFieldOptions)({collection:u.sourceCollection,compile:l,collectionManager:s})},[s,l,u.sourceCollection]);return r.value?n().createElement(e.Variable.TextArea,w(O({},r),{scope:f})):n().createElement(h.Tag,null,a("Unconfigured",{ns:c}))}));function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C(e){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(E=function(){return!!e})()}var k=e.interfacesProperties.defaultProps,T=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n,r;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return n=t,r=arguments,n=C(n),S(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,E()?Reflect.construct(n,r||[],C(this).constructor):n.apply(this,r)),"name","expression"),S(e,"type","string"),S(e,"group","advanced"),S(e,"order",1),S(e,"title",'{{t("Expression", { ns: "'.concat(c,'" })}}')),S(e,"description",'{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "'.concat(c,'" })}}')),S(e,"sortable",!0),S(e,"default",{type:"text",uiSchema:{"x-component":"DynamicExpression"}}),S(e,"properties",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){S(e,t,n[t])})}return e}({},k)),S(e,"hidden",!0),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_(t,e),t}(e.CollectionFieldInterface),I=f(47);function F(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function V(e,t){return(V=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function R(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(R=function(){return!!e})()}var B=function(t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,r,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return r=n,o=arguments,r=q(r),F(t=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,R()?Reflect.construct(r,o||[],q(this).constructor):r.apply(this,o)),"name","expression"),F(t,"title",'{{t("Expression collection")}}'),F(t,"order",4),F(t,"color","orange"),F(t,"default",{createdBy:!0,updatedBy:!0,createdAt:!0,updatedAt:!0,fields:[{name:"engine",type:"string",interface:"radioGroup",uiSchema:{type:"string",title:'{{t("Calculation engine")}}',"x-component":"Radio.Group",enum:(0,I.getOptions)(),default:"formula.js"}},{name:"sourceCollection",type:"string",interface:"select",uiSchema:{type:"string",title:'{{t("Collection")}}',"x-component":"CollectionSelect","x-component-props":{}}},{name:"expression",type:"text",interface:"expression",uiSchema:{type:"string",title:'{{t("Expression")}}',"x-component":"DynamicExpression"}}]}),F(t,"availableFieldInterfaces",{include:[]}),F(t,"configurableProperties",(0,e.getConfigurableProperties)("title","name","inherits","category","description","presetFields")),t}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&V(n,t),n}(e.CollectionTemplate);function A(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function M(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){A(i,r,o,c,a,"next",e)}function a(e){A(i,r,o,c,a,"throw",e)}c(void 0)})}}function D(e,t,n){return(D=U()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&W(o,n.prototype),o}).apply(null,arguments)}function N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function W(e,t){return(W=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t="function"==typeof Map?new Map:void 0;return(G=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 D(e,arguments,N(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),W(n,e)})(e)}function U(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(U=function(){return!!e})()}function z(e,t){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var u=[i,a];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=t.call(e,c)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var $=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=N(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,U()?Reflect.construct(e,t||[],N(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&W(n,e),t=[{key:"afterAdd",value:function(){return M(function(){return z(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return M(function(){return z(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return M(function(){var t,n;return z(this,function(r){return e.app.dataSourceManager.addFieldInterfaces([T]),e.app.addComponents({DynamicExpression:P}),e.dataSourceManager.addCollectionTemplates([B]),t=e.app.pm.get("workflow"),n=new d,t.instructions.register(n.type,n),[2]})})()}}],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}(G(e.Plugin))}(),p}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/core"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react"),require("@formily/react"),require("@nocobase/evaluators/client"),require("@ant-design/icons"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-dynamic-calculation",["@formily/core","@nocobase/client","@nocobase/plugin-workflow/client","react","@formily/react","@nocobase/evaluators/client","@ant-design/icons","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-dynamic-calculation"]=t(require("@formily/core"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react"),require("@formily/react"),require("@nocobase/evaluators/client"),require("@ant-design/icons"),require("antd"),require("react-i18next")):e["@nocobase/plugin-workflow-dynamic-calculation"]=t(e["@formily/core"],e["@nocobase/client"],e["@nocobase/plugin-workflow/client"],e.react,e["@formily/react"],e["@nocobase/evaluators/client"],e["@ant-design/icons"],e.antd,e["react-i18next"])}(self,function(e,t,n,r,o,i,c,a,u){return function(){"use strict";var l={482:function(e){e.exports=c},563:function(t){t.exports=e},505:function(e){e.exports=o},772:function(e){e.exports=t},47:function(e){e.exports=i},433:function(e){e.exports=n},721:function(e){e.exports=a},156:function(e){e.exports=r},238:function(e){e.exports=u}},s={};function f(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return l[e](n,n.exports,f),n.exports}f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var n in t)f.o(t,n)&&!f.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};return!function(){f.r(p),f.d(p,{default:function(){return z}});var e=f(772),t=f(156),n=f.n(t),r=f(482),o=f(433),i=f(238),c="workflow-dynamic-calculation";function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}function y(e){var t;return!!["belongsTo","hasOne"].includes(e.type)&&((null==(t=this.getCollection(e.collectionName))?void 0:t.template)==="expression"||this.getCollectionFields(e.target).some(function(e){return"expression"===e.interface}))}function b(t){var r=t.value,i=t.onChange,c=(0,e.useCollectionManager_deprecated)(),a=c.getCollectionFields,u=c.getCollection,l=(0,o.useWorkflowVariableOptions)({types:[y.bind({getCollectionFields:a,getCollection:u})]});return n().createElement(e.Variable.Input,{value:r,onChange:i,scope:l})}var d=function(t){var f;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function p(){var e,t,i;if(!(this instanceof p))throw TypeError("Cannot call a class as a function");return t=p,i=arguments,t=u(t),a(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,s()?Reflect.construct(t,i||[],u(this).constructor):t.apply(this,i)),"title",'{{t("Dynamic expression calculation", { ns: "'.concat(c,'" })}}')),a(e,"type","dynamic-calculation"),a(e,"group","calculation"),a(e,"description",'{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression is dynamic one from an expression collections.", { ns: "'.concat(c,'" })}}')),a(e,"icon",n().createElement(r.FunctionOutlined,null)),a(e,"fieldset",{expression:{type:"string",title:'{{t("Calculation expression", { ns: "'.concat(c,'" })}}'),"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:'{{t("Variable datasource", { ns: "'.concat(c,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}}),a(e,"components",{DynamicExpression:b,WorkflowVariableInput:o.WorkflowVariableInput,ValueBlock:o.ValueBlock}),e}return p.prototype=Object.create(t&&t.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),t&&l(p,t),f=[{key:"useVariables",value:function(e,t){var n,r=e.key,i=e.title,c=t.types,u=t.fieldNames,l=void 0===u?o.defaultFieldNames:u;return c&&!c.some(function(e){return e in o.BaseTypeSets||Object.values(o.BaseTypeSets).some(function(t){return t.has(e)})})?null:(a(n={},l.value,r),a(n,l.label,i),n)}},{key:"useInitializers",value:function(e){var t;return{name:"#".concat(e.id),type:"item",title:null!=(t=e.title)?t:"#".concat(e.id),Component:o.ValueBlock.Initializer,node:e,resultTitle:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=n,(0,i.useTranslation)(c,t)).t)(e)}("Calculation result")}}},{key:"getCreateModelMenuItem",value:function(t){var n,r=t.node;return{key:"#".concat(r.id),label:null!=(n=r.title)?n:"#".concat(r.id),useModel:"NodeValueModel",createModelOptions:{use:"NodeValueModel",stepParams:{valueSettings:{init:{dataSource:"{{$jobsMapByNodeKey.".concat(r.key,"}}"),defaultValue:function(t){var n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.i18n.t(t,(n=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}({},o),r=r={ns:c},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n))}("Calculation result")}},cardSettings:{titleDescription:{title:'{{t("Dynamic expression calculation", { ns: "'.concat(c,'" })}}')}}}}}}}],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)}}(p.prototype,f),p}(o.Instruction),m=f(563),v=f(505),g=f(721);function h(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 O(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 w(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 j(e,t){if(e){if("string"==typeof e)return h(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 h(e,t)}}var x=(0,v.observer)(function(r){var i,c,a=r.onChange,u=(0,v.useField)(),l=(0,v.useForm)(),s=((function(e){if(Array.isArray(e))return h(e)})(i=u.path.segments.slice(0,-1))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||j(i)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat(["sourceCollection"]).join("."),f=(c=(0,t.useState)(l.getValuesIn(s)),function(e){if(Array.isArray(e))return e}(c)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],c=!0,a=!1;try{for(o=o.call(e);!(c=(n=o.next()).done)&&(i.push(n.value),i.length!==t);c=!0);}catch(e){a=!0,r=e}finally{try{c||null==o.return||o.return()}finally{if(a)throw r}}return i}}(c,2)||j(c,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.")}()),p=f[0],y=f[1],b=(0,e.useCompile)(),d=(0,e.useCollectionManager)();(0,v.useFormEffects)(function(){(0,m.onFormInitialValuesChange)(function(e){y(e.getValuesIn(s))}),(0,m.onFieldInputValueChange)(s,function(e){y(e.value),a(null)})});var g=(0,o.getCollectionFieldOptions)({collection:p,compile:b,collectionManager:d});return n().createElement(e.Variable.TextArea,w(O({},r),{scope:g}))},{displayName:"InternalExpression"}),P=(0,v.connect)(x,(0,v.mapReadPretty)(function(r){var a=(0,i.useTranslation)().t,u=(0,e.useRecord)(),l=(0,e.useCompile)(),s=(0,e.useCollectionManager)(),f=(0,t.useMemo)(function(){return(0,o.getCollectionFieldOptions)({collection:u.sourceCollection,compile:l,collectionManager:s})},[s,l,u.sourceCollection]);return r.value?n().createElement(e.Variable.TextArea,w(O({},r),{scope:f})):n().createElement(g.Tag,null,a("Unconfigured",{ns:c}))}));function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C(e){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function k(e,t){return(k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}var E=e.interfacesProperties.defaultProps,T=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n,r;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return n=t,r=arguments,n=C(n),S(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,_()?Reflect.construct(n,r||[],C(this).constructor):n.apply(this,r)),"name","expression"),S(e,"type","string"),S(e,"group","advanced"),S(e,"order",1),S(e,"title",'{{t("Expression", { ns: "'.concat(c,'" })}}')),S(e,"description",'{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "'.concat(c,'" })}}')),S(e,"sortable",!0),S(e,"default",{type:"text",uiSchema:{"x-component":"DynamicExpression"}}),S(e,"properties",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){S(e,t,n[t])})}return e}({},E)),S(e,"hidden",!0),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e),t}(e.CollectionFieldInterface),I=f(47);function M(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function V(e,t){return(V=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function q(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(q=function(){return!!e})()}var D=function(t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,r,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return r=n,o=arguments,r=F(r),M(t=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(r,o||[],F(this).constructor):r.apply(this,o)),"name","expression"),M(t,"title",'{{t("Expression collection")}}'),M(t,"order",4),M(t,"color","orange"),M(t,"default",{createdBy:!0,updatedBy:!0,createdAt:!0,updatedAt:!0,fields:[{name:"engine",type:"string",interface:"radioGroup",uiSchema:{type:"string",title:'{{t("Calculation engine")}}',"x-component":"Radio.Group",enum:(0,I.getOptions)(),default:"formula.js"}},{name:"sourceCollection",type:"string",interface:"select",uiSchema:{type:"string",title:'{{t("Collection")}}',"x-component":"CollectionSelect","x-component-props":{}}},{name:"expression",type:"text",interface:"expression",uiSchema:{type:"string",title:'{{t("Expression")}}',"x-component":"DynamicExpression"}}]}),M(t,"availableFieldInterfaces",{include:[]}),M(t,"configurableProperties",(0,e.getConfigurableProperties)("title","name","inherits","category","description","presetFields")),t}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&V(n,t),n}(e.CollectionTemplate);function B(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function R(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){B(i,r,o,c,a,"next",e)}function a(e){B(i,r,o,c,a,"throw",e)}c(void 0)})}}function A(e,t,n){return(A=U()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&W(o,n.prototype),o}).apply(null,arguments)}function N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function W(e,t){return(W=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t="function"==typeof Map?new Map:void 0;return(G=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 A(e,arguments,N(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),W(n,e)})(e)}function U(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(U=function(){return!!e})()}function $(e,t){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var u=[i,a];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=t.call(e,c)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var z=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=N(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,U()?Reflect.construct(e,t||[],N(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&W(n,e),t=[{key:"afterAdd",value:function(){return R(function(){return $(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return R(function(){return $(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return R(function(){var t,n;return $(this,function(r){return e.app.dataSourceManager.addFieldInterfaces([T]),e.app.addComponents({DynamicExpression:P}),e.dataSourceManager.addCollectionTemplates([D]),t=e.app.pm.get("workflow"),n=new d,t.instructions.register(n.type,n),[2]})})()}}],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}(G(e.Plugin))}(),p}()});
@@ -10,14 +10,15 @@
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
12
  "@ant-design/icons": "5.6.1",
13
- "@nocobase/client": "2.0.0-alpha.63",
14
- "@nocobase/plugin-workflow": "2.0.0-alpha.63",
13
+ "@nocobase/client": "2.0.0-alpha.65",
14
+ "@nocobase/plugin-workflow": "2.0.0-alpha.65",
15
+ "@nocobase/flow-engine": "2.0.0-alpha.65",
15
16
  "@formily/core": "2.3.7",
16
17
  "@formily/react": "2.3.7",
17
18
  "antd": "5.24.2",
18
19
  "react-i18next": "11.18.6",
19
- "@nocobase/evaluators": "2.0.0-alpha.63",
20
- "@nocobase/utils": "2.0.0-alpha.63",
21
- "@nocobase/server": "2.0.0-alpha.63",
22
- "@nocobase/database": "2.0.0-alpha.63"
20
+ "@nocobase/evaluators": "2.0.0-alpha.65",
21
+ "@nocobase/utils": "2.0.0-alpha.65",
22
+ "@nocobase/server": "2.0.0-alpha.65",
23
+ "@nocobase/database": "2.0.0-alpha.65"
23
24
  };
@@ -9,3 +9,4 @@
9
9
  export declare const NAMESPACE = "workflow-dynamic-calculation";
10
10
  export declare function useLang(key: string, options?: {}): string;
11
11
  export declare function usePluginTranslation(options: any): import("react-i18next").UseTranslationResponse<"workflow-dynamic-calculation", undefined>;
12
+ export declare function lang(key: string, options?: {}): string;
@@ -27,10 +27,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
27
27
  var locale_exports = {};
28
28
  __export(locale_exports, {
29
29
  NAMESPACE: () => NAMESPACE,
30
+ lang: () => lang,
30
31
  useLang: () => useLang,
31
32
  usePluginTranslation: () => usePluginTranslation
32
33
  });
33
34
  module.exports = __toCommonJS(locale_exports);
35
+ var import_client = require("@nocobase/client");
34
36
  var import_react_i18next = require("react-i18next");
35
37
  const NAMESPACE = "workflow-dynamic-calculation";
36
38
  function useLang(key, options = {}) {
@@ -40,9 +42,13 @@ function useLang(key, options = {}) {
40
42
  function usePluginTranslation(options) {
41
43
  return (0, import_react_i18next.useTranslation)(NAMESPACE, options);
42
44
  }
45
+ function lang(key, options = {}) {
46
+ return import_client.i18n.t(key, { ...options, ns: NAMESPACE });
47
+ }
43
48
  // Annotate the CommonJS export names for ESM import in node:
44
49
  0 && (module.exports = {
45
50
  NAMESPACE,
51
+ lang,
46
52
  useLang,
47
53
  usePluginTranslation
48
54
  });
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Useful plugin for doing dynamic calculation based on expression collection records in workflow.",
7
7
  "description.zh-CN": "用于在工作流中进行基于数据行的动态表达式计算。",
8
8
  "description.ru-RU": "Плагин для выполнения динамических вычислений на основе записей коллекции выражений в рабочем процессе.",
9
- "version": "2.0.0-alpha.63",
9
+ "version": "2.0.0-alpha.65",
10
10
  "license": "AGPL-3.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/workflow-dynamic-calculation",
@@ -33,7 +33,7 @@
33
33
  "@nocobase/test": "2.x",
34
34
  "@nocobase/utils": "2.x"
35
35
  },
36
- "gitHead": "0d5e9eb45e4d0f3ba70d7561a0d296d12a4d8bf8",
36
+ "gitHead": "790dd7ba2bb5b1dc905163f11c7b492a5b862365",
37
37
  "keywords": [
38
38
  "Workflow",
39
39
  "Collections"