UNPKG

@aurigma/ui-framework

Version:

A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.

1 lines 3.68 kB
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[48],{934:function(t,e,n){n.r(e),n.d(e,"AuWidgetSteps",function(){return d}),n.d(e,"widget",function(){return d});var i,s,r,u=n(0),e=n(2),a=n(76),o=n(17),c=n(1),l=n(46),n=n(160),d=((s=i=i||{})[s.previous=0]="previous",s[s.visited=1]="visited",s[s.all=2]="all",r=n.a,Object(u.d)(p,r),p.prototype.connectedCallback=function(){var e=this;r.prototype.connectedCallback.call(this),this.stepSubscription=this.observe(o.a.STEP_CHANGED).subscribe(function(t){return e._stepChangeCallback(t)})},p.prototype._stepChangeCallback=function(n){return Object(u.b)(this,void 0,void 0,function(){var e;return Object(u.e)(this,function(t){switch(t.label){case 0:if(e=n.data.step,!c.a.isNotNullOrUndefined(this.params)||!c.a.isNotNullOrUndefined(this.params.availabilityMode))return[3,7];switch(i[this.params.availabilityMode.toString()]){case i.previous:return[3,1];case i.visited:return[3,3];case i.all:return[3,5]}return[3,5];case 1:return[4,this.stepsManager.handleModePrevious(e)];case 2:return t.sent(),[3,6];case 3:return[4,this.stepsManager.handleModeVisited(e)];case 4:return t.sent(),[3,6];case 5:return[3,6];case 6:this.updateParams(this.params),t.label=7;case 7:return[2]}})})},p.prototype.updateParams=function(t){var e;t.steps&&this.changeStepState(t.steps),t.finishButton&&(null!=(e=t.finishButton)&&e.onClick&&this._subscribeToOnFinishClick(null==(e=t.finishButton)?void 0:e.onClick),this.stepsManager.finishButton=t.finishButton,this.stepsManager.update()),t.backToProductButton&&(this.stepsManager.backToProductButton=t.backToProductButton,this.stepsManager.update())},p.prototype._subscribeToOnFinishClick=function(n){return Object(u.b)(this,void 0,void 0,function(){var e=this;return Object(u.e)(this,function(t){return this.publishData({selector:"#finishButton"},o.a.GET_ELEMENT_FROM_AU_WIZARD).then(function(t){!t||e._isSubscribedToOnFinish||(t.onFinish.subscribe(function(){return Object(u.b)(e,void 0,void 0,function(){return Object(u.e)(this,function(t){switch(t.label){case 0:return[4,c.a.functionWrapperConstructor(n)()];case 1:return t.sent(),[2]}})})}),e._isSubscribedToOnFinish=!0)}),[2]})})},p.prototype.changeStepState=function(c){return Object(u.b)(this,void 0,void 0,function(){var e,n,i,s,r,a,o;return Object(u.e)(this,function(t){switch(t.label){case 0:e=this.stepsManager.steps,t.label=1;case 1:t.trys.push([1,6,7,8]),n=Object(u.k)(Object.entries(c)),i=n.next(),t.label=2;case 2:return i.done?[3,5]:(s=Object(u.h)(i.value,2),r=s[0],s=s[1],[4,this._applyConfig(e,r,s)]);case 3:t.sent(),t.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return r=t.sent(),a={error:r},[3,8];case 7:try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}return[7];case 8:return this.stepsManager.update(),[2]}})})},p.prototype._applyConfig=function(n,i,s){return Object(u.b)(this,void 0,void 0,function(){var e;return Object(u.e)(this,function(t){return(e=c.a.isNum(i)?n[Number(i)]:n.find(function(t){return t.title===i||t.name===i}))&&(e=n.indexOf(e),c.a.isNotNullOrUndefined(s.enabled)&&this.stepsManager.toggleDisable(e,!s.enabled,!1),c.a.isNotNullOrUndefined(s.disabled)&&this.stepsManager.toggleDisable(e,s.disabled,!1),c.a.isNotNullOrUndefined(s.hidden))&&this.stepsManager.toggleHidden(e,s.hidden,!1),[2]})})},Object(u.c)([Object(l.b)("StepsManager"),Object(u.g)("design:type",a.a)],p.prototype,"stepsManager",void 0),Object(u.c)([Object(e.c)(),Object(u.g)("design:type",Object)],p.prototype,"params",void 0),Object(u.c)([Object(e.a)("au-widget-steps")],p));function p(){var t=null!==r&&r.apply(this,arguments)||this;return t._isSubscribedToOnFinish=!1,t}}}]);