UNPKG

@aurigma/ui-framework

Version:

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

1 lines 6.71 kB
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[5],{423:function(e,t,i){i.d(t,"a",function(){return n});class n{constructor(e,t=!1){this._title=null,this.optionValue=e,this.disabled=t}equals(e){return this.id===e.id&&this.title===e.title&&this.price===e.price}get value(){return this.optionValue}get id(){return this.optionValue.id}get title(){return null==this._title&&(this._title=this._getParsedTitle()),this._title}get price(){return this.optionValue.price}get color(){return this.optionValue.color}get imageUrl(){return this.optionValue.imageUrl}get props(){return this.optionValue.props}get shownPrice(){return this.optionValue.shownPrice}get preselected(){return this.optionValue.preselected}_getParsedTitle(){try{return(new DOMParser).parseFromString(this.optionValue.title,"text/html").body.innerText}catch(e){}return this.optionValue.title}}},431:function(e,t,i){i.d(t,"a",function(){return a});var t=i(0),n=i(2),s=i(1),l=i(448),r=i(423);class a extends l.a{init(i){super.init(i);var e=this._copySelection();this.items=i.values.map((e,t)=>(!s.a.isNullOrUndefined(e.id)&&-1!==e.id||(e.id=t),"image"!==i.type&&e.imageUrl&&(e.imageUrl=null),new r.a(e,e.disabled))),s.a.isNotNullOrUndefined(e)&&this._restoreSelection(e),this.enableFilter=s.a.isNotNullOrUndefined(i.props)&&i.props.enableFilter||!1,i.onAvailableOptionValueChange&&i.onAvailableOptionValueChange.subscribe((e,t)=>this.updateItemsAvailability(t)),i.onOptionValueChange&&i.onOptionValueChange.subscribe((e,t)=>this.updateSelectedValue(t))}_copySelection(){return s.a.isNotNullOrUndefined(this.value)?Object.assign({},this.value):void 0}_restoreSelection(t){this.value=this.items.find(e=>e.equals(t))}_isArrayEqual(e,i){return e.length===i.length&&e.every((e,t)=>e===i[t])}_getItemPriceTitle(e){var t=e=>e&&0!==e?" (+"+this.driver.cart.formatPrice(e)+")":"";let i=t(e.price);return null!=e.shownPrice&&(i=t(e.shownPrice*(this.driver.orders.current._priceMultiplier||1))),e.title+i}_isOptionDisabled(e){return this.disabled||e}updateItemsAvailability(e){for(let t=0;t<this.items.length;t++){var i=e.every(e=>e.id!==this.items[t].id);this.set(`items.${t}.disabled`,i)}}_disabledClass(e){return e?"item-disabled":""}}Object(t.a)([Object(n.c)(),Object(t.b)("design:type",Array)],a.prototype,"items",void 0),Object(t.a)([Object(n.c)({notify:!0}),Object(t.b)("design:type",Boolean)],a.prototype,"enableFilter",void 0)},596:function(e,t,i){i.d(t,"a",function(){return a});var t=i(0),n=i(18),s=i(34),l=i(2),r=i(1),i=i(431);class a extends i.a{init(t){if(super.init(t),this.maxSelectedItems=r.a.objectDeepValue(t,"props.maxCount")?t.props.maxCount:-1,0!==this.items.length&&r.a.isNullOrUndefined(this.value)){let e=this.items.filter(e=>e.optionValue.preselected);0===e.length&&(t=this.items.find(e=>0===e.price),e=t?[t]:[]),0===e.length&&(e=[this.items[0]]),this.value=e}}updateSelectedValue(e){var t,i,n=this.value.filter(t=>e.some(e=>t.value&&e.id===t.value.id));t=n,i=this.value,t.length===i.length&&!t.some(t=>i.every(e=>e.id!==t.optionValue.id))||(this.deselect(this.value),this.select(n),this.value=n)}_copySelection(){return r.a.isNotNullOrUndefined(this.value)?Array.from(this.value):void 0}_restoreSelection(e){var t=this.items.filter(t=>e.some(e=>e.equals(t)));this.select(t)}_maxSelectionItemsChanged(){-1<this.maxSelectedItems&&this.value.length>this.maxSelectedItems&&this.deselect(Array.of(this.getLastSelectedItem()))}_valueChange(e){this._valueObserver(this.value)}_valueObserver(e){this._debouncerValueObserver=s.a.debounce(this._debouncerValueObserver,n.d.after(20),()=>{this._maxSelectionItemsChanged(),this._onOptionChange()})}}Object(t.a)([Object(l.b)("maxSelectedItems"),Object(t.b)("design:type",Function),Object(t.b)("design:paramtypes",[]),Object(t.b)("design:returntype",void 0)],a.prototype,"_maxSelectionItemsChanged",null),Object(t.a)([Object(l.b)("value.splices"),Object(t.b)("design:type",Function),Object(t.b)("design:paramtypes",[Object]),Object(t.b)("design:returntype",void 0)],a.prototype,"_valueChange",null),Object(t.a)([Object(l.c)(),Object(t.b)("design:type",Array)],a.prototype,"value",void 0),Object(t.a)([Object(l.b)("value"),Object(t.b)("design:type",Function),Object(t.b)("design:paramtypes",[Object]),Object(t.b)("design:returntype",void 0)],a.prototype,"_valueObserver",null),Object(t.a)([Object(l.c)(),Object(t.b)("design:type",Object)],a.prototype,"maxSelectedItems",void 0)},879:function(e,t){e.exports='<style>\n :host {\n display: inline-flex;\n width: 100%;\n overflow: hidden;\n flex-direction: column;\n }\n\n iron-selector {\n display: inline-flex;\n flex-direction: column;\n margin-left: -12px;\n margin-right: -12px;\n }\n\n .text {\n @apply --au-body2-font;\n }\n\n paper-checkbox {\n padding: 12px;\n --paper-checkbox-checked-color: var(--theme-primary-color);\n }\n</style>\n<iron-selector noink name="option" class="option-checkbox-container" attr-for-selected="name" multi="true"\n selected-values="{{_selectedIds}}" on-selected-changed="_onOptionChange" selected-attribute="checked">\n <template is="dom-repeat" items="[[items]]">\n <paper-checkbox noink type="value" disabled$="[[_isOptionDisabled(item.disabled)]]" checked="[[item.preselected]]" name="[[item.id]]">\n <span noink class="text">\n [[_getItemPriceTitle(item)]]\n </span>\n </paper-checkbox>\n </template>\n</iron-selector>'},919:function(e,t,i){i.r(t),i.d(t,"AuCheckBoxGroup",function(){return a}),i.d(t,"option",function(){return a});let n=i(0),s=i(2),l=i(596),r=i(879),a=class extends l.a{init(e){super.init(e),this._selectedIds=this.items.filter(e=>e.preselected).map(e=>e.id)}getLastSelectedItem(){return this.value.find(e=>e.id===this._selectedIds[0])}select(e){e.forEach(e=>{this.push("_selectedIds",e.id)})}deselect(e){e.forEach(e=>{e=this._selectedIds.indexOf(e.id);0<=e&&this.splice("_selectedIds",e,1)})}_valueChange(){this.value&&0<this.value.length&&(this._selectedIds=this.value.map(e=>null==(e=e.optionValue)?void 0:e.id))}_selectedIdsChange(e){e&&0<this.items.length&&(this.value=this.items.filter(e=>-1<this._selectedIds.indexOf(e.id)))}};Object(n.a)([Object(s.b)("value.splices"),Object(n.b)("design:type",Function),Object(n.b)("design:paramtypes",[]),Object(n.b)("design:returntype",void 0)],a.prototype,"_valueChange",null),Object(n.a)([Object(s.b)("_selectedIds.splices"),Object(n.b)("design:type",Function),Object(n.b)("design:paramtypes",[Object]),Object(n.b)("design:returntype",void 0)],a.prototype,"_selectedIdsChange",null),a=Object(n.a)([Object(s.a)("au-option-checkbox-group",r)],a)}}]);