UNPKG

@aurigma/ui-framework

Version:

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

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