UNPKG

@aurigma/ui-framework

Version:

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

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