@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
1 lines • 10.7 kB
JavaScript
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[37],{448:function(e,t,i){i.d(t,"a",function(){return s});var n,t=i(0),r=i(93),o=i(2),i=i(20),s=(n=Object(r.a)(i.a),Object(t.d)(c,n),c.prototype._onOptionChange=function(){"function"==typeof this.changeCallback&&this.changeCallback()},c.prototype.init=function(e){this.id=(e.id||Date.now()).toString(),this.title=e.title||"",this.description=e.description||"",this.prompt=e.prompt||"",this.required=e.required,this.props=e.props,this.type=(0<(e.subType||[]).length?[e.type,e.subType]:[e.type]).join("_")},Object(t.c)([Object(o.c)(),Object(t.g)("design:type",Boolean)],c.prototype,"disabled",void 0),Object(t.c)([Object(o.c)(),Object(t.g)("design:type",String)],c.prototype,"id",void 0),Object(t.c)([Object(o.c)(),Object(t.g)("design:type",String)],c.prototype,"title",void 0),Object(t.c)([Object(o.c)(),Object(t.g)("design:type",Object)],c.prototype,"order",void 0),Object(t.c)([Object(o.c)(),Object(t.g)("design:type",Object)],c.prototype,"driver",void 0),Object(t.c)([Object(o.c)(),Object(t.g)("design:type",String)],c.prototype,"description",void 0),Object(t.c)([Object(o.c)(),Object(t.g)("design:type",Boolean)],c.prototype,"required",void 0),Object(t.c)([Object(o.c)(),Object(t.g)("design:type",String)],c.prototype,"prompt",void 0),Object(t.c)([Object(o.c)(),Object(t.g)("design:type",Object)],c.prototype,"props",void 0),Object(t.c)([Object(o.c)(),Object(t.g)("design:type",String)],c.prototype,"type",void 0),c);function c(e){var t=n.call(this)||this;return t.disabled=!1,t.isVisible=!0,t.isActive=!0,t.init(e),t}},849:function(e,t){e.exports='<style>\n :host {\n position: relative;\n display: flex;\n flex: 1 1 auto;\n }\n\n #placeholder {\n position: absolute;\n display: flex;\n width: 100%;\n height: 36px;\n padding: 0 13px;\n box-sizing: border-box;\n flex-direction: row;\n align-items: center;\n color: #999999;\n font-size: var(--default-common-control-font_-_font-size);\n }\n\n [hidden] {\n display: none !important;\n }\n</style>\n<div id="placeholder" hidden>\n [[placeholderText]]\n</div>\n<div replaceable="true"></div>'},929:function(e,t,i){i.r(t),i.d(t,"AuWidgetOption",function(){return y}),i.d(t,"widget",function(){return y});var l=i(0),o=i(144),s=i(28);var n,c=function(e,t,i){var n=!0,r=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return Object(s.a)(i)&&(n="leading"in i?!!i.leading:n,r="trailing"in i?!!i.trailing:r),Object(o.a)(e,t,{leading:n,maxWait:t,trailing:r})},t=i(2),a=i(1),r=i(37),d=i(160),u=i(448),p=(h.register=function(e,t){this._dict.has(e)||this._dict.set(e,t)},h.getInstanceFor=function(i){return Object(l.b)(this,void 0,void 0,function(){var t;return Object(l.e)(this,function(e){switch(e.label){case 0:return(t=(0<(i.subType||[]).length?[i.type,i.subType]:[i.type]).join("_"),this._dict.has(t))?[4,this._dict.get(t)()]:[3,2];case 1:return[2,new(e.sent().option)(i)];case 2:throw"Option of type ".concat(t," are not supported!")}})})},h._dict=new Map,h);function h(){}function g(){var e=null!==n&&n.apply(this,arguments)||this;return e._firstTimeInit=!0,e._definitionPromise=Promise.resolve(),e._isRestoring=!1,e}p.register("radio",m=function(){return i.e(10).then(i.bind(null,917))}),p.register("radio_detailed",m),p.register("radio_compact",function(){return i.e(11).then(i.bind(null,918))}),p.register("checkbox",m=function(){return i.e(5).then(i.bind(null,919))}),p.register("checkbox_detailed",m),p.register("checkbox_compact",m),p.register("image",m=function(){return i.e(8).then(i.bind(null,920))}),p.register("color",m),p.register("image_detailed",m),p.register("color_detailed",m),p.register("image_compact",m=function(){return i.e(9).then(i.bind(null,921))}),p.register("color_compact",m),p.register("list",m=function(){return Promise.all([i.e(1),i.e(7)]).then(i.bind(null,922))}),p.register("list_detailed",m),p.register("list_compact",m),p.register("multilist",m=function(){return Promise.all([i.e(1),i.e(6)]).then(i.bind(null,923))}),p.register("multilist_detailed",m),p.register("multilist_compact",m),p.register("text",m=function(){return i.e(12).then(i.bind(null,943))}),p.register("text_compact",m),p.register("number",m),p.register("number_compact",m),p.register("textarea",m),p.register("textarea_compact",m),n=d.b,Object(l.d)(g,n),Object.defineProperty(g.prototype,"_",{get:function(){return this.selected},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"selected",{get:function(){return r.Maybe.maybe(this.element&&this.element.value).caseOf({just:function(e){return Array.isArray(e)?e.map(function(e){return null==e?void 0:e.optionValue}):e.optionValue||e.value},nothing:function(){return null}})},enumerable:!1,configurable:!0}),g.prototype.initParamsResolved=function(e,t){void 0===e&&(e={}),(t=void 0===t?!1:t)&&n.prototype.connectedCallbackResolved.call(this,e)},g.prototype.changedParamsResolved=function(e,t){void 0===e&&(e={}),(t=void 0===t?!1:t)&&n.prototype.changedParamsResolved.call(this,e)},g.prototype.clearSelection=function(){this.element&&(this.element._selectedId&&(this.element._selectedId=null),this.element.value=null)},g.prototype.updateParams=function(e,t){},g.prototype._manageEmptyValuesText=function(e){var t;this.element&&(t=this.element.querySelectorShadow("#emptyValuesMessage"),e=e&&0==(this.element.items||[]).length,t)&&(e?t.classList.remove("hidden"):t.classList.add("hidden"))},Object(l.c)([Object(t.c)(),Object(l.g)("design:type",Object)],g.prototype,"order",void 0),Object(l.c)([Object(t.c)(),Object(l.g)("design:type",String)],g.prototype,"placeholderText",void 0),Object(l.c)([Object(t.c)(),Object(l.g)("design:type",u.a)],g.prototype,"element",void 0),Object(l.c)([Object(t.c)(),Object(l.g)("design:type",Object),Object(l.g)("design:paramtypes",[])],g.prototype,"_",null),Object(l.c)([Object(t.c)(),Object(l.g)("design:type",Object),Object(l.g)("design:paramtypes",[])],g.prototype,"selected",null);var b,m=g,d=i(849),y=(b=m,Object(l.d)(f,b),f.prototype._definitionChanged=function(r){var e=this;return this._definitionPromise.then(function(){return Object(l.b)(e,void 0,void 0,function(){var i,t,n=this;return Object(l.e)(this,function(e){switch(e.label){case 0:return this._isRestoring?[3,2]:a.a.isNotNullOrUndefined(r)?(r.title=r.title||this.title,i=this.element?this.element.value:null,t=this,[4,p.getInstanceFor(r)]):[3,2];case 1:t.element=e.sent(),this.element.setAttribute("replaceable","true"),this.element.set("driver",this.driver),this.element.set("order",this.order),this.element.language=this.language,this.element.set("emptyValuesText",r.emptyValuesText||this.localize("widgets.option.messages.emptyValuesWarning")),i&&this.element.items&&this.element.items.find(function(e){return a.a.objectEquals(e,i)})&&(this.element.value=i),this.element.changeCallback=c(function(){return Object(l.b)(n,void 0,void 0,function(){var t=this;return Object(l.e)(this,function(e){switch(e.label){case 0:return this._isRestoring||this.emitChange({selected:this.selected}),r.initWithEmptyValue?[3,2]:[4,this.order.choices.update(r,this.selected)];case 1:e.sent(),e.label=2;case 2:return this.querySelectorShadow("#placeholder").hidden=null!==this.element.value,this.selected&&this.selected.onSelect&&(null===i||i&&i.optionValue!==this.selected)&&a.a.setTimeoutWrapper(function(){return Object(l.b)(t,void 0,void 0,function(){var t,i,n,r,o,s,c;return Object(l.e)(this,function(e){switch(e.label){case 0:t=a.a.getWizardElement(),t=Object.entries(t.scope.$).map(function(e){return e[1]}).filter(function(e){return-1!==["canvas","design-editor"].indexOf(e.tagName.toLowerCase().replace("au-widget-",""))}),i=[];try{for(n=Object(l.k)(t),r=n.next();!r.done;r=n.next())(o=r.value).actionsFinishedPromise&&i.push(o.actionsFinishedPromise.promise)}catch(e){s={error:e}}finally{try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(s)throw s.error}}return[4,Promise.all(i)];case 1:return e.sent(),this.selected.onSelect(),[2]}})})},10,10),this._onChange&&this._onChange(),[2]}})})},500),this.shadowRoot.replaceChild(this.element,this.querySelectorShadow("[replaceable]")),this.querySelectorShadow("[replaceable]").style.height="",this.querySelectorShadow("[replaceable]").style.height="100%",this.initParamsResolved({},!0),this.changedParamsResolved(r,!0),this._manageEmptyValuesText(r.applyEmptyValues||!1),e.label=2;case 2:return[2,this.element]}})})})},f.prototype.exportWidgetData=function(e){return Object(l.b)(this,void 0,void 0,function(){return Object(l.e)(this,function(e){return this.element?(this.element.value&&this.element.value.optionValue&&this.element.value.optionValue.preselected&&(this.element.value.optionValue.preselected=!0),[2,{selected:this.element.value}]):[2,null]})})},f.prototype.restoreWidgetFromData=function(t,e){return Object(l.b)(this,void 0,void 0,function(){var i=this;return Object(l.e)(this,function(e){return setTimeout(function(){t&&(i._isRestoring=!0,t.selected&&Array.isArray(t.selected)&&i.element.items&&0<i.element.items.length?t.selected.forEach(function(t){i.element.value=i.element.items.filter(function(e){return t.optionValue.id===e.optionValue.id})}):t.selected&&i.element.items&&0<i.element.items.length?i.element.value=i.element.items.find(function(e){return e.optionValue.title===t.selected.optionValue.title}):"string"==typeof t.selected?i.element.value=t.selected:i.element.value=null),i._isRestoring=!1},200),[2]})})},f.prototype.updateParams=function(e,t){var i=this,n=a.a.getOrDefault("this.order.product.id",void 0);this.order=null!=e.orderIndex?this.driver.cart.lineItems[e.orderIndex]:this.driver.orders.current,(t&&t.orderIndex!==e.orderIndex||this.order&&this.order.product&&this.order.product.id!==n)&&(this._firstTimeInit=!0),this.order&&this.order.product&&(n=(t=e.applyEmptyValues&&0==(e.values||[]).length)?e:this.order.product.addOrUpdateOption(e,this._firstTimeInit),t&&this.clearSelection(),e.initWithEmptyValue&&(this.clearSelection(),this.placeholderText=e.placeholderText),this._definitionChanged(n).then(function(){e.hidden?i.element.setAttribute("hidden","true"):i.element.removeAttribute("hidden")}),this._firstTimeInit=!1,e.onChange)&&(this._onChange=a.a.functionWrapperConstructor(e.onChange))},Object(l.c)([Object(t.c)(),Object(l.g)("design:type",Object)],f.prototype,"definition",void 0),Object(l.c)([Object(t.b)("definition"),Object(l.g)("design:type",Function),Object(l.g)("design:paramtypes",[Object]),Object(l.g)("design:returntype",void 0)],f.prototype,"_definitionChanged",null),Object(l.c)([Object(t.a)("au-widget-option",d)],f));function f(){return null!==b&&b.apply(this,arguments)||this}}}]);