@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
1 lines • 6.89 kB
JavaScript
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[5],{424:function(e,t,i){"use strict";i.d(t,"a",(function(){return s}));class s{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}}},429:function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var s=i(0),n=i(2),l=i(1),r=i(441),a=i(424);class o extends r.a{init(e){super.init(e);const t=this._copySelection();this.items=e.values.map(((t,i)=>((l.a.isNullOrUndefined(t.id)||-1===t.id)&&(t.id=i),"image"!==e.type&&t.imageUrl&&(t.imageUrl=null),new a.a(t,t.disabled)))),l.a.isNotNullOrUndefined(t)&&this._restoreSelection(t),this.enableFilter=l.a.isNotNullOrUndefined(e.props)&&e.props.enableFilter||!1,e.onAvailableOptionValueChange&&e.onAvailableOptionValueChange.subscribe(((e,t)=>this.updateItemsAvailability(t))),e.onOptionValueChange&&e.onOptionValueChange.subscribe(((e,t)=>this.updateSelectedValue(t)))}_copySelection(){return l.a.isNotNullOrUndefined(this.value)?Object.assign({},this.value):void 0}_restoreSelection(e){this.value=this.items.find((t=>t.equals(e)))}_isArrayEqual(e,t){return e.length===t.length&&e.every(((e,i)=>e===t[i]))}_getItemPriceTitle(e){const t=e=>e&&0!==e?" (+"+this.driver.cart.formatPrice(e)+")":"";let i=t(e.price);return null!==e.shownPrice&&void 0!==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++){const i=e.every((e=>e.id!==this.items[t].id));this.set(`items.${t}.disabled`,i)}}_disabledClass(e){return e?"item-disabled":""}}Object(s.a)([Object(n.c)(),Object(s.b)("design:type",Array)],o.prototype,"items",void 0),Object(s.a)([Object(n.c)({notify:!0}),Object(s.b)("design:type",Boolean)],o.prototype,"enableFilter",void 0)},597:function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var s=i(0),n=i(18),l=i(34),r=i(2),a=i(1),o=i(429);class c extends o.a{init(e){if(super.init(e),this.maxSelectedItems=a.a.objectDeepValue(e,"props.maxCount")?e.props.maxCount:-1,0!==this.items.length&&a.a.isNullOrUndefined(this.value)){let e=this.items.filter((e=>e.optionValue.preselected));if(0===e.length){const t=this.items.find((e=>0===e.price));e=t?[t]:[]}0===e.length&&(e=[this.items[0]]),this.value=e}}updateSelectedValue(e){const t=this.value.filter((t=>e.some((e=>t.value&&e.id===t.value.id))));((e,t)=>e.length!==t.length||e.some((e=>t.every((t=>t.id!==e.optionValue.id)))))(t,this.value)&&(this.deselect(this.value),this.select(t),this.value=t)}_copySelection(){return a.a.isNotNullOrUndefined(this.value)?Array.from(this.value):void 0}_restoreSelection(e){let t=this.items.filter((t=>e.some((e=>e.equals(t)))));this.select(t)}_maxSelectionItemsChanged(){this.maxSelectedItems>-1&&this.value.length>this.maxSelectedItems&&this.deselect(Array.of(this.getLastSelectedItem()))}_valueChange(e){this._valueObserver(this.value)}_valueObserver(e){this._debouncerValueObserver=l.a.debounce(this._debouncerValueObserver,n.d.after(20),(()=>{this._maxSelectionItemsChanged(),this._onOptionChange()}))}}Object(s.a)([Object(r.b)("maxSelectedItems"),Object(s.b)("design:type",Function),Object(s.b)("design:paramtypes",[]),Object(s.b)("design:returntype",void 0)],c.prototype,"_maxSelectionItemsChanged",null),Object(s.a)([Object(r.b)("value.splices"),Object(s.b)("design:type",Function),Object(s.b)("design:paramtypes",[Object]),Object(s.b)("design:returntype",void 0)],c.prototype,"_valueChange",null),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",Array)],c.prototype,"value",void 0),Object(s.a)([Object(r.b)("value"),Object(s.b)("design:type",Function),Object(s.b)("design:paramtypes",[Object]),Object(s.b)("design:returntype",void 0)],c.prototype,"_valueObserver",null),Object(s.a)([Object(r.c)(),Object(s.b)("design:type",Object)],c.prototype,"maxSelectedItems",void 0)},880: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>'},918:function(e,t,i){"use strict";i.r(t),i.d(t,"AuCheckBoxGroup",(function(){return a})),i.d(t,"option",(function(){return a}));var s=i(0),n=i(2),l=i(597),r=i(880);let 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=>{let t=this._selectedIds.indexOf(e.id);t>=0&&this.splice("_selectedIds",t,1)}))}_valueChange(){this.value&&this.value.length>0&&(this._selectedIds=this.value.map((e=>{var t;return null===(t=e.optionValue)||void 0===t?void 0:t.id})))}_selectedIdsChange(e){e&&this.items.length>0&&(this.value=this.items.filter((e=>this._selectedIds.indexOf(e.id)>-1)))}};Object(s.a)([Object(n.b)("value.splices"),Object(s.b)("design:type",Function),Object(s.b)("design:paramtypes",[]),Object(s.b)("design:returntype",void 0)],a.prototype,"_valueChange",null),Object(s.a)([Object(n.b)("_selectedIds.splices"),Object(s.b)("design:type",Function),Object(s.b)("design:paramtypes",[Object]),Object(s.b)("design:returntype",void 0)],a.prototype,"_selectedIdsChange",null),a=Object(s.a)([Object(n.a)("au-option-checkbox-group",r)],a)}}]);