@nocobase/plugin-workflow-loop 1.7.0-beta.3 → 1.7.0-beta.31

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.
@@ -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("antd"),require("@nocobase/plugin-workflow/client"),require("@ant-design/icons"),require("@formily/react"),require("react-i18next"),require("@nocobase/client"),require("@formily/antd-v5"),require("react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-loop",["antd","@nocobase/plugin-workflow/client","@ant-design/icons","@formily/react","react-i18next","@nocobase/client","@formily/antd-v5","react"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-loop"]=t(require("antd"),require("@nocobase/plugin-workflow/client"),require("@ant-design/icons"),require("@formily/react"),require("react-i18next"),require("@nocobase/client"),require("@formily/antd-v5"),require("react")):e["@nocobase/plugin-workflow-loop"]=t(e.antd,e["@nocobase/plugin-workflow/client"],e["@ant-design/icons"],e["@formily/react"],e["react-i18next"],e["@nocobase/client"],e["@formily/antd-v5"],e.react)}(self,function(e,t,n,r,o,i,a,l){return function(){"use strict";var c={482:function(e){e.exports=n},632:function(e){e.exports=a},505:function(e){e.exports=r},772:function(e){e.exports=i},433:function(e){e.exports=t},721:function(t){t.exports=e},156:function(e){e.exports=l},238:function(e){e.exports=o}},u={};function s(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return c[e](n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var f={};s.r(f),s.d(f,{default:function(){return Y}});var p=s("772"),d=s("156"),b=s.n(d),y=s("482"),m=s("721"),v=s("632"),h=s("505"),g=s("433"),w=s("238"),O="workflow-loop";function x(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,function(e){return(0,w.useTranslation)(O,e)}(t).t)(e)}function k(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 j(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)}}function E(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 P(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){E(e,t,n[t])})}return e}function S(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 T(e,t){return(T=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function q(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function _(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function F(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(F=function(){return!!e})()}function I(){var e=q(["\n padding-left: 4em;\n "]);return I=function(){return e},e}function W(){var e=q(["\n width: 100%;\n\n .variable {\n flex: 1;\n }\n\n .ant-input.null-value {\n width: 100%;\n }\n "]);return W=function(){return e},e}function A(e){var t=e.value,n=e.onChange,r=(0,w.useTranslation)().t,o=(0,d.useCallback)(function(e){n(S(P({},t),{checkpoint:e.target.value}))},[t,n]),i=(0,d.useCallback)(function(e){n(S(P({},t),{continueOnFalse:e.target.value}))},[t,n]),a=(0,d.useCallback)(function(e){n(S(P({},t),{calculation:e}))},[t,n]);return b().createElement(b().Fragment,null,b().createElement(m.Checkbox,{checked:!!t,onChange:function(e){n(!!e.target.checked&&{checkpoint:0,continueOnFalse:!1,calculation:{group:{type:"and",calculations:[]}}})}},r("Enable loop condition",{ns:O})),t?b().createElement(m.Card,null,b().createElement(v.FormLayout,{layout:"vertical"},b().createElement(v.FormItem,{label:r("Condition",{ns:O})},b().createElement(g.CalculationConfig,{value:t.calculation,onChange:a,useVariableHook:L})),b().createElement(v.FormItem,{label:r("When to check",{ns:O})},b().createElement(g.RadioWithTooltip,{value:t.checkpoint,onChange:o,options:[{label:r("Before each starts",{ns:O}),value:0},{label:r("After each ends",{ns:O}),value:1}]})),b().createElement(v.FormItem,{label:r("When condition is not met on item",{ns:O})},b().createElement(g.RadioWithTooltip,{value:t.continueOnFalse,onChange:i,options:[{label:r("Exit loop",{ns:O}),value:!1},{label:r("Continue on next item",{ns:O}),value:!0}]})))):null)}function R(e,t){var n,r,o,i,a=(0,p.useCompile)(),l=x("Loop target"),c=x("Loop index (starts from 0)"),u=x("Loop sequence (starts from 1)"),s=x("Loop length"),f=e.config.target;if(null==f)return null;var d=t.fieldNames,b=void 0===d?g.defaultFieldNames:d,y=t.scope,m=(E(n={key:"item"},b.value,"item"),E(n,b.label,l),n);if("string"==typeof f&&f.startsWith("{{")&&f.endsWith("}}")){var v=f.slice(2,-2).split(".").map(function(e){return e.trim()});m=Object.assign({},function(e,t){for(var n=e,r=null,o=0;o<t.length;o++){var i=function(e){var o=t[e],i=n.find(function(e){return e.value===o});if(!i)return{v:null};r=i,!i.isLeaf&&i.loadChildren&&i.loadChildren(i),i.children&&(n=i.children)}(o);if("object"===_(i))return i.v}return r}(null!=y?y:[g.scopeOptions,g.nodesOptions,g.triggerOptions].map(function(n){var r,o=n.useOptions(S(P({},t),{current:e})).filter(Boolean);return E(r={},b.label,a(n.label)),E(r,b.value,n.value),E(r,"key",n.value),E(r,b.children,o),E(r,"disabled",o&&!o.length),r}),v),m)}return[m,(E(r={key:"index"},b.value,"index"),E(r,b.label,c),r),(E(o={key:"sequence"},b.value,"sequence"),E(o,b.label,u),o),(E(i={key:"length"},b.value,"length"),E(i,b.label,s),i)]}function L(){var e,t,n,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=(0,h.useForm)().values,i=(0,g.useNodeContext)(),a=S(P({},i),{config:S(P({},i.config),{target:o.target})}),l=(0,g.useWorkflowVariableOptions)(r),c=R(a,S(P({},r),{scope:l.filter(function(e){return["$scopes","$jobsMapByNodeKey","$context"].includes(e.key)})})),u=r.fieldNames,s=void 0===u?g.defaultFieldNames:u;if(!c)return l;var f=l.find(function(e){return"$scopes"===e[s.value]});return f&&(!f[s.children]&&(f[s.children]=[]),f[s.children].unshift((E(n={key:i.key},s.value,i.key),E(n,s.label,null!==(t=i.title)&&void 0!==t?t:"#".concat(i.id)),E(n,s.children,c),n)),f.disabled=!1),function(e){if(Array.isArray(e))return k(e)}(e=l)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return k(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 k(e,t)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e){var t=e.variableOptions,n=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++){if(n=i[r],!(t.indexOf(n)>=0))Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}}return o}(e,["variableOptions"]),r=L(t);return b().createElement(p.Variable.TextArea,P({scope:r},n))}var V=function(e){var t,n,r;function o(){var e,t,n,r;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),t=this,n=o,r=arguments,n=C(n),E(e=function(e,t){return t&&("object"===_(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,F()?Reflect.construct(n,r||[],C(t).constructor):n.apply(t,r)),"title",'{{t("Loop", { ns: "'.concat(O,'" })}}')),E(e,"type","loop"),E(e,"group","control"),E(e,"description",'{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "'.concat(O,'" })}}')),E(e,"icon",b().createElement(y.RollbackOutlined,{style:{}})),E(e,"fieldset",{target:{type:"string",title:'{{t("Loop target", { ns: "'.concat(O,'" })}}'),description:'{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "'.concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,nullable:!1,useTypedConstant:["string",["number",{step:1,min:0,precision:0}]],className:(0,p.css)(W())},required:!0,default:1,"x-reactions":[{target:"calculation",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"expression",effects:["onFieldValueChange"],fulfill:{state:{value:""}}}]},condition:{type:"boolean","x-decorator":"FormItem","x-component":"LoopCondition","x-reactions":[{dependencies:["target"],fulfill:{state:{visible:"{{Boolean($deps[0])}}"}}}],default:!1},exit:{type:"number",title:'{{t("When node inside loop failed", { ns: "'.concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Exit workflow", { ns: "'.concat(O,'" })}}'),value:0},{label:'{{t("Exit loop and continue workflow", { ns: "'.concat(O,'" })}}'),value:1},{label:'{{t("Continue loop on next item", { ns: "'.concat(O,'" })}}'),value:2}]},default:0}}),E(e,"branching",!0),E(e,"scope",{renderEngineReference:g.renderEngineReference}),E(e,"components",{LoopCondition:A,WorkflowVariableInput:g.WorkflowVariableInput,WorkflowVariableTextArea:g.WorkflowVariableTextArea,LoopVariableTextArea:N,RadioWithTooltip:g.RadioWithTooltip,CalculationConfig:g.CalculationConfig}),E(e,"useScopeVariables",R),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&T(e,t)}(o,e),t=o,n=[{key:"Component",value:function(e){var t,n=e.data,r=(0,g.useFlowContext)().nodes,o=(0,g.useStyles)().styles,i=r.find(function(e){return e.upstreamId===n.id&&null!=e.branchIndex});return b().createElement(g.NodeDefaultView,{data:n},b().createElement("div",{className:o.nodeSubtreeClass},b().createElement("div",{className:(0,p.cx)(o.branchBlockClass,(0,p.css)(I()))},b().createElement(g.Branch,{from:n,entry:i,branchIndex:null!==(t=null==i?void 0:i.branchIndex)&&void 0!==t?t:0}),b().createElement("div",{className:o.branchClass,style:{minWidth:"4em"}},b().createElement("div",{className:"workflow-branch-lines"}),b().createElement("div",{className:o.loopLineClass},b().createElement(y.ArrowUpOutlined,null))))))}}],j(t.prototype,n),o}(g.Instruction);function B(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).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 a(e){B(i,r,o,a,l,"next",e)}function l(e){B(i,r,o,a,l,"throw",e)}a(void 0)})}}function $(e,t,n){return($=G()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&H(o,n.prototype),o}).apply(null,arguments)}function D(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)}}function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function H(e,t){return(H=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function U(e){var t="function"==typeof Map?new Map:void 0;return(U=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return $(e,arguments,z(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),H(r,e)})(e)}function G(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(G=function(){return!!e})()}function K(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}var Y=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=z(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,G()?Reflect.construct(t,n||[],z(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&H(e,t)}(o,e),t=o,n=[{key:"afterAdd",value:function(){return M(function(){return K(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return M(function(){return K(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return M(function(){return K(this,function(t){return e.app.pm.get("workflow").registerInstruction("loop",V),[2]})})()}}],D(t.prototype,n),o}(U(p.Plugin));return f}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@formily/antd-v5"),require("@formily/react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-loop",["react","@formily/antd-v5","@formily/react","@nocobase/client","@ant-design/icons","antd","@nocobase/plugin-workflow/client","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-loop"]=t(require("react"),require("@formily/antd-v5"),require("@formily/react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):e["@nocobase/plugin-workflow-loop"]=t(e.react,e["@formily/antd-v5"],e["@formily/react"],e["@nocobase/client"],e["@ant-design/icons"],e.antd,e["@nocobase/plugin-workflow/client"],e["react-i18next"])}(self,function(e,t,n,r,o,i,a,l){return function(){"use strict";var c={482:function(e){e.exports=o},632:function(e){e.exports=t},505:function(e){e.exports=n},772:function(e){e.exports=r},433:function(e){e.exports=a},721:function(e){e.exports=i},156:function(t){t.exports=e},238:function(e){e.exports=l}},u={};function s(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return c[e](n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var f={};return!function(){s.r(f),s.d(f,{default:function(){return L}});var e=s(772),t=s(156),n=s.n(t),r=s(482),o=s(721),i=s(632),a=s(505),l=s(433),c=s(238),u="workflow-loop";function p(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=n,(0,c.useTranslation)(u,t)).t)(e)}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(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){b(e,t,n[t])})}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function w(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function x(){var e=g(["\n padding-left: 4em;\n "]);return x=function(){return e},e}function k(){var e=g(["\n width: 100%;\n\n .variable {\n flex: 1;\n }\n\n .ant-input.null-value {\n width: 100%;\n }\n "]);return k=function(){return e},e}function j(e){var r=e.value,a=e.onChange,s=(0,c.useTranslation)().t,f=(0,t.useCallback)(function(e){a(v(m({},r),{checkpoint:e.target.value}))},[r,a]),p=(0,t.useCallback)(function(e){a(v(m({},r),{continueOnFalse:e.target.value}))},[r,a]),d=(0,t.useCallback)(function(e){a(v(m({},r),{calculation:e}))},[r,a]);return n().createElement(n().Fragment,null,n().createElement(o.Checkbox,{checked:!!r,onChange:function(e){a(!!e.target.checked&&{checkpoint:0,continueOnFalse:!1,calculation:{group:{type:"and",calculations:[]}}})}},s("Enable loop condition",{ns:u})),r?n().createElement(o.Card,null,n().createElement(i.FormLayout,{layout:"vertical"},n().createElement(i.FormItem,{label:s("Condition",{ns:u})},n().createElement(l.CalculationConfig,{value:r.calculation,onChange:d,useVariableHook:C})),n().createElement(i.FormItem,{label:s("When to check",{ns:u})},n().createElement(l.RadioWithTooltip,{value:r.checkpoint,onChange:f,options:[{label:s("Before each starts",{ns:u}),value:0},{label:s("After each ends",{ns:u}),value:1}]})),n().createElement(i.FormItem,{label:s("When condition is not met on item",{ns:u})},n().createElement(l.RadioWithTooltip,{value:r.continueOnFalse,onChange:p,options:[{label:s("Exit loop",{ns:u}),value:!1},{label:s("Continue on next item",{ns:u}),value:!0}]})))):null)}function E(t,n){var r,o,i,a,c=(0,e.useCompile)(),u=p("Loop target"),s=p("Loop index (starts from 0)"),f=p("Loop sequence (starts from 1)"),d=p("Loop length"),y=t.config.target;if(null==y)return null;var h=n.fieldNames,g=void 0===h?l.defaultFieldNames:h,O=n.scope,x=(b(r={key:"item"},g.value,"item"),b(r,g.label,u),r);if("string"==typeof y&&y.startsWith("{{")&&y.endsWith("}}")){var k=y.slice(2,-2).split(".").map(function(e){return e.trim()});x=Object.assign({},function(e,t){for(var n=e,r=null,o=0;o<t.length;o++){var i=function(e){var o=t[e],i=n.find(function(e){return e.value===o});if(!i)return{v:null};r=i,!i.isLeaf&&i.loadChildren&&i.loadChildren(i),i.children&&(n=i.children)}(o);if("object"===w(i))return i.v}return r}(null!=O?O:[l.scopeOptions,l.nodesOptions,l.triggerOptions].map(function(e){var r,o=e.useOptions(v(m({},n),{current:t})).filter(Boolean);return b(r={},g.label,c(e.label)),b(r,g.value,e.value),b(r,"key",e.value),b(r,g.children,o),b(r,"disabled",o&&!o.length),r}),k),x)}return[x,(b(o={key:"index"},g.value,"index"),b(o,g.label,s),o),(b(i={key:"sequence"},g.value,"sequence"),b(i,g.label,f),i),(b(a={key:"length"},g.value,"length"),b(a,g.label,d),a)]}function C(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=(0,a.useForm)().values,o=(0,l.useNodeContext)(),i=v(m({},o),{config:v(m({},o.config),{target:r.target})}),c=(0,l.useWorkflowVariableOptions)(n),u=E(i,v(m({},n),{scope:c.filter(function(e){return["$scopes","$jobsMapByNodeKey","$context"].includes(e.key)})})),s=n.fieldNames,f=void 0===s?l.defaultFieldNames:s;if(!u)return c;var p=c.find(function(e){return"$scopes"===e[f.value]});return p&&(p[f.children]||(p[f.children]=[]),p[f.children].unshift((b(t={key:o.key},f.value,o.key),b(t,f.label,null!=(e=o.title)?e:"#".concat(o.id)),b(t,f.children,u),t)),p.disabled=!1),function(e){if(Array.isArray(e))return d(e)}(c)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(c)||function(e,t){if(e){if("string"==typeof e)return d(e,void 0);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 d(e,t)}}(c)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(t){var r=t.variableOptions,o=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(t,["variableOptions"]),i=C(r);return n().createElement(e.Variable.TextArea,m({scope:i},o))}var S=function(t){var o;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function i(){var t,o,a;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return o=i,a=arguments,o=y(o),b(t=function(e,t){if(t&&("object"===w(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,O()?Reflect.construct(o,a||[],y(this).constructor):o.apply(this,a)),"title",'{{t("Loop", { ns: "'.concat(u,'" })}}')),b(t,"type","loop"),b(t,"group","control"),b(t,"description",'{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "'.concat(u,'" })}}')),b(t,"icon",n().createElement(r.RollbackOutlined,{style:{}})),b(t,"fieldset",{target:{type:"string",title:'{{t("Loop target", { ns: "'.concat(u,'" })}}'),description:'{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "'.concat(u,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,nullable:!1,useTypedConstant:["string",["number",{step:1,min:0,precision:0}]],className:(0,e.css)(k())},required:!0,default:1,"x-reactions":[{target:"calculation",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"expression",effects:["onFieldValueChange"],fulfill:{state:{value:""}}}]},condition:{type:"boolean","x-decorator":"FormItem","x-component":"LoopCondition","x-reactions":[{dependencies:["target"],fulfill:{state:{visible:"{{Boolean($deps[0])}}"}}}],default:!1},exit:{type:"number",title:'{{t("When node inside loop failed", { ns: "'.concat(u,'" })}}'),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Exit workflow", { ns: "'.concat(u,'" })}}'),value:0},{label:'{{t("Exit loop and continue workflow", { ns: "'.concat(u,'" })}}'),value:1},{label:'{{t("Continue loop on next item", { ns: "'.concat(u,'" })}}'),value:2}]},default:0}}),b(t,"branching",!0),b(t,"scope",{renderEngineReference:l.renderEngineReference}),b(t,"components",{LoopCondition:j,WorkflowVariableInput:l.WorkflowVariableInput,WorkflowVariableTextArea:l.WorkflowVariableTextArea,LoopVariableTextArea:P,RadioWithTooltip:l.RadioWithTooltip,CalculationConfig:l.CalculationConfig}),b(t,"useScopeVariables",E),t}return i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),t&&h(i,t),o=[{key:"Component",value:function(t){var o,i=t.data,a=(0,l.useFlowContext)().nodes,c=(0,l.useStyles)().styles,u=a.find(function(e){return e.upstreamId===i.id&&null!=e.branchIndex});return n().createElement(l.NodeDefaultView,{data:i},n().createElement("div",{className:c.nodeSubtreeClass},n().createElement("div",{className:(0,e.cx)(c.branchBlockClass,(0,e.css)(x()))},n().createElement(l.Branch,{from:i,entry:u,branchIndex:null!=(o=null==u?void 0:u.branchIndex)?o:0}),n().createElement("div",{className:c.branchClass,style:{minWidth:"4em"}},n().createElement("div",{className:"workflow-branch-lines"}),n().createElement("div",{className:c.loopLineClass},n().createElement(r.ArrowUpOutlined,null))))))}}],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)}}(i.prototype,o),i}(l.Instruction);function T(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function q(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){T(i,r,o,a,l,"next",e)}function l(e){T(i,r,o,a,l,"throw",e)}a(void 0)})}}function _(e,t,n){return(_=A()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&I(o,n.prototype),o}).apply(null,arguments)}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function W(e){var t="function"==typeof Map?new Map:void 0;return(W=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 _(e,arguments,F(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),I(n,e)})(e)}function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(A=function(){return!!e})()}function R(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var c=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var L=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=F(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,A()?Reflect.construct(e,t||[],F(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&I(n,e),t=[{key:"afterAdd",value:function(){return q(function(){return R(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return q(function(){return R(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return q(function(){return R(this,function(t){return e.app.pm.get("workflow").registerInstruction("loop",S),[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}(W(e.Plugin))}(),f}()});
@@ -10,12 +10,12 @@
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
12
  "@ant-design/icons": "5.6.1",
13
- "antd": "5.12.8",
14
- "@formily/antd-v5": "1.1.9",
13
+ "antd": "5.24.2",
14
+ "@formily/antd-v5": "1.2.3",
15
15
  "@formily/react": "2.3.0",
16
- "@nocobase/client": "1.7.0-beta.3",
17
- "@nocobase/plugin-workflow": "1.7.0-beta.3",
16
+ "@nocobase/client": "1.7.0-beta.31",
17
+ "@nocobase/plugin-workflow": "1.7.0-beta.31",
18
18
  "react-i18next": "11.18.6",
19
- "@nocobase/evaluators": "1.7.0-beta.3",
20
- "@nocobase/server": "1.7.0-beta.3"
19
+ "@nocobase/evaluators": "1.7.0-beta.31",
20
+ "@nocobase/server": "1.7.0-beta.31"
21
21
  };
@@ -1,9 +1,22 @@
1
1
  {
2
2
  "Loop": "Ciclo",
3
3
  "Loop target": "Destinazione ciclo",
4
- "Loop index": "Indice ciclo",
4
+ "Loop index (starts from 0)": "Indice del ciclo (inizia da 0)",
5
+ "Loop sequence (starts from 1)": "Sequenza del ciclo (inizia da 1)",
5
6
  "Loop length": "Lunghezza ciclo",
6
- "By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.": "Utilizzando un nodo ciclo, puoi eseguire la stessa operazione su più insiemi di dati. L' origine di questi insiemi può essere costituita da record multipli di un nodo query o da record multipli associati di singolo record. Il nodo ciclo può essere utilizzato anche per iterare un certo numero di volte o per scorrere ogni carattere in una stringa. Tuttavia, un numero eccessivamente elevato di cicli può causare problemi di prestazioni, quindi usalo con cautela.",
7
- "Scope variables": "Variabili ambito",
8
- "A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.": "Un singolo numero verrà trattato come conteggio del ciclo, una singola stringa verrà trattata come un array di caratteri e altri valori non-array verranno convertiti in array. Il nodo ciclo termina quando viene raggiunto il conteggio del ciclo o quando il ciclo dell'array è completato. Puoi anche aggiungere nodi condizione al ciclo per terminarlo."
7
+ "By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.": "Utilizzando un nodo ciclo, puoi eseguire la stessa operazione su più insiemi di dati. L' origine di questi insiemi può essere costituita da record multipli di un nodo query o da record multipli associati di singolo record. Il nodo ciclo può essere utilizzato anche per iterare un certo numero di volte o per scorrere ogni carattere in una stringa. Tuttavia, un numero eccessivamente elevato di cicli può causare problemi di prestazioni, quindi usalo con cautela.",
8
+ "A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.": "Un singolo numero verrà trattato come conteggio del ciclo, una singola stringa verrà trattata come un array di caratteri e altri valori non-array verranno convertiti in array. Il nodo ciclo termina quando viene raggiunto il conteggio del ciclo o quando il ciclo dell'array è completato. Puoi anche aggiungere nodi condizione al ciclo per terminarlo.",
9
+ "Enable loop condition": "Abilita condizione del ciclo",
10
+ "Loop condition on each item": "Condizione del ciclo su ciascun elemento",
11
+ "When to check": "Quando controllare",
12
+ "Before each starts": "Prima dell'inizio di ogni ciclo",
13
+ "After each ends": "Dopo la fine di ogni ciclo",
14
+ "When condition is not met on item": "Quando la condizione non è soddisfatta sull'elemento",
15
+ "Exit loop": "Esci dal ciclo",
16
+ "Continue on next item": "Continua con l'elemento successivo",
17
+ "Condition": "Condizione",
18
+ "When node inside loop failed": "Quando il nodo all'interno del ciclo fallisce",
19
+ "Continue loop on next item": "Continua il ciclo con l'elemento successivo",
20
+ "Exit loop and continue workflow": "Esci dal ciclo e continua il workflow",
21
+ "Exit workflow": "Esci dal workflow"
9
22
  }
@@ -1,9 +1,9 @@
1
1
  {
2
- "Loop": "Loop",
3
- "Loop target": "Loop target",
2
+ "Loop": "Lus",
3
+ "Loop target": "Lus doel",
4
4
  "Loop index": "Loop index",
5
- "Loop length": "Loop length",
6
- "By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.": "By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.",
7
- "Scope variables": "Scope variables",
8
- "A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.": "A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it."
9
- }
5
+ "Loop length": "Lus lengte",
6
+ "By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.": "Door een lus node te gebruiken, kun je dezelfde bewerking uitvoeren op meerdere gegevenssets. De bron van deze sets kan bestaan uit meerdere records van een querynode of meerdere gekoppelde records van een enkel record. De lus node kan ook worden gebruikt om een bepaald aantal keren te itereren of door elk teken in een string te lopen. Te veel lussen kunnen echter prestatieproblemen veroorzaken, dus gebruik het met voorzichtigheid.",
7
+ "Scope variables": "Scopevariabelen",
8
+ "A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.": "Een enkel getal wordt behandeld als een lusaantal, een enkele string wordt behandeld als een array van tekens, en andere niet-arraywaarden worden omgezet naar arrays. De lus node eindigt wanneer het lusaantal is bereikt, of wanneer de arraylus is voltooid. Je kunt ook voorwaardelijke nodes aan de lus toevoegen om deze te beëindigen."
9
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:循环节点",
5
5
  "description": "Used to repeat the sub-process processing of each value in an array, and can also be used for fixed times of sub-process processing.",
6
6
  "description.zh-CN": "用于对一个数组中的每个值进行重复的子流程处理,也可用于固定次数的重复子流程处理。",
7
- "version": "1.7.0-beta.3",
7
+ "version": "1.7.0-beta.31",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-loop",
@@ -22,7 +22,7 @@
22
22
  "@nocobase/server": "1.x",
23
23
  "@nocobase/test": "1.x"
24
24
  },
25
- "gitHead": "8d52cb1d366a968f87c1cd3f98f55f24be3056a5",
25
+ "gitHead": "84bf8bcfeeaf3a05086e24cef00507ca209ac3c5",
26
26
  "keywords": [
27
27
  "Workflow"
28
28
  ]