@steedos-widgets/steedos-lib 1.2.42 → 1.3.0-beta.10
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/index.umd.js +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("antd"),require("react"),require("react-dom"),require("lodash"),require("@steedos-widgets/amis-lib")):"function"==typeof define&&define.amd?define(["exports","antd","react","react-dom","lodash","@steedos-widgets/amis-lib"],t):t((e=e||self)["steedos-lib"]={},e.antd,e.React,e.ReactDOM,e._,e.amisLib)}(this,function(exports,antd,React,ReactDOM,_$1,amisLib){const global=window;var React__default="default"in React?React.default:React,ReactDOM__default="default"in ReactDOM?ReactDOM.default:ReactDOM,__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},StandardObjects={Base:{Actions:{standard_query:{visible:function(e,t,n){return!1}},standard_new:{visible:function(e,t,n){return"cms_files"!==e&&"instances"!==e&&(n?n.allowCreate:void 0)}},standard_edit:{visible:function(e,t,n){if(n)return n.allowEdit}},standard_delete:{visible:function(e,t,n){if(n)return n.allowDelete}},standard_import_data:{visible:function(e,t,n){var r=this.object;if(n)return n.allowCreate&&r.hasImportTemplates}},standard_approve:{visible:function(e,t,n){return!1}},standard_view_instance:{visible:function(e,t,n){return!1}},standard_submit_for_approval:{visible:function(e,t,n){return window.Steedos.ProcessManager.allowSubmit.apply(this,[e,t])},todo:function(e,t){return window.Steedos.ProcessManager.submit.apply(this,[e,t])}},standard_follow:{visible:function(e,t,n){return!1}},standard_delete_many:{visible:function(e,t,n){return!RegExp("\\w+/view/\\w+").test(location.pathname)&&(n?n.allowDelete:void 0)}},standard_export_excel:{visible:function(e,t,n){return!1}}}}},authRequest=function(e,t){var a=null;e=Steedos.absoluteUrl(e);try{var n=[{name:"Content-Type",value:"application/json"},{name:"Authorization",value:Steedos.getAuthorization()}],r={type:"get",url:e,dataType:"json",contentType:"application/json",beforeSend:function(t){if(n&&n.length)return n.forEach(function(e){return t.setRequestHeader(e.name,e.value)})},success:function(e){a=e},error:function(e,t,n){var r,o;e.responseJSON&&e.responseJSON.error?(r=e.responseJSON.error,o=void(a={error:r}),o=r.reason||r.message||r,console.error(o)):console.error(e.responseJSON)}};return $.ajax(Object.assign({},r,t)),a}catch(e){console.error(e)}};function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n,r=arguments[t];for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}const newFunctionComponent=o=>e=>{const[t,n]=React.useState(!0);var r=()=>{n(!1)};return _$1.has(e,"ref")||(window.SteedosUI.refs[e.name]={show:()=>{n(!0)},close:r}),React__default.createElement(o,_extends({visible:t,onCancel:r,onClose:r},{width:"70%",style:{width:"70%",maxWidth:"950px",minWidth:"480px"}},e))},newComponentRender=(n,r)=>(e,t)=>{e.name||(e.name=n+"-"+(e.name||"default")),(t=t||document.getElementById(`steedos-${n}-root-`+e.name))||((t=document.createElement("div")).setAttribute("id",`steedos-${n}-root-`+e.name),document.body.appendChild(t));e=React__default.createElement(newFunctionComponent(r),e);ReactDOM.createRoot(t).render(e)},Modal=_$1.assign(newComponentRender("modal",antd.Modal),{info:antd.Modal.info,success:antd.Modal.success,error:antd.Modal.error,warning:antd.Modal.warning,confirm:antd.Modal.confirm}),Drawer=newComponentRender("drawer",antd.Drawer),getGraphqlFieldsQuery=e=>{const t=["_id"];return e.push("record_permissions"),_$1.each(e,e=>{-1<e.indexOf(".")&&(e=e.split(".")[0]),t.push(""+e)}),""+t.join(" ")},getFindOneQuery=(e,t,n)=>{e=e.replace(/\./g,"_");n=getGraphqlFieldsQuery(n);let r="";t=[`id: "${t}"`];return`{record:${e}__findOne${r=0<t.length?`(${t.join(",")})`:r}{${n}}}`},SObject={getRecord:async(e,t,n)=>{return(await amisLib.fetchAPI("/graphql",{method:"post",body:JSON.stringify({query:getFindOneQuery(e,t,n)})})).data.record},getUISchema:async(e,t)=>amisLib.getUISchema(e,t)},canSaveFilter=e=>!(!e._id||e.owner!==amisLib.getSteedosAuth()?.userId),ListView={showFilter:(e,{listView:t,data:n})=>{canSaveFilter(t);n.filters&&(n.filters=amisLib.filtersToConditions(n.filters))},getVisibleFilter:(e,t)=>{return t||(canSaveFilter(e)?e.filters:void 0)},getQueryFilter:(e,t)=>{return canSaveFilter(e)?ListView.getVisibleFilter(e,t):_$1.isEmpty(t)?e.filters:[e.filters,"and",t]},getFirstListView:async e=>{e=await window.getUISchema(e);return _.first(_.sortBy(_.values(e.list_views),"sort_no"))}},Router={getAppPath({appId:e}){return"/app/"+e},getPagePath(){},getObjectListViewPath({appId:e,objectName:t,listViewName:n}){return`/app/${e}/${t}/grid/`+n},getObjectDetailPath({appId:e,objectName:t,recordId:n}){return`/app/${e}/${t}/view/`+n},getObjectRelatedViewPath({appId:e,masterObjectName:t,masterRecordId:n,objectName:r,foreignKey:o}){return`/app/${e}/${t}/${n}/${r}/grid?related_field_name=`+o}};var withModalWrap=function(t,e){return function(e){return React.createElement(t,e)}},render=function(e,t,n,r){e=withModalWrap(e),e=React.createElement(e,__assign({},t));return ReactDOM__default.render(e,n)};const safeRunFunction=(t,n,r,o)=>{try{var a=window.Creator;if(!!(!a||!a.getObjectUrl)&&/\bSteedos\b|\bCreator\b|\bMeteor\b|\bSession\b/.test(t))return console.info("调用了Creator|Steedos|Meteor|Session变量的脚本不执行,直接按空值处理。"),"";let e=[];return _$1.isNil(n)||(e=_$1.isArray(n)?n:[n]),t.bind(o||{})(...e)}catch(e){return console.log(e),r}};function safeEval(js){try{return eval(js)}catch(e){console.error(e,js)}}const isExpression=function(e){var t,n;return"string"==typeof e&&(t=/^{{(function.+)}}$/,n=/^{{(.+=>.+)}}$/,!("string"!=typeof e||!e.match(/^{{(.+)}}$/)||e.match(t)||e.match(n)))},parseSingleExpression=function(t,e,n,r){var o,a=function(e,t){return"#"!==t&&t?"string"==typeof t?_.get(e,t):void console.error("path has to be a string"):e||{}}(e=void 0===e?{}:e,function(e){return"string"!=typeof e||1===(e=e.split(".")).length?"#":(e.pop(),e.join("."))}(n))||{};if("string"!=typeof t)return t;o="__G_L_O_B_A_L__",e="\n return "+t.substring(2,t.length-2).replace(/\bformData\b/g,JSON.stringify(e).replace(/\bglobal\b/g,o)).replace(/\bglobal\b/g,JSON.stringify(r)).replace(new RegExp("\\b"+o+"\\b","g"),"global").replace(/rootValue/g,JSON.stringify(a));try{return Function(e)()}catch(e){return console.log(e,t,n),t}};var Expression=Object.freeze({__proto__:null,isExpression:isExpression,parseSingleExpression:parseSingleExpression});const getCompatibleDefaultValueExpression=(express,multiple)=>{const reg=/^\{\w+(\.*\w+)*\}$/,reg2=/^{{[\s\S]*}}$/;let result=express;if(reg.test(express)&&(result=-1<express.indexOf("userId")||-1<express.indexOf("spaceId")||-1<express.indexOf("user.")||-1<express.indexOf("now")?`{${express}}`.replace("{{","{{global."):`{${express}}`.replace("{{","{{formData."),multiple&&(result=result.replace(/\{\{(.+)\}\}/,"{{[$1]}}"))),reg2.test(express)&&(-1<express.indexOf("function")||-1<express.indexOf("=>"))){let regex=/\{\{([\s\S]*)\}\}/,matches=regex.exec(express);if(matches&&1<matches.length){let functionCode=matches[1];result=eval("("+functionCode+")")()}}return result},getFieldDefaultValue=(e,t)=>{if(!e)return null;let n=e.defaultValue;e._defaultValue&&(n=safeEval(`(${e._defaultValue})`)),_$1.isFunction(n)&&(n=safeRunFunction(n,[],null,{name:e.name})),_$1.isString(n)&&(n=getCompatibleDefaultValueExpression(n,e.multiple));var r=isExpression(n);return r&&(n=parseSingleExpression(n,{},"#",t)),"select"===e.type&&(t=e.data_type||"text",!n||r||e.multiple||("text"!==t||_$1.isString(n)?"number"!==t||_$1.isNumber(n)?"boolean"!==t||_$1.isBoolean(n)||(n="true"===n):n=Number(n):n=String(n))),n};function getTreeOptions(t,e){const o=e?.valueField||"value";e?.labelField;const n=e?.unfoldedNum||1,r=[],a=(t,n,r)=>{var e;if(n)return e=_.filter(t,e=>_.includes(n,e[o])),_.each(e,e=>{1<=r?(e.unfolded=!0,e.children&&(e.children=a(t,e.children,r-1))):e.children&&(e.children=a(t,e.children,r))}),e};for(var i=t,s=0;s<i.length;s++)if(i[s].noParent=0,i[s].unfolded=!1,i[s].parent){let e=1;for(var l=0;l<i.length;l++)i[s].parent==i[l][o]&&(e=0);1==e&&(i[s].noParent=1)}else i[s].noParent=1;return _.each(t,e=>{1==e.noParent&&(1<=n?(e.unfolded=!0,r.push(Object.assign({},e,{children:a(t,e.children,n-1)}))):r.push(Object.assign({},e,{children:a(t,e.children,n)})))}),r}function getClosestAmisComponentByType(t,n,r){let o=(r=r||{}).name;var e=r.direction||"up";let a=t.getComponents().find(function(e){return e.props.type===n&&(!o||e.props.name===o)});if(a)return a;if("down"===e){if(t.children&&t.children.length){for(let e=0;e<t.children.length&&!(a=getClosestAmisComponentByType(t.children[e],n,r));e++);return a}}else if("up"===e&&t.parent)return getClosestAmisComponentByType(t.parent,n,r)}function isFilterFormValuesEmpty(e){let t=!0;var e=_.pickBy(e,function(e,t){return/^__searchable__/g.test(t)});return _.isEmpty(e)||(e=_.omitBy(e,function(e){return _.isNil(e)||_.isObject(e)&&_.isEmpty(e)||_.isArray(e)&&_.isEmpty(e.filter(function(e){return!_.isNil(e)}))||_.isString(e)&&0===e.length}),_.isEmpty(e)||(t=!1)),t}const SteedosUI=Object.assign({},{render:render,Router:Router,ListView:ListView,Object:SObject,Modal:Modal,Drawer:Drawer,refs:{},getRef(e){return SteedosUI.refs[e]},router:{go:(e,t)=>{var n=window.FlowRouter;if(t)return n?n.go(t):window.open(t);n?n.reload():console.warn("暂不支持自动跳转",e)},reload:()=>{console.log("reload")}},message:antd.message,notification:antd.notification,components:{Button:antd.Button,Space:antd.Space},getRefId:({type:e,appId:t,name:n})=>{switch(e){case"listview":return`amis-${t}-${n}-listview`;case"form":return`amis-${t}-${n}-form`;case"detail":return`amis-${t}-${n}-detail`;default:return`amis-${t}-${n}-`+e}},reloadRecord:()=>{if(window.FlowRouter)return window.FlowRouter.reload()},getFieldDefaultValue:getFieldDefaultValue,getTreeOptions:getTreeOptions,getClosestAmisComponentByType:getClosestAmisComponentByType,isFilterFormValuesEmpty:isFilterFormValuesEmpty,getSearchFilter:e=>{var o=[];return _.each(e,(e,t)=>{var n,r;_.isEmpty(e)&&!_.isBoolean(e)||(_.startsWith(t,"__searchable__between__")?o.push([""+t.replace("__searchable__between__",""),"between",e]):_.startsWith(t,"__searchable__")&&(_.isString(e)?o.push([""+t.replace("__searchable__",""),"contains",e]):_.isObject(e)&&e.o?(r=[[(n=""+t.replace("__searchable__",""))+"/o","=",e.o]],e.ids.length&&r.push([n+"/ids","=",e.ids]),o.push(r)):o.push([""+t.replace("__searchable__",""),"=",e])))}),o},getKeywordsSearchFilter:(e,t)=>{const o=[];var a;return e&&t&&(a=e.split(/\s+/),a=_$1.compact(a),t.forEach(function(n,e){let r=[];1==a.length?r=[n,"contains",a[0]]:a.forEach(function(e,t){r.push([n,"contains",e]),t<a.length-1&&r.push("or")}),r.length&&(o.push(r),e<t.length-1&&o.push("or"))})),o}});var getBuilderContext=function(){return"undefined"==typeof window?{}:Builder.settings.context||Builder.settings},Steedos$1=__assign({getRootUrl:function(e){var t=getBuilderContext();return t.rootUrl||("undefined"!=typeof window?window.localStorage.getItem("steedos:rootUrl"):"")||e},absoluteUrl:function(e){return void 0===e&&(e=""),"".concat(Steedos$1.getRootUrl()).concat(e)},getTenantId:function(){try{var e=getBuilderContext().tenantId;return(e=window.location.search&&!e?new URLSearchParams(window.location.search).get("X-Space-Id"):e)?e:null}catch(e){console.error(e)}},getAuthorization:function(){try{var e=getBuilderContext(),t=e.tenantId,n=e.authToken;return t&&n?"Bearer ".concat(t,",").concat(n):null}catch(e){console.error(e)}},authRequest:authRequest,StandardObjects:StandardObjects},Expression);"undefined"==typeof window||window.Steedos||(window.Steedos=Steedos$1),"undefined"==typeof window||window.SteedosUI||(window.SteedosUI=SteedosUI),exports.Steedos=Steedos$1,exports.SteedosUI=SteedosUI,Object.defineProperty(exports,"__esModule",{value:!0})});
|
|
1
|
+
function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return i};var i={},e=Object.prototype,s=e.hasOwnProperty,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",o=t.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o,a,i,c,t=t&&t.prototype instanceof f?t:f,t=Object.create(t.prototype),n=new w(n||[]);return t._invoke=(o=e,a=r,i=n,c="suspendedStart",function(e,t){if("executing"===c)throw new Error("Generator is already running");if("completed"===c){if("throw"===e)throw t;return x()}for(i.method=e,i.arg=t;;){var r=i.delegate;if(r){r=function e(t,r){var n=t.iterator[r.method];if(void 0===n){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,e(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}n=u(n,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,l;n=n.arg;return n?n.done?(r[t.resultName]=n.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):n:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}(r,i);if(r){if(r===l)continue;return r}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if("suspendedStart"===c)throw c="completed",i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);c="executing";r=u(o,a,i);if("normal"===r.type){if(c=i.done?"completed":"suspendedYield",r.arg===l)continue;return{value:r.arg,done:i.done}}"throw"===r.type&&(c="completed",i.method="throw",i.arg=r.arg)}}),t}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}i.wrap=c;var l={};function f(){}function d(){}function p(){}var t={},h=(a(t,n,function(){return this}),Object.getPrototypeOf),h=h&&h(h(b([]))),y=(h&&h!==e&&s.call(h,n)&&(t=h),p.prototype=f.prototype=Object.create(t));function m(e){["next","throw","return"].forEach(function(t){a(e,t,function(e){return this._invoke(t,e)})})}function g(i,c){var t;this._invoke=function(r,n){function e(){return new c(function(e,t){!function t(e,r,n,o){var a,e=u(i[e],i,r);if("throw"!==e.type)return(r=(a=e.arg).value)&&"object"==_typeof(r)&&s.call(r,"__await")?c.resolve(r.__await).then(function(e){t("next",e,n,o)},function(e){t("throw",e,n,o)}):c.resolve(r).then(function(e){a.value=e,n(a)},function(e){return t("throw",e,n,o)});o(e.arg)}(r,n,e,t)})}return t=t?t.then(e,e):e()}}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function v(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function b(t){if(t){var r,e=t[n];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return r=-1,(e=function e(){for(;++r<t.length;)if(s.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e}).next=e}return{next:x}}function x(){return{value:void 0,done:!0}}return a(y,"constructor",d.prototype=p),a(p,"constructor",d),d.displayName=a(p,o,"GeneratorFunction"),i.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},i.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,a(e,o,"GeneratorFunction")),e.prototype=Object.create(y),e},i.awrap=function(e){return{__await:e}},m(g.prototype),a(g.prototype,r,function(){return this}),i.AsyncIterator=g,i.async=function(e,t,r,n,o){void 0===o&&(o=Promise);var a=new g(c(e,t,r,n),o);return i.isGeneratorFunction(t)?a:a.next().then(function(e){return e.done?e.value:a.next()})},m(y),a(y,o,"Generator"),a(y,n,function(){return this}),a(y,"toString",function(){return"[object Generator]"}),i.keys=function(r){var e,n=[];for(e in r)n.push(e);return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},i.values=b,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(v),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function e(e,t){return a.type="throw",a.arg=r,n.next=e,t&&(n.method="next",n.arg=void 0),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var o=this.tryEntries[t],a=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var i=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(i&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var a=(o=o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc?null:o)?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),v(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var r,n,o=this.tryEntries[t];if(o.tryLoc===e)return"throw"===(r=o.completion).type&&(n=r.arg,v(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:b(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},i}function asyncGeneratorStep(e,t,r,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function _asyncToGenerator(c){return function(){var e=this,i=arguments;return new Promise(function(t,r){var n=c.apply(e,i);function o(e){asyncGeneratorStep(n,t,r,o,a,"next",e)}function a(e){asyncGeneratorStep(n,t,r,o,a,"throw",e)}o(void 0)})}}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?t(exports,require("antd"),require("react"),require("react-dom"),require("lodash"),require("@steedos-widgets/amis-lib")):"function"==typeof define&&define.amd?define(["exports","antd","react","react-dom","lodash","@steedos-widgets/amis-lib"],t):t((e=e||self)["steedos-lib"]={},e.antd,e.React,e.ReactDOM,e._,e.amisLib)}(this,function(exports,antd,React,ReactDOM,_$1,amisLib){var global=window,React__default="default"in React?React.default:React,ReactDOM__default="default"in ReactDOM?ReactDOM.default:ReactDOM,_assign=function(){return(_assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},StandardObjects={Base:{Actions:{standard_query:{visible:function(e,t,r){return!1}},standard_new:{visible:function(e,t,r){return"cms_files"!==e&&"instances"!==e&&(r?r.allowCreate:void 0)}},standard_edit:{visible:function(e,t,r){if(r)return r.allowEdit}},standard_delete:{visible:function(e,t,r){if(r)return r.allowDelete}},standard_import_data:{visible:function(e,t,r){var n=this.object;if(r)return r.allowCreate&&n.hasImportTemplates}},standard_approve:{visible:function(e,t,r){return!1}},standard_view_instance:{visible:function(e,t,r){return!1}},standard_submit_for_approval:{visible:function(e,t,r){return window.Steedos.ProcessManager.allowSubmit.apply(this,[e,t])},todo:function(e,t){return window.Steedos.ProcessManager.submit.apply(this,[e,t])}},standard_follow:{visible:function(e,t,r){return!1}},standard_delete_many:{visible:function(e,t,r){return!RegExp("\\w+/view/\\w+").test(location.pathname)&&(r?r.allowDelete:void 0)}},standard_export_excel:{visible:function(e,t,r){return!1}}}}},authRequest=function(e,t){var a=null;e=Steedos.absoluteUrl(e);try{var r=[{name:"Content-Type",value:"application/json"},{name:"Authorization",value:Steedos.getAuthorization()}],n={type:"get",url:e,dataType:"json",contentType:"application/json",beforeSend:function(t){if(r&&r.length)return r.forEach(function(e){return t.setRequestHeader(e.name,e.value)})},success:function(e){a=e},error:function(e,t,r){var n,o;e.responseJSON&&e.responseJSON.error?(n=e.responseJSON.error,o=void(a={error:n}),o=n.reason||n.message||n,console.error(o)):console.error(e.responseJSON)}};return $.ajax(Object.assign({},n,t)),a}catch(e){console.error(e)}};function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var newFunctionComponent=function(a){return function(e){function t(){o(!1)}var r=_slicedToArray(React.useState(!0),2),n=r[0],o=r[1];return _$1.has(e,"ref")||(window.SteedosUI.refs[e.name]={show:function(){o(!0)},close:t}),React__default.createElement(a,_extends({visible:n,onCancel:t,onClose:t},{width:"70%",style:{width:"70%",maxWidth:"950px",minWidth:"480px"}},e))}},newComponentRender=function(r,n){return function(e,t){e.name||(e.name="".concat(r,"-").concat(e.name||"default")),(t=t||document.getElementById("steedos-".concat(r,"-root-").concat(e.name)))||((t=document.createElement("div")).setAttribute("id","steedos-".concat(r,"-root-").concat(e.name)),document.body.appendChild(t));e=React__default.createElement(newFunctionComponent(n),e);ReactDOM.createRoot(t).render(e)}},Modal=_$1.assign(newComponentRender("modal",antd.Modal),{info:antd.Modal.info,success:antd.Modal.success,error:antd.Modal.error,warning:antd.Modal.warning,confirm:antd.Modal.confirm}),Drawer=newComponentRender("drawer",antd.Drawer),getGraphqlFieldsQuery=function(e){var t=["_id"];return e.push("record_permissions"),_$1.each(e,function(e){-1<e.indexOf(".")&&(e=e.split(".")[0]),t.push("".concat(e))}),"".concat(t.join(" "))},getFindOneQuery=function(e,t,r){e=e.replace(/\./g,"_");var r=getGraphqlFieldsQuery(r),n="",t=['id: "'.concat(t,'"')];return 0<t.length&&(n="(".concat(t.join(","),")")),"{".concat("record",":").concat(e,"__findOne").concat(n,"{").concat(r,"}}")},SObject={getRecord:function(){var n=_asyncToGenerator(_regeneratorRuntime().mark(function e(t,r,n){var o;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,amisLib.fetchAPI("/graphql",{method:"post",body:JSON.stringify({query:getFindOneQuery(t,r,n)})});case 2:return o=e.sent,e.abrupt("return",o.data.record);case 4:case"end":return e.stop()}},e)}));return function(e,t,r){return n.apply(this,arguments)}}(),getUISchema:function(){var r=_asyncToGenerator(_regeneratorRuntime().mark(function e(t,r){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,amisLib.getUISchema(t,r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e)}));return function(e,t){return r.apply(this,arguments)}}()},canSaveFilter=function(e){return!(!e._id||e.owner!==(null==(e=amisLib.getSteedosAuth())?void 0:e.userId))},ListView={showFilter:function(e,t){var r=t.listView,n=t.data;t.props,t.onFilterChange,canSaveFilter(r);n.filters&&(n.filters=amisLib.filtersToConditions(n.filters))},getVisibleFilter:function(e,t){return t||(canSaveFilter(e)?e.filters:void 0)},getQueryFilter:function(e,t){return canSaveFilter(e)?ListView.getVisibleFilter(e,t):_$1.isEmpty(t)?e.filters:[e.filters,"and",t]},getFirstListView:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.getUISchema(t);case 2:return r=e.sent,e.abrupt("return",_.first(_.sortBy(_.values(r.list_views),"sort_no")));case 4:case"end":return e.stop()}},e)}));return function(e){return t.apply(this,arguments)}}()},Router={getAppPath:function(e){e.formFactor;e=e.appId;return"/app/".concat(e)},getPagePath:function(){},getObjectListViewPath:function(e){e.formFactor;var t=e.appId,r=e.objectName,e=e.listViewName;return"/app/".concat(t,"/").concat(r,"/grid/").concat(e)},getObjectDetailPath:function(e){e.formFactor;var t=e.appId,r=e.objectName,e=e.recordId;return"/app/".concat(t,"/").concat(r,"/view/").concat(e)},getObjectRelatedViewPath:function(e){e.formFactor;var t=e.appId,r=e.masterObjectName,n=e.masterRecordId,o=e.objectName,e=e.foreignKey;return"/app/".concat(t,"/").concat(r,"/").concat(n,"/").concat(o,"/grid?related_field_name=").concat(e)}},withModalWrap=function(t,e){return function(e){return React.createElement(t,e)}},render=function(e,t,r,n){e=withModalWrap(e),e=React.createElement(e,_assign({},t));return ReactDOM__default.render(e,r)},safeRunFunction=function(e,t,r,n){try{var o,a=window.Creator,i=!(!a||!a.getObjectUrl);return!i&&/\bSteedos\b|\bCreator\b|\bMeteor\b|\bSession\b/.test(e)?(console.info("调用了Creator|Steedos|Meteor|Session变量的脚本不执行,直接按空值处理。"),""):(o=[],_$1.isNil(t)||(o=_$1.isArray(t)?t:[t]),e.bind(n||{}).apply(void 0,_toConsumableArray(o)))}catch(e){return console.log(e),r}};function safeEval(js){try{return eval(js)}catch(e){console.error(e,js)}}var isExpression=function(e){var t,r;return"string"==typeof e&&(t=/^{{(function.+)}}$/,r=/^{{(.+=>.+)}}$/,!("string"!=typeof e||!e.match(/^{{(.+)}}$/)||e.match(t)||e.match(r)))},parseSingleExpression=function(t,e,r,n){var o,a=function(e,t){return"#"!==t&&t?"string"==typeof t?_.get(e,t):void console.error("path has to be a string"):e||{}}(e=void 0===e?{}:e,function(e){return"string"!=typeof e||1===(e=e.split(".")).length?"#":(e.pop(),e.join("."))}(r))||{};if("string"!=typeof t)return t;o="__G_L_O_B_A_L__",e="\n return "+t.substring(2,t.length-2).replace(/\bformData\b/g,JSON.stringify(e).replace(/\bglobal\b/g,o)).replace(/\bglobal\b/g,JSON.stringify(n)).replace(new RegExp("\\b"+o+"\\b","g"),"global").replace(/rootValue/g,JSON.stringify(a));try{return Function(e)()}catch(e){return console.log(e,t,r),t}},Expression=Object.freeze({__proto__:null,isExpression:isExpression,parseSingleExpression:parseSingleExpression}),getCompatibleDefaultValueExpression=function getCompatibleDefaultValueExpression(express,multiple){var reg=/^\{\w+(\.*\w+)*\}$/,reg2=/^{{[\s\S]*}}$/,result=express,regex,matches,functionCode,result;return reg.test(express)&&(result=-1<express.indexOf("userId")||-1<express.indexOf("spaceId")||-1<express.indexOf("user.")||-1<express.indexOf("now")?"{".concat(express,"}").replace("{{","{{global."):"{".concat(express,"}").replace("{{","{{formData."),multiple&&(result=result.replace(/\{\{(.+)\}\}/,"{{[$1]}}"))),reg2.test(express)&&(-1<express.indexOf("function")||-1<express.indexOf("=>"))&&(regex=/\{\{([\s\S]*)\}\}/,matches=regex.exec(express),matches&&1<matches.length&&(functionCode=matches[1],result=eval("("+functionCode+")")())),result},getFieldDefaultValue=function(e,t){var r,n;return e?(r=e.defaultValue,e._defaultValue&&(r=safeEval("(".concat(e._defaultValue,")"))),_$1.isFunction(r)&&(r=safeRunFunction(r,[],null,{name:e.name})),_$1.isString(r)&&(r=getCompatibleDefaultValueExpression(r,e.multiple)),(n=isExpression(r))&&(r=parseSingleExpression(r,{},"#",t)),"select"===e.type&&(t=e.data_type||"text",!r||n||e.multiple||("text"!==t||_$1.isString(r)?"number"!==t||_$1.isNumber(r)?"boolean"!==t||_$1.isBoolean(r)||(r="true"===r):r=Number(r):r=String(r))),r):null};function getTreeOptions(t,e){function o(t,r,n){var e;if(r)return e=_.filter(t,function(e){return _.includes(r,e[a])}),_.each(e,function(e){1<=n?(e.unfolded=!0,e.children&&(e.children=o(t,e.children,n-1))):e.children&&(e.children=o(t,e.children,n))}),e}for(var a=(null==e?void 0:e.valueField)||"value",r=(null==e||e.labelField,(null==e?void 0:e.unfoldedNum)||1),n=[],i=t,c=0;c<i.length;c++)if(i[c].noParent=0,i[c].unfolded=!1,i[c].parent){for(var s=1,u=0;u<i.length;u++)i[c].parent==i[u][a]&&(s=0);1==s&&(i[c].noParent=1)}else i[c].noParent=1;return _.each(t,function(e){1==e.noParent&&(1<=r?(e.unfolded=!0,n.push(Object.assign({},e,{children:o(t,e.children,r-1)}))):n.push(Object.assign({},e,{children:o(t,e.children,r)})))}),n}function getClosestAmisComponentByType(e,t,r){var n=(r=r||{}).name,o=r.direction||"up",a=e.getComponents().find(function(e){return e.props.type===t&&(!n||e.props.name===n)});if(a)return a;if("down"===o){if(e.children&&e.children.length){for(var i=0;i<e.children.length&&!(a=getClosestAmisComponentByType(e.children[i],t,r));i++);return a}}else if("up"===o&&e.parent)return getClosestAmisComponentByType(e.parent,t,r)}function isFilterFormValuesEmpty(e){var t=!0,e=_.pickBy(e,function(e,t){return/^__searchable__/g.test(t)});return _.isEmpty(e)||(e=_.omitBy(e,function(e){return _.isNil(e)||_.isObject(e)&&_.isEmpty(e)||_.isArray(e)&&_.isEmpty(e.filter(function(e){return!_.isNil(e)}))||_.isString(e)&&0===e.length}),_.isEmpty(e)||(t=!1)),t}var SteedosUI=Object.assign({},{render:render,Router:Router,ListView:ListView,Object:SObject,Modal:Modal,Drawer:Drawer,refs:{},getRef:function(e){return SteedosUI.refs[e]},router:{go:function(e,t){var r=window.FlowRouter;if(t)return r?r.go(t):window.open(t);r?r.reload():console.warn("暂不支持自动跳转",e)},reload:function(){console.log("reload")}},message:antd.message,notification:antd.notification,components:{Button:antd.Button,Space:antd.Space},getRefId:function(e){var t=e.type,r=e.appId,n=e.name;switch(t){case"listview":return"amis-".concat(r,"-").concat(n,"-listview");case"form":return"amis-".concat(r,"-").concat(n,"-form");case"detail":return"amis-".concat(r,"-").concat(n,"-detail");default:return"amis-".concat(r,"-").concat(n,"-").concat(t)}},reloadRecord:function(){if(window.FlowRouter)return window.FlowRouter.reload()},getFieldDefaultValue:getFieldDefaultValue,getTreeOptions:getTreeOptions,getClosestAmisComponentByType:getClosestAmisComponentByType,isFilterFormValuesEmpty:isFilterFormValuesEmpty,getSearchFilter:function(e){var o=[];return _.each(e,function(e,t){var r,n;_.isEmpty(e)&&!_.isBoolean(e)||(_.startsWith(t,"__searchable__between__")?o.push(["".concat(t.replace("__searchable__between__","")),"between",e]):_.startsWith(t,"__searchable__")&&(_.isString(e)?o.push(["".concat(t.replace("__searchable__","")),"contains",e]):_.isObject(e)&&e.o?(n=[[(r="".concat(t.replace("__searchable__","")))+"/o","=",e.o]],e.ids.length&&n.push([r+"/ids","=",e.ids]),o.push(n)):o.push(["".concat(t.replace("__searchable__","")),"=",e])))}),o},getKeywordsSearchFilter:function(e,t){var o,a=[];return e&&t&&(o=e.split(/\s+/),o=_$1.compact(o),t.forEach(function(r,e){var n=[];1==o.length?n=[r,"contains",o[0]]:o.forEach(function(e,t){n.push([r,"contains",e]),t<o.length-1&&n.push("or")}),n.length&&(a.push(n),e<t.length-1&&a.push("or"))})),a}}),getBuilderContext=function(){return"undefined"==typeof window?{}:Builder.settings.context||Builder.settings},Steedos$1=_assign({getRootUrl:function(e){var t=getBuilderContext();return t.rootUrl||("undefined"!=typeof window?window.localStorage.getItem("steedos:rootUrl"):"")||e},absoluteUrl:function(e){return void 0===e&&(e=""),"".concat(Steedos$1.getRootUrl()).concat(e)},getTenantId:function(){try{var e=getBuilderContext().tenantId;return(e=window.location.search&&!e?new URLSearchParams(window.location.search).get("X-Space-Id"):e)?e:null}catch(e){console.error(e)}},getAuthorization:function(){try{var e=getBuilderContext(),t=e.tenantId,r=e.authToken;return t&&r?"Bearer ".concat(t,",").concat(r):null}catch(e){console.error(e)}},authRequest:authRequest,StandardObjects:StandardObjects},Expression);"undefined"==typeof window||window.Steedos||(window.Steedos=Steedos$1),"undefined"==typeof window||window.SteedosUI||(window.SteedosUI=SteedosUI),exports.Steedos=Steedos$1,exports.SteedosUI=SteedosUI,Object.defineProperty(exports,"__esModule",{value:!0})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos-widgets/steedos-lib",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0-beta.10",
|
|
5
5
|
"unpkg": "./dist/index.umd.js",
|
|
6
6
|
"main": "./dist/index.cjs.js",
|
|
7
7
|
"module": "./dist/index.esm.js",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"lodash": "^4.17.21"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "7f712765c85defa6acc01ad2b4e2694542d99868"
|
|
28
28
|
}
|