@claspo/renderer 18.3.3 → 18.3.4-promo.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ViewRouter.js CHANGED
@@ -1 +1 @@
1
- import SysActionTypes from"./action/SysActionTypes";import SysEventTypes from"./common/SysEventTypes";import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import SysRouterEvent from"./RouterEvent";export default class ViewRouter extends DefaultEventEmitter{constructor(e,t,i,n,s){super(),this.eventEmitter=e,this.documentModel=t,this.viewRenderer=i,this.optionalDocumentStyles=n,this.services=s,this.currentViewIndex=null,this.currentViewComponentRef=null,this.eventEmitter.on(SysEventTypes.TOO_MANY_REQUESTS,()=>{this.viewDestroy(),this.documentContainer.innerText="Too many requests"}),this.transitions=[]}getCurrentViewIndex(){return this.currentViewIndex}start(e){this.documentContainer=window.document.createElement("div"),this.documentContainer.setAttribute("cl-document",""),this.optionalDocumentStyles&&Object.keys(this.optionalDocumentStyles).forEach(e=>{this.documentContainer.style[e]=this.optionalDocumentStyles[e]}),this.navigate(e||0);return this.eventEmitter.on(SysActionTypes.GO_TO_VIEW,(e,t,i)=>{const n="number"==typeof e?e:this.documentModel.getModel().views.findIndex(t=>t.id===e);-1===n?this.eventEmitter.emit("WIDGET_NAVIGATION_STATE_NOT_FOUND",{viewPointer:e}):this.navigate(n,i,n<this.currentViewIndex?this._previousViewDestroyedCb.bind(this):()=>{})}),this.eventEmitter.on(SysActionTypes.GO_TO_PREVIOUS_VIEW,()=>{this.getCurrentViewIndex()<=0||this.navigate(this.getCurrentViewIndex()-1,{},this._previousViewDestroyedCb.bind(this))}),this.eventEmitter.on(SysActionTypes.GO_TO_NEXT_VIEW,()=>{this.documentModel.getModel().views[this.getCurrentViewIndex()+1]&&this.navigate(this.getCurrentViewIndex()+1)}),this.documentContainer}destroy(){this.viewDestroy(),this.documentContainer&&this.documentContainer.remove()}navigate(e,t={},i=()=>{}){var n;let s=this.documentModel.getView(e);const r=this.currentViewIndex;if(this.currentViewIndex===e)return;if(!s)throw this.eventEmitter.emit("WIDGET_NAVIGATION_STATE_NOT_FOUND",{navigateTo:e}),new Error("View was not found by index: "+e);const o=this.viewRenderer.render(s,e);this.viewDestroy(),i(),this.documentContainer.appendChild(o),this.currentViewComponentRef=o,this.currentViewIndex=e,this.transitions.push({prevViewIndex:r,currentViewIndex:e,currentViewComponentRef:o,contactDataSubmitted:null===(n=this.services.submitState)||void 0===n?void 0:n.hasSubmitAttemptSinceLastChange(),routeState:t}),this.eventEmitter.emit(SysRouterEvent.NAVIGATION_END,e)}viewDestroy(){this.currentViewComponentRef&&this.viewRenderer.destroy(this.currentViewComponentRef)}getDocumentContainer(){return this.documentContainer}getLastTransition(){return this.transitions[this.transitions.length-1]}_previousViewDestroyedCb(){this.services.form.getControlsAsArray().forEach(e=>{e.viewIdx===this.currentViewIndex&&this.services.form.removeControl(e.name)}),this.services.state.setState({conditionalRedirectViewId:null})}}
1
+ import SysActionTypes from"./action/SysActionTypes";import SysEventTypes from"./common/SysEventTypes";import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import SysRouterEvent from"./RouterEvent";import systemResultStateNames from"./document-model/systemResultStateNames";import{LayoutType}from"@claspo/common/LayoutType";export default class ViewRouter extends DefaultEventEmitter{constructor(t,e,i,n,s){super(),this.eventEmitter=t,this.documentModel=e,this.viewRenderer=i,this.optionalDocumentStyles=n,this.services=s,this.currentViewIndex=null,this.currentViewComponentRef=null,this.eventEmitter.on(SysEventTypes.TOO_MANY_REQUESTS,()=>{this.viewDestroy(),this.documentContainer.innerText="Too many requests"}),this.transitions=[]}getCurrentViewIndex(){return this.currentViewIndex}start(t){this.documentContainer=window.document.createElement("div"),this.documentContainer.setAttribute("cl-document",""),this.optionalDocumentStyles&&Object.keys(this.optionalDocumentStyles).forEach(t=>{this.documentContainer.style[t]=this.optionalDocumentStyles[t]}),this.navigate(t||0);return this.eventEmitter.on(SysActionTypes.GO_TO_VIEW,(t,e,i)=>{const n="number"==typeof t?t:this.documentModel.getModel().views.findIndex(e=>e.id===t);-1===n?this.eventEmitter.emit("WIDGET_NAVIGATION_STATE_NOT_FOUND",{viewPointer:t}):this.navigate(n,i,n<this.currentViewIndex?this._previousViewDestroyedCb.bind(this):()=>{})}),this.eventEmitter.on(SysActionTypes.GO_TO_PREVIOUS_VIEW,()=>{this.getCurrentViewIndex()<=0||this.navigate(this.getCurrentViewIndex()-1,{},this._previousViewDestroyedCb.bind(this))}),this.eventEmitter.on(SysActionTypes.GO_TO_NEXT_VIEW,()=>{this.documentModel.getModel().views[this.getCurrentViewIndex()+1]&&this.navigate(this.getCurrentViewIndex()+1)}),this.documentContainer}destroy(){this.viewDestroy(),this.documentContainer&&this.documentContainer.remove()}navigate(t,e={},i=()=>{}){var n,s,o,r;let u=this.documentModel.getView(t);const m=this.currentViewIndex;if(this.currentViewIndex===t)return;if(!u)throw this.eventEmitter.emit("WIDGET_NAVIGATION_STATE_NOT_FOUND",{navigateTo:t}),new Error("View was not found by index: "+t);(null===(o=null===(s=null===(n=this.services)||void 0===n?void 0:n.config)||void 0===s?void 0:s.getConfig())||void 0===o?void 0:o.layoutType)===LayoutType.BUILT_IN&&setTimeout(()=>{var t;const e=systemResultStateNames.includes(u.label),i=null===(t=this.services.submitState)||void 0===t?void 0:t.hasSubmitAttemptSinceLastChange(),n=this.services.form.getControlsAsArray().length>0;e&&n&&!i&&(this.eventEmitter.emit("WIDGET_NAVIGATION_STATE_NOT_FOUND",{toSystemStateWithoutSubmitFromIndex:m,ctx:this.services.context.getKVMap()}),this.services.actionFactory.get({type:SysActionTypes.REQUEST}).execute(void 0,void 0,!0,{skipValidation:!0}))},300);const a=this.viewRenderer.render(u,t);this.viewDestroy(),i(),this.documentContainer.appendChild(a),this.currentViewComponentRef=a,this.currentViewIndex=t,this.transitions.push({prevViewIndex:m,currentViewIndex:t,currentViewComponentRef:a,contactDataSubmitted:null===(r=this.services.submitState)||void 0===r?void 0:r.hasSubmitAttemptSinceLastChange(),routeState:e}),this.eventEmitter.emit(SysRouterEvent.NAVIGATION_END,t)}viewDestroy(){this.currentViewComponentRef&&this.viewRenderer.destroy(this.currentViewComponentRef)}getDocumentContainer(){return this.documentContainer}getLastTransition(){return this.transitions[this.transitions.length-1]}_previousViewDestroyedCb(){this.services.form.getControlsAsArray().forEach(t=>{t.viewIdx===this.currentViewIndex&&this.services.form.removeControl(t.name)}),this.services.state.setState({conditionalRedirectViewId:null})}}
@@ -4,6 +4,7 @@ declare enum SysEventTypes {
4
4
  FAILED_TO_LOAD_COMPONENT_RESOURCE = "FAILED_TO_LOAD_COMPONENT_RESOURCE",
5
5
  EXECUTE_ACTION_BY_PREDICATE = "EXECUTE_ACTION_BY_PREDICATE",
6
6
  SUBMIT_REQUEST_STARTED = "SUBMIT_REQUEST_STARTED",
7
- SUBMIT_REQUEST_FINISHED = "SUBMIT_REQUEST_FINISHED"
7
+ SUBMIT_REQUEST_FINISHED = "SUBMIT_REQUEST_FINISHED",
8
+ PROMO_CODE_SHOWN = "PROMO_CODE_SHOWN"
8
9
  }
9
10
  export default SysEventTypes;
@@ -1 +1 @@
1
- var SysEventTypes;!function(E){E.TOO_MANY_REQUESTS="TOO_MANY_REQUESTS",E.COMPONENT_RESOURCES_LOADED="COMPONENT_RESOURCES_LOADED",E.FAILED_TO_LOAD_COMPONENT_RESOURCE="FAILED_TO_LOAD_COMPONENT_RESOURCE",E.EXECUTE_ACTION_BY_PREDICATE="EXECUTE_ACTION_BY_PREDICATE",E.SUBMIT_REQUEST_STARTED="SUBMIT_REQUEST_STARTED",E.SUBMIT_REQUEST_FINISHED="SUBMIT_REQUEST_FINISHED"}(SysEventTypes||(SysEventTypes={}));export default SysEventTypes;
1
+ var SysEventTypes;!function(E){E.TOO_MANY_REQUESTS="TOO_MANY_REQUESTS",E.COMPONENT_RESOURCES_LOADED="COMPONENT_RESOURCES_LOADED",E.FAILED_TO_LOAD_COMPONENT_RESOURCE="FAILED_TO_LOAD_COMPONENT_RESOURCE",E.EXECUTE_ACTION_BY_PREDICATE="EXECUTE_ACTION_BY_PREDICATE",E.SUBMIT_REQUEST_STARTED="SUBMIT_REQUEST_STARTED",E.SUBMIT_REQUEST_FINISHED="SUBMIT_REQUEST_FINISHED",E.PROMO_CODE_SHOWN="PROMO_CODE_SHOWN"}(SysEventTypes||(SysEventTypes={}));export default SysEventTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claspo/renderer",
3
- "version": "18.3.3",
3
+ "version": "18.3.4-promo.7",
4
4
  "scripts": {
5
5
  "dev": " tsc --project tsconfig.json --watch",
6
6
  "build": "rm -rf out && tsc --project tsconfig.json && npm run minify",