UNPKG

@aurigma/ui-framework

Version:

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

1 lines 5.31 kB
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[39],{872:function(t,e){t.exports='<style>\n :host {\n width: 100%;\n height: 100%;\n }\n #pantone-cp body{\n margin: 0;\n }\n</style>\n\n<iframe id="pantone-cp" width="100%" height="100%" style="border: none"></iframe>\n'},941:function(t,e,n){n.r(e),n.d(e,"AuWidgetPantoneColorPicker",function(){return r}),n.d(e,"widget",function(){return r});function i(){}var s,a=n(0),c=n(1),e=n(160),o=n(2),n=n(872),r=(s=e.c,Object(a.d)(u,s),u.prototype.updateParams=function(t,e){var n;null!=(n=this._element)&&n.setPantoneConfig(t),this.config=t},u.prototype.exportWidgetData=function(t){return Object(a.b)(this,void 0,void 0,function(){return Object(a.e)(this,function(t){return[2,{color:this.selectedColor}]})})},u.prototype.restoreWidgetFromData=function(e,t){return Object(a.b)(this,void 0,void 0,function(){return Object(a.e)(this,function(t){return e&&this.selectedColor!==e.color&&(this._isRestoring=!0,this._element.setPrevColor(e.color),this.emitChange()),this._isRestoring=!1,[2]})})},u.prototype.updateParamsAsync=function(o,r){return Object(a.b)(this,void 0,void 0,function(){var e,n,i=this;return Object(a.e)(this,function(t){switch(t.label){case 0:return e=Object(a.a)({},o),[4,s.prototype.updateParamsAsync.call(this,e,r)];case 1:return t.sent(),this._src?[3,3]:[4,this._loadResources()];case 2:t.sent(),t.label=3;case 3:return e&&!this._frameIsReady&&this._initIFrame(),[4,(n=this)._getWebComponent()];case 4:return n._element=t.sent(),this._element&&(!e.height||isNaN(Number(e.height))?this._iFrameEl.height="275px":this._iFrameEl.height=e.height.includes("px")?e.height:e.height+"px",this._translations&&this._element.setTranslation(this._translations),e.lang=this.language.slice(0,2),this._element.setPantoneConfig(e),this._element.changed$().subscribe(function(t){console.warn(t),i.selectedColor=t,i.emitChange()}),console.log("upd conf",e)),[2]}})})},u.prototype._loadResources=function(){return Object(a.b)(this,void 0,void 0,function(){var e,n;return Object(a.e)(this,function(t){switch(t.label){case 0:return e=Date.now(),e="".concat(c.a.getPatchedUrl("static/pantone-color-picker/script.html"),"?t=").concat(e),n=this,[4,c.a.loadHtml(e)];case 1:return n._src=t.sent(),this._localize(),[2]}})})},u.prototype._getPickerLocalesFile=function(){return Object(a.b)(this,void 0,void 0,function(){var e;return Object(a.e)(this,function(t){return e=Date.now(),e="".concat(c.a.getPatchedUrl("static/pantone-color-picker/locales.json"),"?t=").concat(e),[2,c.a.loadJson(e)]})})},u.prototype._localize=function(){var s;return Object(a.b)(this,void 0,void 0,function(){var e,n,i,o,r;return Object(a.e)(this,function(t){switch(t.label){case 0:if(this.__isLocalesInited)return[2];if(!(e=null==(s=null==(s=this.driver)?void 0:s.localization)?void 0:s.find(function(t){return"preflight"===t.app}))||"string"!=typeof e.url||""===e.url)return[3,6];t.label=1;case 1:return t.trys.push([1,3,,5]),n=this,[4,c.a.loadJson(e.url+"?ts="+Date.now())];case 2:return n._translations=t.sent(),[3,5];case 3:return i=t.sent(),console.error(i),[4,(i=this)._getPickerLocalesFile()];case 4:return i._translations=t.sent(),[3,5];case 5:return[3,8];case 6:return[4,(o=this)._getPickerLocalesFile()];case 7:o._translations=t.sent(),e&&"object"==typeof e.data&&0!==Object.keys(e.data).length&&(this._translations=-1!==Object.keys(e.data).indexOf(this.language)?c.a.DeepMerge(this._translations,e.data):c.a.DeepMerge(this._translations,((r={})[this.language]=e.data,r))),t.label=8;case 8:return this.__isLocalesInited=!0,[2]}})})},u.prototype._initIFrame=function(){this._iFrameEl=this.querySelectorShadow("#pantone-cp"),this._iframeWin=this._iFrameEl||this._iFrameEl.contentWindow,this._iframeDoc=this._iFrameEl.contentDocument||this._iframeWin.document,this._iframeDoc.write(this._src),this._iframeDoc.write("<style> body{margin: 0} </style>"),this._iframeDoc.write('<div style="width:100%; height:100%">\n <au-pantone-color-picker id="au-pantone-color-picker"></au-pantone-color-picker>\n </div>'),this._frameIsReady=!0},u.prototype._getWebComponent=function(){return Object(a.b)(this,void 0,void 0,function(){var e;return Object(a.e)(this,function(t){switch(t.label){case 0:return this._element?[2,Promise.resolve(this._element)]:[3,1];case 1:return t.trys.push([1,3,,4]),[4,this._waitWebComponent(this._iframeDoc,"au-pantone-color-picker")];case 2:return e=t.sent(),window.Aurigma=Object.assign(window.Aurigma,this._iframeWin.contentWindow.Aurigma),[2,e];case 3:return e=t.sent(),this.showToast(e),[3,4];case 4:return[2]}})})},u.prototype._waitWebComponent=function(o,r){function n(){function i(e,n){setTimeout(function(){var t;o?(t=o.getElementById(r))?e(t):i(e,n):n(new Error("Can't find element. Document not found"))},200)}return i}return new Promise(function(t,e){return n()(t,e)})},Object(a.c)([Object(o.c)(),Object(a.g)("design:type",String)],u.prototype,"format",void 0),Object(a.c)([Object(o.c)(),Object(a.g)("design:type",i)],u.prototype,"config",void 0),Object(a.c)([Object(o.a)("au-widget-pantone-color-picker",n),Object(a.g)("design:paramtypes",[])],u));function u(){var t=s.call(this)||this;return t._isRestoring=!1,t.__isLocalesInited=!1,t._initIFrame=t._initIFrame.bind(t),t}}}]);