UNPKG

@aurigma/ui-framework

Version:

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

1 lines 8.98 kB
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[37],{448:function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var s=i(0),n=i(93),r=i(2),l=i(20);class o extends(Object(n.a)(l.a)){constructor(e){super(),this.disabled=!1,this.isVisible=!0,this.isActive=!0,this.init(e)}_onOptionChange(){"function"==typeof this.changeCallback&&this.changeCallback()}init(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(s.a)([Object(r.c)(),Object(s.b)("design:type",Boolean)],o.prototype,"disabled",void 0),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",String)],o.prototype,"id",void 0),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",String)],o.prototype,"title",void 0),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",Object)],o.prototype,"order",void 0),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",Object)],o.prototype,"driver",void 0),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",String)],o.prototype,"description",void 0),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",Boolean)],o.prototype,"required",void 0),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",String)],o.prototype,"prompt",void 0),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",Object)],o.prototype,"props",void 0),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",String)],o.prototype,"type",void 0)},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 g})),i.d(t,"widget",(function(){return g}));var s=i(0),n=i(144),r=i(28),l=i(2),o=i(1),a=i(37),c=i(160),d=i(448);class h{static register(e,t){this._dict.has(e)||this._dict.set(e,t)}static async getInstanceFor(e){const t=((e.subType||[]).length>0?[e.type,e.subType]:[e.type]).join("_");if(this._dict.has(t))return new((await this._dict.get(t)()).option)(e);throw`Option of type ${t} are not supported!`}}let p;h._dict=new Map,p=()=>i.e(10).then(i.bind(null,917)),h.register("radio",p),h.register("radio_detailed",p),p=()=>i.e(11).then(i.bind(null,918)),h.register("radio_compact",p),p=()=>i.e(5).then(i.bind(null,919)),h.register("checkbox",p),h.register("checkbox_detailed",p),h.register("checkbox_compact",p),p=()=>i.e(8).then(i.bind(null,920)),h.register("image",p),h.register("color",p),h.register("image_detailed",p),h.register("color_detailed",p),p=()=>i.e(9).then(i.bind(null,921)),h.register("image_compact",p),h.register("color_compact",p),p=()=>Promise.all([i.e(1),i.e(7)]).then(i.bind(null,922)),h.register("list",p),h.register("list_detailed",p),h.register("list_compact",p),p=()=>Promise.all([i.e(1),i.e(6)]).then(i.bind(null,923)),h.register("multilist",p),h.register("multilist_detailed",p),h.register("multilist_compact",p),p=()=>i.e(12).then(i.bind(null,943)),h.register("text",p),h.register("text_compact",p),h.register("number",p),h.register("number_compact",p),h.register("textarea",p),h.register("textarea_compact",p);class u extends c.b{constructor(){super(...arguments),this._firstTimeInit=!0,this._definitionPromise=Promise.resolve(),this._isRestoring=!1}get _(){return this.selected}get selected(){return a.Maybe.maybe(this.element&&this.element.value).caseOf({just:e=>Array.isArray(e)?e.map((e=>null==e?void 0:e.optionValue)):e.optionValue||e.value,nothing:()=>null})}initParamsResolved(e={},t=!1){t&&super.connectedCallbackResolved(e)}changedParamsResolved(e={},t=!1){t&&super.changedParamsResolved(e)}clearSelection(){this.element&&(this.element._selectedId&&(this.element._selectedId=null),this.element.value=null)}updateParams(e,t){}_manageEmptyValuesText(e){if(!this.element)return;const t=this.element.querySelectorShadow("#emptyValuesMessage"),i=e&&0==(this.element.items||[]).length;t&&(i?t.classList.remove("hidden"):t.classList.add("hidden"))}}Object(s.a)([Object(l.c)(),Object(s.b)("design:type",Object)],u.prototype,"order",void 0),Object(s.a)([Object(l.c)(),Object(s.b)("design:type",String)],u.prototype,"placeholderText",void 0),Object(s.a)([Object(l.c)(),Object(s.b)("design:type",d.a)],u.prototype,"element",void 0),Object(s.a)([Object(l.c)(),Object(s.b)("design:type",Object),Object(s.b)("design:paramtypes",[])],u.prototype,"_",null),Object(s.a)([Object(l.c)(),Object(s.b)("design:type",Object),Object(s.b)("design:paramtypes",[])],u.prototype,"selected",null);var b=u,m=i(849);let g=class extends b{_definitionChanged(e){return this._definitionPromise.then((async()=>{if(!this._isRestoring&&o.a.isNotNullOrUndefined(e)){e.title=e.title?e.title:this.title;let t=this.element?this.element.value:null;this.element=await h.getInstanceFor(e),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((e=>o.a.objectEquals(e,t)))&&(this.element.value=t),this.element.changeCallback=function(e,t,i){var s=!0,l=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return Object(r.a)(i)&&(s="leading"in i?!!i.leading:s,l="trailing"in i?!!i.trailing:l),Object(n.a)(e,t,{leading:s,maxWait:t,trailing:l})}((async()=>{this._isRestoring||this.emitChange({selected:this.selected}),e.initWithEmptyValue||await this.order.choices.update(e,this.selected),this.querySelectorShadow("#placeholder").hidden=null!==this.element.value,this.selected&&this.selected.onSelect&&(null===t||t&&t.optionValue!==this.selected)&&o.a.setTimeoutWrapper((async()=>{const e=o.a.getWizardElement(),t=Object.entries(e.scope.$).map((e=>e[1])).filter((e=>-1!==["canvas","design-editor"].indexOf(e.tagName.toLowerCase().replace("au-widget-",""))));let i=[];for(const s of t)s.actionsFinishedPromise&&i.push(s.actionsFinishedPromise.promise);await Promise.all(i),this.selected.onSelect()}),10,10),this._onChange&&this._onChange()}),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)}return this.element}))}async exportWidgetData(e){return this.element?(this.element.value&&this.element.value.optionValue&&this.element.value.optionValue.preselected&&(this.element.value.optionValue.preselected=!0),{selected:this.element.value}):null}async restoreWidgetFromData(e,t){setTimeout((()=>{e&&(this._isRestoring=!0,e.selected&&Array.isArray(e.selected)&&this.element.items&&this.element.items.length>0?e.selected.forEach((e=>{this.element.value=this.element.items.filter((t=>e.optionValue.id===t.optionValue.id))})):e.selected&&this.element.items&&this.element.items.length>0?this.element.value=this.element.items.find((({optionValue:t})=>t.title===e.selected.optionValue.title)):"string"==typeof e.selected?this.element.value=e.selected:this.element.value=null),this._isRestoring=!1}),200)}updateParams(e,t){const i=o.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!==i)&&(this._firstTimeInit=!0),this.order&&this.order.product){const t=e.applyEmptyValues&&0==(e.values||[]).length;let i=t?e:this.order.product.addOrUpdateOption(e,this._firstTimeInit);t&&this.clearSelection(),e.initWithEmptyValue&&(this.clearSelection(),this.placeholderText=e.placeholderText),this._definitionChanged(i).then((()=>{e.hidden?this.element.setAttribute("hidden","true"):this.element.removeAttribute("hidden")})),this._firstTimeInit=!1,e.onChange&&(this._onChange=o.a.functionWrapperConstructor(e.onChange))}}};Object(s.a)([Object(l.c)(),Object(s.b)("design:type",Object)],g.prototype,"definition",void 0),Object(s.a)([Object(l.b)("definition"),Object(s.b)("design:type",Function),Object(s.b)("design:paramtypes",[Object]),Object(s.b)("design:returntype",void 0)],g.prototype,"_definitionChanged",null),g=Object(s.a)([Object(l.a)("au-widget-option",m)],g)}}]);