@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
1 lines • 10.9 kB
JavaScript
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[37],{448:function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var n=i(0),r=i(93),o=i(2),s=i(20),c=function(e){function t(t){var i=e.call(this)||this;return i.disabled=!1,i.isVisible=!0,i.isActive=!0,i.init(t),i}return Object(n.d)(t,e),t.prototype._onOptionChange=function(){"function"==typeof this.changeCallback&&this.changeCallback()},t.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=((e.subType||[]).length>0?[e.type,e.subType]:[e.type]).join("_")},Object(n.c)([Object(o.c)(),Object(n.g)("design:type",Boolean)],t.prototype,"disabled",void 0),Object(n.c)([Object(o.c)(),Object(n.g)("design:type",String)],t.prototype,"id",void 0),Object(n.c)([Object(o.c)(),Object(n.g)("design:type",String)],t.prototype,"title",void 0),Object(n.c)([Object(o.c)(),Object(n.g)("design:type",Object)],t.prototype,"order",void 0),Object(n.c)([Object(o.c)(),Object(n.g)("design:type",Object)],t.prototype,"driver",void 0),Object(n.c)([Object(o.c)(),Object(n.g)("design:type",String)],t.prototype,"description",void 0),Object(n.c)([Object(o.c)(),Object(n.g)("design:type",Boolean)],t.prototype,"required",void 0),Object(n.c)([Object(o.c)(),Object(n.g)("design:type",String)],t.prototype,"prompt",void 0),Object(n.c)([Object(o.c)(),Object(n.g)("design:type",Object)],t.prototype,"props",void 0),Object(n.c)([Object(o.c)(),Object(n.g)("design:type",String)],t.prototype,"type",void 0),t}(Object(r.a)(s.a))},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){"use strict";i.r(t),i.d(t,"AuWidgetOption",(function(){return m})),i.d(t,"widget",(function(){return m}));var n,r=i(0),o=i(144),s=i(28),c=i(2),l=i(1),a=i(37),d=i(160),u=i(448),p=function(){function e(){}return e.register=function(e,t){this._dict.has(e)||this._dict.set(e,t)},e.getInstanceFor=function(e){return Object(r.b)(this,void 0,void 0,(function(){var t;return Object(r.e)(this,(function(i){switch(i.label){case 0:return t=((e.subType||[]).length>0?[e.type,e.subType]:[e.type]).join("_"),this._dict.has(t)?[4,this._dict.get(t)()]:[3,2];case 1:return[2,new(i.sent().option)(e)];case 2:throw"Option of type ".concat(t," are not supported!")}}))}))},e._dict=new Map,e}();n=function(){return i.e(10).then(i.bind(null,917))},p.register("radio",n),p.register("radio_detailed",n),n=function(){return i.e(11).then(i.bind(null,918))},p.register("radio_compact",n),n=function(){return i.e(5).then(i.bind(null,919))},p.register("checkbox",n),p.register("checkbox_detailed",n),p.register("checkbox_compact",n),n=function(){return i.e(8).then(i.bind(null,920))},p.register("image",n),p.register("color",n),p.register("image_detailed",n),p.register("color_detailed",n),n=function(){return i.e(9).then(i.bind(null,921))},p.register("image_compact",n),p.register("color_compact",n),n=function(){return Promise.all([i.e(1),i.e(7)]).then(i.bind(null,922))},p.register("list",n),p.register("list_detailed",n),p.register("list_compact",n),n=function(){return Promise.all([i.e(1),i.e(6)]).then(i.bind(null,923))},p.register("multilist",n),p.register("multilist_detailed",n),p.register("multilist_compact",n),n=function(){return i.e(12).then(i.bind(null,943))},p.register("text",n),p.register("text_compact",n),p.register("number",n),p.register("number_compact",n),p.register("textarea",n),p.register("textarea_compact",n);var h=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._firstTimeInit=!0,t._definitionPromise=Promise.resolve(),t._isRestoring=!1,t}return Object(r.d)(t,e),Object.defineProperty(t.prototype,"_",{get:function(){return this.selected},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selected",{get:function(){return a.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}),t.prototype.initParamsResolved=function(t,i){void 0===t&&(t={}),void 0===i&&(i=!1),i&&e.prototype.connectedCallbackResolved.call(this,t)},t.prototype.changedParamsResolved=function(t,i){void 0===t&&(t={}),void 0===i&&(i=!1),i&&e.prototype.changedParamsResolved.call(this,t)},t.prototype.clearSelection=function(){this.element&&(this.element._selectedId&&(this.element._selectedId=null),this.element.value=null)},t.prototype.updateParams=function(e,t){},t.prototype._manageEmptyValuesText=function(e){if(this.element){var t=this.element.querySelectorShadow("#emptyValuesMessage"),i=e&&0==(this.element.items||[]).length;t&&(i?t.classList.remove("hidden"):t.classList.add("hidden"))}},Object(r.c)([Object(c.c)(),Object(r.g)("design:type",Object)],t.prototype,"order",void 0),Object(r.c)([Object(c.c)(),Object(r.g)("design:type",String)],t.prototype,"placeholderText",void 0),Object(r.c)([Object(c.c)(),Object(r.g)("design:type",u.a)],t.prototype,"element",void 0),Object(r.c)([Object(c.c)(),Object(r.g)("design:type",Object),Object(r.g)("design:paramtypes",[])],t.prototype,"_",null),Object(r.c)([Object(c.c)(),Object(r.g)("design:type",Object),Object(r.g)("design:paramtypes",[])],t.prototype,"selected",null),t}(d.b),g=h,b=i(849),m=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(r.d)(t,e),t.prototype._definitionChanged=function(e){var t=this;return this._definitionPromise.then((function(){return Object(r.b)(t,void 0,void 0,(function(){var t,i,n=this;return Object(r.e)(this,(function(c){switch(c.label){case 0:return this._isRestoring?[3,2]:l.a.isNotNullOrUndefined(e)?(e.title=e.title?e.title:this.title,t=this.element?this.element.value:null,i=this,[4,p.getInstanceFor(e)]):[3,2];case 1:i.element=c.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",e.emptyValuesText||this.localize("widgets.option.messages.emptyValuesWarning")),t&&this.element.items&&this.element.items.find((function(e){return l.a.objectEquals(e,t)}))&&(this.element.value=t),this.element.changeCallback=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})}((function(){return Object(r.b)(n,void 0,void 0,(function(){var i=this;return Object(r.e)(this,(function(n){switch(n.label){case 0:return this._isRestoring||this.emitChange({selected:this.selected}),e.initWithEmptyValue?[3,2]:[4,this.order.choices.update(e,this.selected)];case 1:n.sent(),n.label=2;case 2:return this.querySelectorShadow("#placeholder").hidden=null!==this.element.value,this.selected&&this.selected.onSelect&&(null===t||t&&t.optionValue!==this.selected)&&l.a.setTimeoutWrapper((function(){return Object(r.b)(i,void 0,void 0,(function(){var e,t,i,n,o,s,c,a;return Object(r.e)(this,(function(d){switch(d.label){case 0:e=l.a.getWizardElement(),t=Object.entries(e.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(r.k)(t),o=n.next();!o.done;o=n.next())(s=o.value).actionsFinishedPromise&&i.push(s.actionsFinishedPromise.promise)}catch(u){c={error:u}}finally{try{o&&!o.done&&(a=n.return)&&a.call(n)}finally{if(c)throw c.error}}return[4,Promise.all(i)];case 1:return d.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(e,!0),this._manageEmptyValuesText(e.applyEmptyValues||!1),c.label=2;case 2:return[2,this.element]}}))}))}))},t.prototype.exportWidgetData=function(e){return Object(r.b)(this,void 0,void 0,(function(){return Object(r.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]}))}))},t.prototype.restoreWidgetFromData=function(e,t){return Object(r.b)(this,void 0,void 0,(function(){var t=this;return Object(r.e)(this,(function(i){return setTimeout((function(){e&&(t._isRestoring=!0,e.selected&&Array.isArray(e.selected)&&t.element.items&&t.element.items.length>0?e.selected.forEach((function(e){t.element.value=t.element.items.filter((function(t){return e.optionValue.id===t.optionValue.id}))})):e.selected&&t.element.items&&t.element.items.length>0?t.element.value=t.element.items.find((function(t){return t.optionValue.title===e.selected.optionValue.title})):"string"==typeof e.selected?t.element.value=e.selected:t.element.value=null),t._isRestoring=!1}),200),[2]}))}))},t.prototype.updateParams=function(e,t){var i=this,n=l.a.getOrDefault("this.order.product.id",void 0);if(this.order=null!==e.orderIndex&&void 0!==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){var r=e.applyEmptyValues&&0==(e.values||[]).length,o=r?e:this.order.product.addOrUpdateOption(e,this._firstTimeInit);r&&this.clearSelection(),e.initWithEmptyValue&&(this.clearSelection(),this.placeholderText=e.placeholderText),this._definitionChanged(o).then((function(){e.hidden?i.element.setAttribute("hidden","true"):i.element.removeAttribute("hidden")})),this._firstTimeInit=!1,e.onChange&&(this._onChange=l.a.functionWrapperConstructor(e.onChange))}},Object(r.c)([Object(c.c)(),Object(r.g)("design:type",Object)],t.prototype,"definition",void 0),Object(r.c)([Object(c.b)("definition"),Object(r.g)("design:type",Function),Object(r.g)("design:paramtypes",[Object]),Object(r.g)("design:returntype",void 0)],t.prototype,"_definitionChanged",null),Object(r.c)([Object(c.a)("au-widget-option",b)],t)}(g)}}]);