@primno/core
Version:
Front-end framework for Model-Driven Apps of Power Apps and Dynamics 365.
2 lines (1 loc) • 8.6 kB
JavaScript
;var t,e;exports.EventTypes=void 0,(t=exports.EventTypes||(exports.EventTypes={})).FormLoad="FormLoad",t.DataLoad="DataLoad",t.Save="Save",t.PostSave="PostSave",t.ColumnChange="ColumnChange",t.LookupTagClick="LookupTagClick",t.TabStateChange="TabStateChange",t.PreSearch="PreSearch",t.CommandInvoke="CommandInvoke",t.StageChange="StageChange",t.PreStageChange="PreStageChange",t.ProcessStatusChange="ProcessStatusChange",t.PreProcessStatusChange="PreProcessStatusChange",t.StageSelected="StageSelected",t.IframeLoaded="IframeLoaded",t.EnableRule="EnableRule",t.GridLoad="GridLoad",t.GridSave="GridSave",t.GridChange="GridChange",t.OutputChange="OutputChange",t.GridRecordSelect="GridRecordSelect",t.PopulateQuery="PopulateQuery",exports.ControlType=void 0,(e=exports.ControlType||(exports.ControlType={})).form="form",e.grid="grid";var a="optional",n="inversify:tagged",r="inversify:tagged_props",o="inversify:paramtypes",s="design:paramtypes",i="Cannot apply @injectable decorator multiple times.",u="Metadata key was used more than once in a parameter:",p="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.",c=function(){function t(t,e){this.key=t,this.value=e}return t.prototype.toString=function(){return"named"===this.key?"named: "+String(this.value).toString()+" ":"tagged: { key:"+this.key.toString()+", value: "+String(this.value)+" }"},t}();function d(t,e,a,r){!function(t){if(void 0!==t)throw new Error(p)}(e),h(n,t,a.toString(),r)}function g(t){var e=[];if(Array.isArray(t)){var a=function(t){for(var e=new Set,a=0,n=t;a<n.length;a++){var r=n[a];if(e.has(r))return r;e.add(r)}}((e=t).map((function(t){return t.key})));if(void 0!==a)throw new Error(u+" "+a.toString())}else e=[t];return e}function h(t,e,a,n){var r=g(n),o={};Reflect.hasOwnMetadata(t,e)&&(o=Reflect.getMetadata(t,e));var s=o[a];if(void 0===s)s=[];else for(var i=function(t){if(r.some((function(e){return e.key===t.key})))throw new Error(u+" "+t.key.toString())},p=0,c=s;p<c.length;p++){i(c[p])}s.push.apply(s,r),o[a]=s,Reflect.defineMetadata(t,o,e)}function f(t){return function(e,a,n){"number"==typeof n?d(e,a,n,t):function(t,e,a){if(void 0!==t.prototype)throw new Error(p);h(r,t.constructor,e,a)}(e,a,t)}}function y(t,e){Reflect.decorate(t,e)}function l(t,e){return function(a,n){e(a,n,t)}}function v(t,e,a){"number"==typeof a?y([l(a,t)],e):"string"==typeof a?Reflect.decorate([t],e,a):y([t],e)}var M,m,S,x=(M="inject",function(t){return function(e,a,n){if(void 0===t){var r="function"==typeof e?e.name:e.constructor.name;throw new Error("@inject called with undefined this could mean that the class "+r+" has a circular dependency problem. You can use a LazyServiceIdentifer to overcome this limitation.")}return f(new c(M,t))(e,a,n)}});function C(t){return x(t)}function w(t){switch(typeof t){case"object":return t.constructor;case"function":return t;default:throw new Error("Metadata storage can't be resolved. Unsupported target")}}!function(t){t.module="module",t.component="component",t.events="events",t.config="config",t.subComponent="sub-components"}(m||(m={})),function(t){t.providers="providers"}(S||(S={}));class E{constructor(t,e="default"){this.storage=t,this.metadataKey=`primno:metadata-${e}`}getData(){return Reflect.getMetadata(this.metadataKey,this.storage)??{}}setData(t){Reflect.defineMetadata(this.metadataKey,t,this.storage)}getMetadata(t){return this.getData()[t]}setMetadata(t,e){const a=this.getData();a[t]=e,this.setData(a)}hasMetadata(t){return void 0!==this.getMetadata(t)}}const T=Reflect;const O=new class{constructor(){this.storage=new E(w(T))}getData(){return this.storage.getMetadata("global")??{}}setData(t){this.storage.setMetadata("global",t)}getMetadata(t){return this.getData()[t]}setMetadata(t,e){const a=this.getData();a[t]=e,this.setData(a)}hasMetadata(t){return void 0!==this.getMetadata(t)}};function P(t){return function(e){var a;v((function(t){if(Reflect.hasOwnMetadata(o,t))throw new Error(i);var e=Reflect.getMetadata(s,t)||[];return Reflect.defineMetadata(o,e,t),t}),e),"root"===t?.providedIn&&(a=e,O.setMetadata(S.providers,[...O.getMetadata(S.providers)??[],a]))}}class D{constructor(t){this.storage=new E(w(t),"class")}getMetadata(t){return this.storage.getMetadata(t)}setMetadata(t,e){this.storage.setMetadata(t,e)}hasMetadata(t){return void 0!==this.getMetadata(t)}}class b{constructor(t,e){this.storage=new E(t.constructor,"parameter"),this.parameterKey=e.toString()}getData(){return this.storage.getMetadata(this.parameterKey)??{}}setData(t){this.storage.setMetadata(this.parameterKey,t)}getMetadata(t){return this.getData()[t]}setMetadata(t,e){const a=this.getData();a[t]=e,this.setData(a)}hasMetadata(t){return void 0!==this.getMetadata(t)}}class k{get propertyKey(){return this._propertyKey}constructor(t,e){this.storage=new E(w(t),"property"),this._propertyKey=e}getData(){return this.storage.getMetadata(this.propertyKey)??{}}setData(t){this.storage.setMetadata(this.propertyKey,t)}getMetadata(t){return this.getData()[t]}setMetadata(t,e){const a=this.getData();a[t]=e,this.setData(a)}hasMetadata(t){return void 0!==this.getMetadata(t)}static getPropertiesMetadata(t){const e=new E(w(t),"property");return Object.keys(e.getData()).map((e=>new k(t,e)))}}class L{constructor(t,e,a){if(e||a)if("number"==typeof a)this.storage=new b(t,a);else{if("string"!=typeof e)throw new Error("Unsupported target");this.storage=new k(t,e)}else this.storage=new D(t)}getMetadata(t){return this.storage.getMetadata(t)}setMetadata(t,e){this.storage.setMetadata(t,e)}hasMetadata(t){return void 0!==this.storage.getMetadata(t)}}function R(t){return function(e,a,n){const r=new L(e,a),o=[...r.getMetadata(m.events)??[],t];r.setMetadata(m.events,o)}}exports.Inject=C,exports.Injectable=P,exports.MnComponent=function(t){return function(e){v(P(),e);new L(e).setMetadata(m.component,t)}},exports.MnConfig=function(t){return function(e,a,n){C("config")(e,a,n);new L(e,a,n).setMetadata(m.config,t)}},exports.MnInput=function(){return C("input")},exports.MnModule=function(t){return function(e){v(P(),e);const a=new L(e),n=a.getMetadata(m.module)??{};a.setMetadata(m.module,{...n,...t}),t.declarations?.forEach((e=>{const a=new D(e),n=a.getMetadata(m.component);if(!n)throw new Error(`Declared component ${e} is not a component`);n.moduleConfig=t,a.setMetadata(m.component,n)}))}},exports.MnOnColumnChange=function(t){return R({type:exports.EventTypes.ColumnChange,target:t})},exports.MnOnCommandInvoke=function(t){return R({type:exports.EventTypes.CommandInvoke,target:t})},exports.MnOnDataLoad=function(){return R({type:exports.EventTypes.DataLoad})},exports.MnOnEnableRule=function(t){return R({type:exports.EventTypes.EnableRule,target:t})},exports.MnOnFormLoad=function(){return R({type:exports.EventTypes.FormLoad})},exports.MnOnGridChange=function(t){return R({type:exports.EventTypes.GridChange,target:t})},exports.MnOnGridLoad=function(t){return R({type:exports.EventTypes.GridLoad,target:t})},exports.MnOnGridRecordSelect=function(t){return R({type:exports.EventTypes.GridRecordSelect,target:t})},exports.MnOnGridSave=function(t){return R({type:exports.EventTypes.GridSave,target:t})},exports.MnOnIframeLoaded=function(t){return R({type:exports.EventTypes.IframeLoaded,target:t})},exports.MnOnLookupTagClick=function(t){return R({type:exports.EventTypes.LookupTagClick,target:t})},exports.MnOnOutputChange=function(t){return R({type:exports.EventTypes.OutputChange,target:t})},exports.MnOnPopulateQuery=function(t){return R({type:exports.EventTypes.PopulateQuery,target:t})},exports.MnOnPostSave=function(){return R({type:exports.EventTypes.PostSave})},exports.MnOnPreProcessStatusChange=function(){return R({type:exports.EventTypes.PreProcessStatusChange})},exports.MnOnPreSearch=function(t){return R({type:exports.EventTypes.PreSearch,target:t})},exports.MnOnPreStageChange=function(){return R({type:exports.EventTypes.PreStageChange})},exports.MnOnProcessStatusChange=function(){return R({type:exports.EventTypes.ProcessStatusChange})},exports.MnOnSave=function(){return R({type:exports.EventTypes.Save})},exports.MnOnStageChange=function(){return R({type:exports.EventTypes.StageChange})},exports.MnOnStageSelected=function(){return R({type:exports.EventTypes.StageSelected})},exports.MnOnTabStateChange=function(t){return R({type:exports.EventTypes.TabStateChange,target:t})},exports.MnOutput=function(){return(t,e,a)=>{}},exports.MnSubComponent=function(t){return function(e,a,n){new L(e,a,n).setMetadata(m.subComponent,t)}},exports.Optional=function(){return f(new c(a,!0))};