@nocobase/plugin-field-formula 2.1.10 → 2.1.11
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-v2/index.js
CHANGED
|
@@ -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("lodash"),require("@nocobase/client-v2"),require("@formily/reactive"),require("@nocobase/evaluators/client"),require("antd"),require("react"),require("@formily/react"),require("@nocobase/flow-engine"),require("@ant-design/icons"),require("@nocobase/utils/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-formula/client-v2",["lodash","@nocobase/client-v2","@formily/reactive","@nocobase/evaluators/client","antd","react","@formily/react","@nocobase/flow-engine","@ant-design/icons","@nocobase/utils/client"],t):"object"==typeof exports?exports["@nocobase/plugin-field-formula/client-v2"]=t(require("lodash"),require("@nocobase/client-v2"),require("@formily/reactive"),require("@nocobase/evaluators/client"),require("antd"),require("react"),require("@formily/react"),require("@nocobase/flow-engine"),require("@ant-design/icons"),require("@nocobase/utils/client")):e["@nocobase/plugin-field-formula/client-v2"]=t(e.lodash,e["@nocobase/client-v2"],e["@formily/reactive"],e["@nocobase/evaluators/client"],e.antd,e.react,e["@formily/react"],e["@nocobase/flow-engine"],e["@ant-design/icons"],e["@nocobase/utils/client"])}(self,function(e,t,n,r,o,i,l,a,u,c){return function(){"use strict";var s,f,p,d={143:function(e,t,n){n.d(t,{M:function(){return l},k:function(){return i}});var r=n(694),o=JSON.parse('{"UU":"@nocobase/plugin-field-formula"}');function i(){var e=(0,r.useFlowEngine)();return function(t){return e.context.t(t,{ns:[o.UU,"client"]})}}function l(e){return(0,r.tExpr)(e,{ns:[o.UU,"client"]})}},375:function(e){e.exports=u},230:function(e){e.exports=l},992:function(e){e.exports=n},485:function(e){e.exports=t},275:function(e){e.exports=r},694:function(e){e.exports=a},768:function(e){e.exports=c},59:function(e){e.exports=o},773:function(t){t.exports=e},155:function(e){e.exports=i}},v={};function b(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return d[e](n,n.exports,b),n.exports}b.m=d,b.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return b.d(t,{a:t}),t},b.d=function(e,t){for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.f={},b.e=function(e){return Promise.all(Object.keys(b.f).reduce(function(t,n){return b.f[n](e,t),t},[]))},b.u=function(e){return""+e+".4435ceef7bdbf216.js"},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m={},b.l=function(e,t,n,r){if(m[e])return void m[e].push(t);if(void 0!==n)for(var o,i,l=document.getElementsByTagName("script"),a=0;a<l.length;a++){var u=l[a];if(u.getAttribute("src")==e||u.getAttribute("data-rspack")=="@nocobase/plugin-field-formula/client-v2:"+n){o=u;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,b.nc&&o.setAttribute("nonce",b.nc),o.setAttribute("data-rspack","@nocobase/plugin-field-formula/client-v2:"+n),o.src=e),m[e]=[t];var c=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=m[e];if(delete m[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(c.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=c.bind(null,o.onerror),o.onload=c.bind(null,o.onload),i&&document.head.appendChild(o)},b.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.g.importScripts&&(h=b.g.location+"");var m,h,y=b.g.document;if(!h&&y&&(y.currentScript&&"SCRIPT"===y.currentScript.tagName.toUpperCase()&&(h=y.currentScript.src),!h)){var g=y.getElementsByTagName("script");if(g.length)for(var x=g.length-1;x>-1&&(!h||!/^http(s?):/.test(h));)h=g[x--].src}if(!h)throw Error("Automatic publicPath is not supported in this browser");b.p=h.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s={889:0},b.f.j=function(e,t){var n=b.o(s,e)?s[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=s[e]=[t,r]});t.push(n[2]=r);var o=b.p+b.u(e),i=Error();b.l(o,function(t){if(b.o(s,e)&&(0!==(n=s[e])&&(s[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},f=function(e,t){var n,r,o=t[0],i=t[1],l=t[2],a=0;if(o.some(function(e){return 0!==s[e]})){for(n in i)b.o(i,n)&&(b.m[n]=i[n]);l&&l(b)}for(e&&e(t);a<o.length;a++)r=o[a],b.o(s,r)&&s[r]&&s[r][0](),s[r]=0},(p=self.webpackChunk_nocobase_plugin_field_formula_client_v2=self.webpackChunk_nocobase_plugin_field_formula_client_v2||[]).forEach(f.bind(null,0)),p.push=f.bind(null,p.push.bind(p));var w={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-field-formula/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-field-formula/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var l=window.location.pathname||"/",a=l.indexOf(i);e=a>=0?l.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-field-formula/dist/client-v2/"}b.p=e}(),!function(){b.r(w),b.d(w,{default:function(){return N}});var e=b(485),t=b(275),n=b(694),r=b(59),o=b(155),i=b.n(o),l=b(143);function a(e,t,n,r,o,i,l){try{var a=e[i](l),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}var u=["checkbox","number","percent","integer","input","textarea","email","phone","date","datetime","datetimeNoTz","unixTimestamp","createdAt","updatedAt","radioGroup","checkboxGroup","select","multipleSelect"];function c(e){var t,r,l,c,s,f,p=(0,n.useFlowContext)(),d=p.dataSourceManager.collectionFieldInterfaceManager,v=(null==(t=p.fieldFormula)?void 0:t.expressionFields)||(null==(c=p.flowEngine)||null==(l=c.context)||null==(r=l.fieldFormula)?void 0:r.expressionFields)||u,b=(0,o.useMemo)(function(){return{formatPathToValue:function(e){var t;return(null==e||null==(t=e.paths)?void 0:t.length)?"{{".concat(e.paths.join("."),"}}"):void 0},parseValueToPath:function(e){var t=null==e?void 0:e.trim().match(/^\{\{\s*(.+?)\s*\}\}$/);return(null==t?void 0:t[1])?t[1].split("."):void 0}}},[]),m=(0,o.useMemo)(function(){var t;return new Set(((null==(t=e.collection)?void 0:t.fields)||[]).map(function(e){return null==e?void 0:e.foreignKey}).filter(function(e){return"string"==typeof e&&!!e}))},[null==(s=e.collection)?void 0:s.fields]),h=(0,o.useCallback)(function(){var t;return(t=function(){var t;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:u(0)}),a(l,"throw",{value:u(1)}),a(l,"return",{value:u(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function u(a){return function(u){var c=[a,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(n){return[2,((null==(t=e.collection)?void 0:t.fields)||[]).filter(function(t){return!(!(null==t?void 0:t.name)||t.name===e.currentFieldName||m.has(t.name))&&(null==t?void 0:t.interface)&&v.includes(t.interface)}).map(function(e){var t,n,r,o,i,l,a,u,c=null==d||null==(a=d.getFieldInterface)?void 0:a.call(d,e.interface),s=null==c?void 0:c.usePathOptions,f="function"==typeof s?s(e):void 0,p=String(null!=(t=null!=(n=null!=(r=null==e||null==(u=e.uiSchema)?void 0:u.title)?r:null==e?void 0:e.title)?n:null==e?void 0:e.name)?t:""),v=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return Array.isArray(t)?t.map(function(t){var o,i,l,a,u=null!=(o=null!=(i=null==t?void 0:t.value)?i:null==t?void 0:t.name)?o:null==t?void 0:t.key;if(null==u)return null;var c=String(null!=(l=null!=(a=t.label)?a:t.title)?l:u),s=r.concat(String(u)),f={name:String(u),title:c,type:t.type||"field",interface:t.interface,options:t.options,uiSchema:t.uiSchema,paths:s,parentTitles:n};return Array.isArray(t.children)&&(f.children=e(t.children,n.concat(c),s)),f}).filter(Boolean):[]}(f,[p],[String(null!=(o=null==e?void 0:e.name)?o:"")]);return{name:String(null!=(i=null==e?void 0:e.name)?i:""),title:p,type:"field",interface:null==e?void 0:e.interface,uiSchema:null==e?void 0:e.uiSchema,paths:[String(null!=(l=null==e?void 0:e.name)?l:"")],parentTitles:[],children:v.length?v:void 0}})]})},function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function l(e){a(i,r,o,l,u,"next",e)}function u(e){a(i,r,o,l,u,"throw",e)}l(void 0)})})()},[v,m,d,null==(f=e.collection)?void 0:f.fields,e.currentFieldName]);return i().createElement(n.VariableHybridInput,{value:e.value||"",onChange:function(t){var n;return null==(n=e.onChange)?void 0:n.call(e,t)},metaTree:h,converters:b,placeholder:p.t("Input text, use {{ to insert variables")})}function s(e){var n=(0,l.k)(),r=e.engine?t.evaluators.get(e.engine):void 0;return(null==r?void 0:r.link)?i().createElement("span",null,n("Syntax references"),":\xa0",i().createElement("a",{href:n(r.link),target:"_blank",rel:"noreferrer"},r.label)):null}function f(e){var t,n=r.Form.useWatch("engine",e.form),l=r.Form.useWatch("name",e.form),a=(0,o.useMemo)(function(){return i().createElement(s,{engine:n||"formula.js"})},[n]);return i().createElement(r.Form.Item,{name:e.namePath,label:e.title,extra:a,rules:(null==(t=e.schema)?void 0:t.required)?[{required:!0}]:void 0},i().createElement(c,{collection:e.collection,currentFieldName:l}))}function p(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 d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e,t){if(e){if("string"==typeof e)return p(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 p(e,t)}}function y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(y=function(){return!!e})()}var g=function(e){var t,n;return(null==e||null==(t=e.options)?void 0:t.dataType)||(null==e?void 0:e.dataType)||(null==e?void 0:e.type)||(null==e||null==(n=e.uiSchema)?void 0:n.type)||"double"},x=(0,e.resolveFilterOperators)("datetime").filter(function(e){return!["$dateNotBefore","$dateNotAfter"].includes(e.value)}),S=function(n){if("function"!=typeof n&&null!==n)throw TypeError("Super expression must either be null or a function");function r(){var n,o,i,a;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return o=r,i=arguments,o=v(o),d(n=function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,y()?Reflect.construct(o,i||[],v(this).constructor):o.apply(this,i)),"name","formula"),d(n,"type","object"),d(n,"group","advanced"),d(n,"order",1),d(n,"title",(0,l.M)("Formula")),d(n,"description",(0,l.M)("Configure and store the results of calculations between multiple field values in the same record, supporting both Math.js and Excel formula functions.")),d(n,"sortable",!0),d(n,"default",{interface:"formula",type:"formula",uiSchema:{type:"string","x-component":"Input","x-read-pretty":!0,"x-component-props":{stringMode:!0,step:"1"}}}),d(n,"configure",{items:[{name:"dataType",title:'{{t("Storage type")}}',component:"Select",disabled:function(e){return!e.context.createOnly},options:[{value:"boolean",label:"Boolean"},{value:"integer",label:"Integer"},{value:"bigInt",label:"Big integer"},{value:"double",label:"Double"},{value:"string",label:"String"},{value:"date",label:"Datetime"}],required:!0,defaultValue:"double"},{name:"uiSchema.x-component-props.step",title:'{{t("Precision")}}',component:"Select",required:!0,defaultValue:"0",options:[{value:"0",label:"1"},{value:"0.1",label:"1.0"},{value:"0.01",label:"1.00"},{value:"0.001",label:"1.000"},{value:"0.0001",label:"1.0000"},{value:"0.00001",label:"1.00000"}],hidden:function(e){return!["double","decimal"].includes(String((0,e.getValue)("dataType")))}}].concat(function(e){if(Array.isArray(e))return p(e)}(a=(0,e.dateTimeFormatConfigureItems)({includePicker:!1,showTimeDefault:!0,hidden:function(e){return"date"!==(0,e.getValue)("dataType")}}))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||h(a)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[{name:"engine",title:(0,l.M)("Calculation engine"),component:"Radio.Group",options:Array.from(t.evaluators.getEntities()).reduce(function(e,t){var n=function(e){if(Array.isArray(e))return e}(t)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw n}}return o}}(t)||h(t,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.")}(),r=n[0],o=n[1];return e.concat({value:String(r),label:o.label})},[]),required:!0,defaultValue:"formula.js"},{name:"expression",title:(0,l.M)("Expression"),required:!0,Component:f,componentProps:{useCurrentFields:"{{ useCurrentFields }}"},description:(0,l.M)("Syntax references")}])}),d(n,"filterable",(0,e.createTypedFilterable)([{types:["boolean"],operators:"boolean"},{types:["string"],operators:"string"},{types:["date"],operators:"formulaDate"},{types:["integer","double","bigInt","number"],operators:"number"}],g)),d(n,"titleUsable",!0),n}return r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),n&&m(r,n),r}(e.CollectionFieldInterface),_=b(230);function O(e,t,n,r,o,i,l){try{var a=e[i](l),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function F(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){O(i,r,o,l,a,"next",e)}function a(e){O(i,r,o,l,a,"throw",e)}l(void 0)})}}function j(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:u(0)}),a(l,"throw",{value:u(1)}),a(l,"return",{value:u(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function u(a){return function(u){var c=[a,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var E=function(e,t,n){var r,o,i,l,a,u=String(null!=(r=null!=(o=null==e||null==(a=e.uiSchema)?void 0:a.title)?o:null==e?void 0:e.name)?r:"");return{name:String(null!=(i=null==e?void 0:e.name)?i:""),title:u,type:"field",interface:null==e?void 0:e.interface,uiSchema:null==e?void 0:e.uiSchema,paths:[String(null!=(l=null==e?void 0:e.name)?l:"")],parentTitles:t,children:n}},k=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return Array.isArray(e)?e.map(function(e){if(!e)return null;var r,o,i,l,a=null!=(r=null!=(o=e.value)?o:e.name)?r:e.key;if(null==a)return null;var u=String(null!=(i=null!=(l=e.label)?l:e.title)?i:a),c=n.concat(String(a)),s={name:String(a),title:u,type:e.type||"field",interface:e.interface,options:e.options,uiSchema:e.uiSchema,paths:c,parentTitles:t};return Array.isArray(e.children)?s.children=k(e.children,t.concat(u),c):"function"==typeof e.children&&(s.children=function(){return F(function(){return j(this,function(n){switch(n.label){case 0:return[4,e.children()];case 1:return[2,k(n.sent(),t.concat(u),c)]}})})()}),s}).filter(Boolean):[]},T=function(e){var t,r,l,a,u=e.value,c=e.onChange,s=e.useCurrentFields,f=(0,_.useField)(),p=(0,n.useFlowEngine)(),d=(0,n.useFlowContext)().t,v=null==(r=p.context)?void 0:r.fieldFormula,b=(null==v?void 0:v.expressionFields)||[],m=(0,o.useMemo)(function(){try{var e,t=null!=(e=null==s?void 0:s())?e:[];return Array.isArray(t)?t:[]}catch(e){return[]}},[s]),h=(0,o.useMemo)(function(){return function(){return F(function(){var e,t,n,r,o,i,l,a,u,c,s,f,d,v,h,y,g,x,w;return j(this,function(S){n=null==(t=p.context)||null==(e=t.dataSourceManager)?void 0:e.collectionFieldInterfaceManager,r=[],o=!0,i=!1,l=void 0;try{for(a=m[Symbol.iterator]();!(o=(u=a.next()).done);o=!0)(null==(c=u.value)?void 0:c.interface)&&b.includes(c.interface)&&(g=null==(y=null==n||null==(v=n.getFieldInterface)?void 0:v.call(n,c.interface))?void 0:y.usePathOptions,x="function"==typeof g?g(c):void 0,w=k(x,[String(null!=(s=null!=(f=null==c||null==(h=c.uiSchema)?void 0:h.title)?f:null==c?void 0:c.name)?s:"")],[String(null!=(d=null==c?void 0:c.name)?d:"")]),r.push(E(c,[],w.length?w:void 0)))}catch(e){i=!0,l=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw l}}return[2,r]})})()}},[m,b,null==(a=p.context)||null==(l=a.dataSourceManager)?void 0:l.collectionFieldInterfaceManager]),y=String(null!=(t=null==e?void 0:e.placeholder)?t:d("Input text, use {{ to insert variables"));return i().createElement(n.SlateVariableEditor,{value:void 0===u?"":u,onChange:function(e){null==c||c(e),f&&"function"==typeof f.setValue&&f.setValue(e)},metaTree:h,placeholder:y,multiline:!0})};function P(e,t,n,r,o,i,l){try{var a=e[i](l),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function A(e,t,n){return(A=C()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&q(o,n.prototype),o}).apply(null,arguments)}function I(e){return(I=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function M(e){var t="function"==typeof Map?new Map:void 0;return(M=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,I(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),q(n,e)})(e)}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(C=function(){return!!e})()}var N=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,r,o,i;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=I(t),e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,C()?Reflect.construct(t,r||[],I(this).constructor):t.apply(this,r)),i=["checkbox","number","percent","integer","number","percent","input","textarea","email","phone","date","datetime","datetimeNoTz","unixTimestamp","createdAt","updatedAt","radioGroup","checkboxGroup","select","multipleSelect"],(o="expressionFields")in e?Object.defineProperty(e,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[o]=i,e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&q(n,e),t=[{key:"registerExpressionFieldInterface",value:function(e){if(Array.isArray(e)){var t=this.expressionFields.concat(e);this.expressionFields=t}else this.expressionFields.push(e)}},{key:"load",value:function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:u(0)}),a(l,"throw",{value:u(1)}),a(l,"return",{value:u(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function u(a){return function(u){var c=[a,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(t){return e=this,this.app.addComponents({FormulaExpression:T}),this.app.registerFieldFilterOperatorGroup("formulaDate",x),this.app.addFieldInterfaces([S]),this.flowEngine.context.defineProperty("fieldFormula",{get:function(){return{expressionFields:e.expressionFields,registerExpressionFieldInterface:e.registerExpressionFieldInterface.bind(e)}}}),this.flowEngine.registerModelLoaders({FormulaFieldModel:{loader:function(){return b.e("408").then(b.bind(b,379))}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){P(i,r,o,l,a,"next",e)}function a(e){P(i,r,o,l,a,"throw",e)}l(void 0)})}).call(this)}}],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}(M(e.Plugin))}(),w}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("lodash"),require("@nocobase/client-v2"),require("@formily/reactive"),require("@nocobase/evaluators/client"),require("antd"),require("react"),require("@formily/react"),require("@nocobase/flow-engine"),require("@nocobase/utils/client"),require("@ant-design/icons")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-formula/client-v2",["lodash","@nocobase/client-v2","@formily/reactive","@nocobase/evaluators/client","antd","react","@formily/react","@nocobase/flow-engine","@nocobase/utils/client","@ant-design/icons"],t):"object"==typeof exports?exports["@nocobase/plugin-field-formula/client-v2"]=t(require("lodash"),require("@nocobase/client-v2"),require("@formily/reactive"),require("@nocobase/evaluators/client"),require("antd"),require("react"),require("@formily/react"),require("@nocobase/flow-engine"),require("@nocobase/utils/client"),require("@ant-design/icons")):e["@nocobase/plugin-field-formula/client-v2"]=t(e.lodash,e["@nocobase/client-v2"],e["@formily/reactive"],e["@nocobase/evaluators/client"],e.antd,e.react,e["@formily/react"],e["@nocobase/flow-engine"],e["@nocobase/utils/client"],e["@ant-design/icons"])}(self,function(e,t,n,r,o,i,l,a,u,c){return function(){"use strict";var s,f,p,d={143:function(e,t,n){n.d(t,{M:function(){return l},k:function(){return i}});var r=n(694),o=JSON.parse('{"UU":"@nocobase/plugin-field-formula"}');function i(){var e=(0,r.useFlowEngine)();return function(t){return e.context.t(t,{ns:[o.UU,"client"]})}}function l(e){return(0,r.tExpr)(e,{ns:[o.UU,"client"]})}},375:function(e){e.exports=c},230:function(e){e.exports=l},992:function(e){e.exports=n},485:function(e){e.exports=t},275:function(e){e.exports=r},694:function(e){e.exports=a},768:function(e){e.exports=u},59:function(e){e.exports=o},773:function(t){t.exports=e},155:function(e){e.exports=i}},v={};function b(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return d[e](n,n.exports,b),n.exports}b.m=d,b.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return b.d(t,{a:t}),t},b.d=function(e,t){for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.f={},b.e=function(e){return Promise.all(Object.keys(b.f).reduce(function(t,n){return b.f[n](e,t),t},[]))},b.u=function(e){return""+e+".4435ceef7bdbf216.js"},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m={},b.l=function(e,t,n,r){if(m[e])return void m[e].push(t);if(void 0!==n)for(var o,i,l=document.getElementsByTagName("script"),a=0;a<l.length;a++){var u=l[a];if(u.getAttribute("src")==e||u.getAttribute("data-rspack")=="@nocobase/plugin-field-formula/client-v2:"+n){o=u;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,b.nc&&o.setAttribute("nonce",b.nc),o.setAttribute("data-rspack","@nocobase/plugin-field-formula/client-v2:"+n),o.src=e),m[e]=[t];var c=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=m[e];if(delete m[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(c.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=c.bind(null,o.onerror),o.onload=c.bind(null,o.onload),i&&document.head.appendChild(o)},b.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.g.importScripts&&(h=b.g.location+"");var m,h,y=b.g.document;if(!h&&y&&(y.currentScript&&"SCRIPT"===y.currentScript.tagName.toUpperCase()&&(h=y.currentScript.src),!h)){var g=y.getElementsByTagName("script");if(g.length)for(var x=g.length-1;x>-1&&(!h||!/^http(s?):/.test(h));)h=g[x--].src}if(!h)throw Error("Automatic publicPath is not supported in this browser");b.p=h.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s={889:0},b.f.j=function(e,t){var n=b.o(s,e)?s[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=s[e]=[t,r]});t.push(n[2]=r);var o=b.p+b.u(e),i=Error();b.l(o,function(t){if(b.o(s,e)&&(0!==(n=s[e])&&(s[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},f=function(e,t){var n,r,o=t[0],i=t[1],l=t[2],a=0;if(o.some(function(e){return 0!==s[e]})){for(n in i)b.o(i,n)&&(b.m[n]=i[n]);l&&l(b)}for(e&&e(t);a<o.length;a++)r=o[a],b.o(s,r)&&s[r]&&s[r][0](),s[r]=0},(p=self.webpackChunk_nocobase_plugin_field_formula_client_v2=self.webpackChunk_nocobase_plugin_field_formula_client_v2||[]).forEach(f.bind(null,0)),p.push=f.bind(null,p.push.bind(p));var w={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-field-formula/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-field-formula/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var l=window.location.pathname||"/",a=l.indexOf(i);e=a>=0?l.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-field-formula/dist/client-v2/"}b.p=e}(),!function(){b.r(w),b.d(w,{default:function(){return N}});var e=b(485),t=b(275),n=b(694),r=b(59),o=b(155),i=b.n(o),l=b(143);function a(e,t,n,r,o,i,l){try{var a=e[i](l),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}var u=["checkbox","number","percent","integer","input","textarea","email","phone","date","datetime","datetimeNoTz","unixTimestamp","createdAt","updatedAt","radioGroup","checkboxGroup","select","multipleSelect"];function c(e){var t,r,l,c,s,f,p=(0,n.useFlowContext)(),d=p.dataSourceManager.collectionFieldInterfaceManager,v=(null==(t=p.fieldFormula)?void 0:t.expressionFields)||(null==(c=p.flowEngine)||null==(l=c.context)||null==(r=l.fieldFormula)?void 0:r.expressionFields)||u,b=(0,o.useMemo)(function(){return{formatPathToValue:function(e){var t;return(null==e||null==(t=e.paths)?void 0:t.length)?"{{".concat(e.paths.join("."),"}}"):void 0},parseValueToPath:function(e){var t=null==e?void 0:e.trim().match(/^\{\{\s*(.+?)\s*\}\}$/);return(null==t?void 0:t[1])?t[1].split("."):void 0}}},[]),m=(0,o.useMemo)(function(){var t;return new Set(((null==(t=e.collection)?void 0:t.fields)||[]).map(function(e){return null==e?void 0:e.foreignKey}).filter(function(e){return"string"==typeof e&&!!e}))},[null==(s=e.collection)?void 0:s.fields]),h=(0,o.useCallback)(function(){var t;return(t=function(){var t;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:u(0)}),a(l,"throw",{value:u(1)}),a(l,"return",{value:u(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function u(a){return function(u){var c=[a,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(n){return[2,((null==(t=e.collection)?void 0:t.fields)||[]).filter(function(t){return!(!(null==t?void 0:t.name)||t.name===e.currentFieldName||m.has(t.name))&&(null==t?void 0:t.interface)&&v.includes(t.interface)}).map(function(e){var t,n,r,o,i,l,a,u,c=null==d||null==(a=d.getFieldInterface)?void 0:a.call(d,e.interface),s=null==c?void 0:c.usePathOptions,f="function"==typeof s?s(e):void 0,p=String(null!=(t=null!=(n=null!=(r=null==e||null==(u=e.uiSchema)?void 0:u.title)?r:null==e?void 0:e.title)?n:null==e?void 0:e.name)?t:""),v=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return Array.isArray(t)?t.map(function(t){var o,i,l,a,u=null!=(o=null!=(i=null==t?void 0:t.value)?i:null==t?void 0:t.name)?o:null==t?void 0:t.key;if(null==u)return null;var c=String(null!=(l=null!=(a=t.label)?a:t.title)?l:u),s=r.concat(String(u)),f={name:String(u),title:c,type:t.type||"field",interface:t.interface,options:t.options,uiSchema:t.uiSchema,paths:s,parentTitles:n};return Array.isArray(t.children)&&(f.children=e(t.children,n.concat(c),s)),f}).filter(Boolean):[]}(f,[p],[String(null!=(o=null==e?void 0:e.name)?o:"")]);return{name:String(null!=(i=null==e?void 0:e.name)?i:""),title:p,type:"field",interface:null==e?void 0:e.interface,uiSchema:null==e?void 0:e.uiSchema,paths:[String(null!=(l=null==e?void 0:e.name)?l:"")],parentTitles:[],children:v.length?v:void 0}})]})},function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function l(e){a(i,r,o,l,u,"next",e)}function u(e){a(i,r,o,l,u,"throw",e)}l(void 0)})})()},[v,m,d,null==(f=e.collection)?void 0:f.fields,e.currentFieldName]);return i().createElement(n.VariableHybridInput,{value:e.value||"",onChange:function(t){var n;return null==(n=e.onChange)?void 0:n.call(e,t)},metaTree:h,converters:b,placeholder:p.t("Input text, use {{ to insert variables")})}function s(e){var n=(0,l.k)(),r=e.engine?t.evaluators.get(e.engine):void 0;return(null==r?void 0:r.link)?i().createElement("span",null,n("Syntax references"),":\xa0",i().createElement("a",{href:n(r.link),target:"_blank",rel:"noreferrer"},r.label)):null}function f(e){var t,n=r.Form.useWatch("engine",e.form),l=r.Form.useWatch("name",e.form),a=(0,o.useMemo)(function(){return i().createElement(s,{engine:n||"formula.js"})},[n]);return i().createElement(r.Form.Item,{name:e.namePath,label:e.title,extra:a,rules:(null==(t=e.schema)?void 0:t.required)?[{required:!0}]:void 0},i().createElement(c,{collection:e.collection,currentFieldName:l}))}function p(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 d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e,t){if(e){if("string"==typeof e)return p(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 p(e,t)}}function y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(y=function(){return!!e})()}var g=function(e){var t,n;return(null==e||null==(t=e.options)?void 0:t.dataType)||(null==e?void 0:e.dataType)||(null==e?void 0:e.type)||(null==e||null==(n=e.uiSchema)?void 0:n.type)||"double"},x=(0,e.resolveFilterOperators)("datetime").filter(function(e){return!["$dateNotBefore","$dateNotAfter"].includes(e.value)}),S=function(n){if("function"!=typeof n&&null!==n)throw TypeError("Super expression must either be null or a function");function r(){var n,o,i,a;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return o=r,i=arguments,o=v(o),d(n=function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,y()?Reflect.construct(o,i||[],v(this).constructor):o.apply(this,i)),"name","formula"),d(n,"type","object"),d(n,"group","advanced"),d(n,"order",1),d(n,"title",(0,l.M)("Formula")),d(n,"description",(0,l.M)("Configure and store the results of calculations between multiple field values in the same record, supporting both Math.js and Excel formula functions.")),d(n,"sortable",!0),d(n,"default",{interface:"formula",type:"formula",uiSchema:{type:"string","x-component":"Input","x-read-pretty":!0,"x-component-props":{stringMode:!0,step:"1"}}}),d(n,"configure",{items:[{name:"dataType",title:'{{t("Storage type")}}',component:"Select",disabled:function(e){return!e.context.createOnly},options:[{value:"boolean",label:"Boolean"},{value:"integer",label:"Integer"},{value:"bigInt",label:"Big integer"},{value:"double",label:"Double"},{value:"string",label:"String"},{value:"date",label:"Datetime"}],required:!0,defaultValue:"double"},{name:"uiSchema.x-component-props.step",title:'{{t("Precision")}}',component:"Select",required:!0,defaultValue:"0",options:[{value:"0",label:"1"},{value:"0.1",label:"1.0"},{value:"0.01",label:"1.00"},{value:"0.001",label:"1.000"},{value:"0.0001",label:"1.0000"},{value:"0.00001",label:"1.00000"}],hidden:function(e){return!["double","decimal"].includes(String((0,e.getValue)("dataType")))}}].concat(function(e){if(Array.isArray(e))return p(e)}(a=(0,e.dateTimeFormatConfigureItems)({includePicker:!1,showTimeDefault:!0,hidden:function(e){return"date"!==(0,e.getValue)("dataType")}}))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||h(a)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[{name:"engine",title:(0,l.M)("Calculation engine"),component:"Radio.Group",options:Array.from(t.evaluators.getEntities()).reduce(function(e,t){var n=function(e){if(Array.isArray(e))return e}(t)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw n}}return o}}(t)||h(t,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.")}(),r=n[0],o=n[1];return e.concat({value:String(r),label:o.label})},[]),required:!0,defaultValue:"formula.js"},{name:"expression",title:(0,l.M)("Expression"),required:!0,Component:f,componentProps:{useCurrentFields:"{{ useCurrentFields }}"},description:(0,l.M)("Syntax references")}])}),d(n,"filterable",(0,e.createTypedFilterable)([{types:["boolean"],operators:"boolean"},{types:["string"],operators:"string"},{types:["date"],operators:"formulaDate"},{types:["integer","double","bigInt","number"],operators:"number"}],g)),d(n,"titleUsable",!0),n}return r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),n&&m(r,n),r}(e.CollectionFieldInterface),_=b(230);function O(e,t,n,r,o,i,l){try{var a=e[i](l),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function F(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){O(i,r,o,l,a,"next",e)}function a(e){O(i,r,o,l,a,"throw",e)}l(void 0)})}}function j(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:u(0)}),a(l,"throw",{value:u(1)}),a(l,"return",{value:u(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function u(a){return function(u){var c=[a,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var E=function(e,t,n){var r,o,i,l,a,u=String(null!=(r=null!=(o=null==e||null==(a=e.uiSchema)?void 0:a.title)?o:null==e?void 0:e.name)?r:"");return{name:String(null!=(i=null==e?void 0:e.name)?i:""),title:u,type:"field",interface:null==e?void 0:e.interface,uiSchema:null==e?void 0:e.uiSchema,paths:[String(null!=(l=null==e?void 0:e.name)?l:"")],parentTitles:t,children:n}},k=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return Array.isArray(e)?e.map(function(e){if(!e)return null;var r,o,i,l,a=null!=(r=null!=(o=e.value)?o:e.name)?r:e.key;if(null==a)return null;var u=String(null!=(i=null!=(l=e.label)?l:e.title)?i:a),c=n.concat(String(a)),s={name:String(a),title:u,type:e.type||"field",interface:e.interface,options:e.options,uiSchema:e.uiSchema,paths:c,parentTitles:t};return Array.isArray(e.children)?s.children=k(e.children,t.concat(u),c):"function"==typeof e.children&&(s.children=function(){return F(function(){return j(this,function(n){switch(n.label){case 0:return[4,e.children()];case 1:return[2,k(n.sent(),t.concat(u),c)]}})})()}),s}).filter(Boolean):[]},T=function(e){var t,r,l,a,u=e.value,c=e.onChange,s=e.useCurrentFields,f=(0,_.useField)(),p=(0,n.useFlowEngine)(),d=(0,n.useFlowContext)().t,v=null==(r=p.context)?void 0:r.fieldFormula,b=(null==v?void 0:v.expressionFields)||[],m=(0,o.useMemo)(function(){try{var e,t=null!=(e=null==s?void 0:s())?e:[];return Array.isArray(t)?t:[]}catch(e){return[]}},[s]),h=(0,o.useMemo)(function(){return function(){return F(function(){var e,t,n,r,o,i,l,a,u,c,s,f,d,v,h,y,g,x,w;return j(this,function(S){n=null==(t=p.context)||null==(e=t.dataSourceManager)?void 0:e.collectionFieldInterfaceManager,r=[],o=!0,i=!1,l=void 0;try{for(a=m[Symbol.iterator]();!(o=(u=a.next()).done);o=!0)(null==(c=u.value)?void 0:c.interface)&&b.includes(c.interface)&&(g=null==(y=null==n||null==(v=n.getFieldInterface)?void 0:v.call(n,c.interface))?void 0:y.usePathOptions,x="function"==typeof g?g(c):void 0,w=k(x,[String(null!=(s=null!=(f=null==c||null==(h=c.uiSchema)?void 0:h.title)?f:null==c?void 0:c.name)?s:"")],[String(null!=(d=null==c?void 0:c.name)?d:"")]),r.push(E(c,[],w.length?w:void 0)))}catch(e){i=!0,l=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw l}}return[2,r]})})()}},[m,b,null==(a=p.context)||null==(l=a.dataSourceManager)?void 0:l.collectionFieldInterfaceManager]),y=String(null!=(t=null==e?void 0:e.placeholder)?t:d("Input text, use {{ to insert variables"));return i().createElement(n.SlateVariableEditor,{value:void 0===u?"":u,onChange:function(e){null==c||c(e),f&&"function"==typeof f.setValue&&f.setValue(e)},metaTree:h,placeholder:y,multiline:!0})};function P(e,t,n,r,o,i,l){try{var a=e[i](l),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function A(e,t,n){return(A=C()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&q(o,n.prototype),o}).apply(null,arguments)}function I(e){return(I=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function M(e){var t="function"==typeof Map?new Map:void 0;return(M=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,I(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),q(n,e)})(e)}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(C=function(){return!!e})()}var N=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,r,o,i;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=I(t),e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,C()?Reflect.construct(t,r||[],I(this).constructor):t.apply(this,r)),i=["checkbox","number","percent","integer","number","percent","input","textarea","email","phone","date","datetime","datetimeNoTz","unixTimestamp","createdAt","updatedAt","radioGroup","checkboxGroup","select","multipleSelect"],(o="expressionFields")in e?Object.defineProperty(e,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[o]=i,e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&q(n,e),t=[{key:"registerExpressionFieldInterface",value:function(e){if(Array.isArray(e)){var t=this.expressionFields.concat(e);this.expressionFields=t}else this.expressionFields.push(e)}},{key:"load",value:function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(l,"next",{value:u(0)}),a(l,"throw",{value:u(1)}),a(l,"return",{value:u(2)}),"function"==typeof Symbol&&a(l,Symbol.iterator,{value:function(){return this}}),l;function u(a){return function(u){var c=[a,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(t){return e=this,this.app.addComponents({FormulaExpression:T}),this.app.registerFieldFilterOperatorGroup("formulaDate",x),this.app.addFieldInterfaces([S]),this.flowEngine.context.defineProperty("fieldFormula",{get:function(){return{expressionFields:e.expressionFields,registerExpressionFieldInterface:e.registerExpressionFieldInterface.bind(e)}}}),this.flowEngine.registerModelLoaders({FormulaFieldModel:{loader:function(){return b.e("408").then(b.bind(b,379))}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){P(i,r,o,l,a,"next",e)}function a(e){P(i,r,o,l,a,"throw",e)}l(void 0)})}).call(this)}}],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}(M(e.Plugin))}(),w}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/react": "2.3.7",
|
|
12
|
-
"@nocobase/client": "2.1.
|
|
13
|
-
"@nocobase/evaluators": "2.1.
|
|
14
|
-
"@nocobase/utils": "2.1.
|
|
12
|
+
"@nocobase/client": "2.1.11",
|
|
13
|
+
"@nocobase/evaluators": "2.1.11",
|
|
14
|
+
"@nocobase/utils": "2.1.11",
|
|
15
15
|
"react": "18.2.0",
|
|
16
|
-
"@nocobase/flow-engine": "2.1.
|
|
17
|
-
"@nocobase/client-v2": "2.1.
|
|
18
|
-
"@nocobase/database": "2.1.
|
|
19
|
-
"@nocobase/server": "2.1.
|
|
20
|
-
"@nocobase/test": "2.1.
|
|
16
|
+
"@nocobase/flow-engine": "2.1.11",
|
|
17
|
+
"@nocobase/client-v2": "2.1.11",
|
|
18
|
+
"@nocobase/database": "2.1.11",
|
|
19
|
+
"@nocobase/server": "2.1.11",
|
|
20
|
+
"@nocobase/test": "2.1.11",
|
|
21
21
|
"react-i18next": "11.18.6",
|
|
22
22
|
"antd": "5.24.2",
|
|
23
23
|
"@formily/reactive": "2.3.7",
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Configure and store the results of calculations between multiple field values in the same record, supporting both Math.js and Excel formula functions.",
|
|
7
7
|
"description.zh-CN": "可以配置并存储同一条记录的多字段值之间的计算结果,支持 Math.js 和 Excel formula functions 两种引擎",
|
|
8
8
|
"description.ru-RU": "Настройка и сохранение результатов вычислений между значениями нескольких полей в одной записи с поддержкой движков Math.js и Excel formula functions.",
|
|
9
|
-
"version": "2.1.
|
|
9
|
+
"version": "2.1.11",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/field-formula",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@nocobase/test": "2.x",
|
|
30
30
|
"@nocobase/utils": "2.x"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "1ccf891d837e21089f65f84b892407b34a0a0cb9",
|
|
33
33
|
"keywords": [
|
|
34
34
|
"Collection fields"
|
|
35
35
|
]
|