@nocobase/plugin-workflow-dynamic-calculation 0.17.0-alpha.6 → 0.17.0-alpha.7
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/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react-i18next"),require("@nocobase/plugin-workflow/client"),require("@formily/core"),require("@formily/react"),require("antd"),require("react")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react-i18next","@nocobase/plugin-workflow/client","@formily/core","@formily/react","antd","react"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-workflow-dynamic-calculation"]={},n["@nocobase/client"],n.jsxRuntime,n["react-i18next"],n["@nocobase/plugin-workflow"],n["@formily/core"],n["@formily/react"],n.antd,n.react))})(this,function(n,e,o,C,r,g,u,x,c){"use strict";var z=Object.defineProperty,L=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var v=(n,e,o)=>e in n?z(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o,m=(n,e)=>{for(var o in e||(e={}))U.call(e,o)&&v(n,o,e[o]);if(F)for(var o of F(e))G.call(e,o)&&v(n,o,e[o]);return n},y=(n,e)=>L(n,_(e));var f=(n,e,o)=>(v(n,typeof e!="symbol"?e+"":e,o),o);var w=(n,e,o)=>new Promise((C,r)=>{var g=c=>{try{x(o.next(c))}catch(a){r(a)}},u=c=>{try{x(o.throw(c))}catch(a){r(a)}},x=c=>c.done?C(c.value):Promise.resolve(c.value).then(g,u);x((o=o.apply(n,e)).next())});const a="workflow-dynamic-calculation";function k(s,i={}){const{t}=I(i);return t(s)}function I(s){return C.useTranslation(a,s)}const{defaultProps:T}=e.interfacesProperties,P={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${a}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${a}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:m({},T)};function E(s){const i=e.useCollectionManager();return o.jsx(e.CollectionManagerContext.Provider,{value:y(m({},i),{interfaces:y(m({},i.interfaces),{expression:P})}),children:s.children})}function M(s){var t;return["belongsTo","hasOne"].includes(s.type)?((t=this.getCollection(s.collectionName))==null?void 0:t.template)==="expression"?!0:this.getCollectionFields(s.target).some(l=>l.interface==="expression"):!1}function q({value:s,onChange:i}){const{getCollectionFields:t,getCollection:l}=e.useCollectionManager(),d=r.useWorkflowVariableOptions({types:[M.bind({getCollectionFields:t,getCollection:l})]});return o.jsx(e.Variable.Input,{value:s,onChange:i,scope:d})}class j extends r.Instruction{constructor(){super(...arguments);f(this,"title",`{{t("Dynamic Calculation", { ns: "${a}" })}}`);f(this,"type","dynamic-calculation");f(this,"group","
|
|
1
|
+
(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react-i18next"),require("@nocobase/plugin-workflow/client"),require("@formily/core"),require("@formily/react"),require("antd"),require("react")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react-i18next","@nocobase/plugin-workflow/client","@formily/core","@formily/react","antd","react"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-workflow-dynamic-calculation"]={},n["@nocobase/client"],n.jsxRuntime,n["react-i18next"],n["@nocobase/plugin-workflow"],n["@formily/core"],n["@formily/react"],n.antd,n.react))})(this,function(n,e,o,C,r,g,u,x,c){"use strict";var z=Object.defineProperty,L=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var v=(n,e,o)=>e in n?z(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o,m=(n,e)=>{for(var o in e||(e={}))U.call(e,o)&&v(n,o,e[o]);if(F)for(var o of F(e))G.call(e,o)&&v(n,o,e[o]);return n},y=(n,e)=>L(n,_(e));var f=(n,e,o)=>(v(n,typeof e!="symbol"?e+"":e,o),o);var w=(n,e,o)=>new Promise((C,r)=>{var g=c=>{try{x(o.next(c))}catch(a){r(a)}},u=c=>{try{x(o.throw(c))}catch(a){r(a)}},x=c=>c.done?C(c.value):Promise.resolve(c.value).then(g,u);x((o=o.apply(n,e)).next())});const a="workflow-dynamic-calculation";function k(s,i={}){const{t}=I(i);return t(s)}function I(s){return C.useTranslation(a,s)}const{defaultProps:T}=e.interfacesProperties,P={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${a}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${a}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:m({},T)};function E(s){const i=e.useCollectionManager();return o.jsx(e.CollectionManagerContext.Provider,{value:y(m({},i),{interfaces:y(m({},i.interfaces),{expression:P})}),children:s.children})}function M(s){var t;return["belongsTo","hasOne"].includes(s.type)?((t=this.getCollection(s.collectionName))==null?void 0:t.template)==="expression"?!0:this.getCollectionFields(s.target).some(l=>l.interface==="expression"):!1}function q({value:s,onChange:i}){const{getCollectionFields:t,getCollection:l}=e.useCollectionManager(),d=r.useWorkflowVariableOptions({types:[M.bind({getCollectionFields:t,getCollection:l})]});return o.jsx(e.Variable.Input,{value:s,onChange:i,scope:d})}class j extends r.Instruction{constructor(){super(...arguments);f(this,"title",`{{t("Dynamic Calculation", { ns: "${a}" })}}`);f(this,"type","dynamic-calculation");f(this,"group","extended");f(this,"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: "${a}" })}}`);f(this,"fieldset",{expression:{type:"string",title:`{{t("Calculation expression", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${a}" })}}`,"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]}}"}}}}});f(this,"components",{DynamicExpression:q,WorkflowVariableInput:r.WorkflowVariableInput,ValueBlock:r.ValueBlock})}useVariables({key:t,title:l},{types:d,fieldNames:p=r.defaultFieldNames}){return d&&!d.some(h=>h in r.BaseTypeSets||Object.values(r.BaseTypeSets).some(b=>b.has(h)))?null:{[p.value]:t,[p.label]:l}}useInitializers(t){var l;return{name:`#${t.id}`,type:"item",title:(l=t.title)!=null?l:`#${t.id}`,Component:r.ValueBlock.Initializer,node:t,resultTitle:k("Calculation result")}}}const D=u.observer(s=>{const{onChange:i}=s,t=u.useField(),l=u.useForm(),p=[...t.path.segments.slice(0,-1),"sourceCollection"].join("."),[h,b]=c.useState(l.getValuesIn(p)),B=e.useCompile(),{getCollectionFields:W}=e.useCollectionManager();u.useFormEffects(()=>{g.onFormInitialValuesChange(V=>{b(V.getValuesIn(p))}),g.onFieldInputValueChange(p,V=>{b(V.value),i(null)})});const N=r.getCollectionFieldOptions({collection:h,compile:B,getCollectionFields:W});return o.jsx(e.Variable.TextArea,y(m({},s),{scope:N}))},{displayName:"InternalExpression"});function O(s){const{t:i}=C.useTranslation(),t=e.useRecord(),l=e.useCompile(),{getCollectionFields:d}=e.useCollectionManager(),p=c.useMemo(()=>r.getCollectionFieldOptions({collection:t.sourceCollection,compile:l,getCollectionFields:d}),[t.sourceCollection,t.sourceCollection]);return s.value?o.jsx(e.Variable.TextArea,y(m({},s),{scope:p})):o.jsx(x.Tag,{children:i("Unconfigured",{ns:a})})}const S=u.connect(D,u.mapReadPretty(O));class A extends e.Plugin{afterAdd(){return w(this,null,function*(){})}beforeLoad(){return w(this,null,function*(){})}load(){return w(this,null,function*(){this.app.addProvider(E);const i=this.app.pm.get("workflow"),t=new j;i.instructions.register(t.type,t)})}addComponents(){this.app.addComponents({DynamicExpression:S})}}n.default=A,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.2.0",
|
|
3
|
-
"@nocobase/client": "0.17.0-alpha.
|
|
4
|
-
"@nocobase/plugin-workflow": "0.17.0-alpha.
|
|
3
|
+
"@nocobase/client": "0.17.0-alpha.7",
|
|
4
|
+
"@nocobase/plugin-workflow": "0.17.0-alpha.7",
|
|
5
5
|
"@formily/core": "2.2.27",
|
|
6
6
|
"@formily/react": "2.2.27",
|
|
7
7
|
"antd": "5.8.6",
|
|
8
8
|
"react-i18next": "11.18.6",
|
|
9
|
-
"@nocobase/utils": "0.17.0-alpha.
|
|
10
|
-
"@nocobase/evaluators": "0.17.0-alpha.
|
|
11
|
-
"@nocobase/server": "0.17.0-alpha.
|
|
12
|
-
"@nocobase/database": "0.17.0-alpha.
|
|
9
|
+
"@nocobase/utils": "0.17.0-alpha.7",
|
|
10
|
+
"@nocobase/evaluators": "0.17.0-alpha.7",
|
|
11
|
+
"@nocobase/server": "0.17.0-alpha.7",
|
|
12
|
+
"@nocobase/database": "0.17.0-alpha.7"
|
|
13
13
|
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流:动态表达式计算节点",
|
|
5
5
|
"description": "Useful plugin for doing dynamic calculation based on expression collection records in workflow.",
|
|
6
6
|
"description.zh-CN": "用于在工作流中进行基于数据行的动态表达式计算。",
|
|
7
|
-
"version": "0.17.0-alpha.
|
|
7
|
+
"version": "0.17.0-alpha.7",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"devDependencies": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"@nocobase/test": "0.x",
|
|
30
30
|
"@nocobase/utils": "0.x"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "91377a3abd1124f79fb3819f2d0e80905e091a32"
|
|
33
33
|
}
|
|
@@ -36,7 +36,7 @@ function DynamicExpression({ value, onChange }) {
|
|
|
36
36
|
export default class extends Instruction {
|
|
37
37
|
title = `{{t("Dynamic Calculation", { ns: "${NAMESPACE}" })}}`;
|
|
38
38
|
type = 'dynamic-calculation';
|
|
39
|
-
group = '
|
|
39
|
+
group = 'extended';
|
|
40
40
|
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: "${NAMESPACE}" })}}`;
|
|
41
41
|
fieldset = {
|
|
42
42
|
expression: {
|