UNPKG

@aurigma/ui-framework

Version:

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

1 lines 8.6 kB
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[5],{423:function(e,t,n){n.d(t,"a",function(){return i});o.prototype.equals=function(e){return this.id===e.id&&this.title===e.title&&this.price===e.price},Object.defineProperty(o.prototype,"value",{get:function(){return this.optionValue},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"id",{get:function(){return this.optionValue.id},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return null==this._title&&(this._title=this._getParsedTitle()),this._title},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"price",{get:function(){return this.optionValue.price},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"color",{get:function(){return this.optionValue.color},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"imageUrl",{get:function(){return this.optionValue.imageUrl},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"props",{get:function(){return this.optionValue.props},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"shownPrice",{get:function(){return this.optionValue.shownPrice},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"preselected",{get:function(){return this.optionValue.preselected},enumerable:!1,configurable:!0}),o.prototype._getParsedTitle=function(){try{return(new DOMParser).parseFromString(this.optionValue.title,"text/html").body.innerText}catch(e){}return this.optionValue.title};var i=o;function o(e,t){void 0===t&&(t=!1),this._title=null,this.optionValue=e,this.disabled=t}},431:function(e,t,n){n.d(t,"a",function(){return s});var o,i=n(0),t=n(2),r=n(1),c=n(448),l=n(423),s=(o=c.a,Object(i.d)(u,o),u.prototype.init=function(n){var i=this,e=(o.prototype.init.call(this,n),this._copySelection());this.items=n.values.map(function(e,t){return!r.a.isNullOrUndefined(e.id)&&-1!==e.id||(e.id=t),"image"!==n.type&&e.imageUrl&&(e.imageUrl=null),new l.a(e,e.disabled)}),r.a.isNotNullOrUndefined(e)&&this._restoreSelection(e),this.enableFilter=r.a.isNotNullOrUndefined(n.props)&&n.props.enableFilter||!1,n.onAvailableOptionValueChange&&n.onAvailableOptionValueChange.subscribe(function(e,t){return i.updateItemsAvailability(t)}),n.onOptionValueChange&&n.onOptionValueChange.subscribe(function(e,t){return i.updateSelectedValue(t)})},u.prototype._copySelection=function(){return r.a.isNotNullOrUndefined(this.value)?Object(i.a)({},this.value):void 0},u.prototype._restoreSelection=function(t){this.value=this.items.find(function(e){return e.equals(t)})},u.prototype._isArrayEqual=function(e,n){return e.length===n.length&&e.every(function(e,t){return e===n[t]})},u.prototype._getItemPriceTitle=function(e){function t(e){return e&&0!==e?" (+"+n.driver.cart.formatPrice(e)+")":""}var n=this,i=t(e.price);return null!=e.shownPrice&&(i=t(e.shownPrice*(this.driver.orders.current._priceMultiplier||1))),e.title+i},u.prototype._isOptionDisabled=function(e){return this.disabled||e},u.prototype.updateItemsAvailability=function(n){for(var i=this,o=this,e=0;e<this.items.length;e++)(t=>{var e=n.every(function(e){return e.id!==i.items[t].id});o.set("items.".concat(t,".disabled"),e)})(e)},u.prototype._disabledClass=function(e){return e?"item-disabled":""},Object(i.c)([Object(t.c)(),Object(i.g)("design:type",Array)],u.prototype,"items",void 0),Object(i.c)([Object(t.c)({notify:!0}),Object(i.g)("design:type",Boolean)],u.prototype,"enableFilter",void 0),u);function u(){return null!==o&&o.apply(this,arguments)||this}},596:function(e,t,n){n.d(t,"a",function(){return s});var i,t=n(0),o=n(18),r=n(34),c=n(2),l=n(1),n=n(431),s=(i=n.a,Object(t.d)(u,i),u.prototype.init=function(e){var t;i.prototype.init.call(this,e),this.maxSelectedItems=l.a.objectDeepValue(e,"props.maxCount")?e.props.maxCount:-1,0!==this.items.length&&l.a.isNullOrUndefined(this.value)&&(0===(e=0===(e=this.items.filter(function(e){return e.optionValue.preselected})).length?(t=this.items.find(function(e){return 0===e.price}))?[t]:[]:e).length&&(e=[this.items[0]]),this.value=e)},u.prototype.updateSelectedValue=function(e){var t,n,i=this.value.filter(function(t){return e.some(function(e){return t.value&&e.id===t.value.id})});t=i,n=this.value,t.length===n.length&&!t.some(function(t){return n.every(function(e){return e.id!==t.optionValue.id})})||(this.deselect(this.value),this.select(i),this.value=i)},u.prototype._copySelection=function(){return l.a.isNotNullOrUndefined(this.value)?Array.from(this.value):void 0},u.prototype._restoreSelection=function(e){var t=this.items.filter(function(t){return e.some(function(e){return e.equals(t)})});this.select(t)},u.prototype._maxSelectionItemsChanged=function(){-1<this.maxSelectedItems&&this.value.length>this.maxSelectedItems&&this.deselect(Array.of(this.getLastSelectedItem()))},u.prototype._valueChange=function(e){this._valueObserver(this.value)},u.prototype._valueObserver=function(e){var t=this;this._debouncerValueObserver=r.a.debounce(this._debouncerValueObserver,o.d.after(20),function(){t._maxSelectionItemsChanged(),t._onOptionChange()})},Object(t.c)([Object(c.b)("maxSelectedItems"),Object(t.g)("design:type",Function),Object(t.g)("design:paramtypes",[]),Object(t.g)("design:returntype",void 0)],u.prototype,"_maxSelectionItemsChanged",null),Object(t.c)([Object(c.b)("value.splices"),Object(t.g)("design:type",Function),Object(t.g)("design:paramtypes",[Object]),Object(t.g)("design:returntype",void 0)],u.prototype,"_valueChange",null),Object(t.c)([Object(c.c)(),Object(t.g)("design:type",Array)],u.prototype,"value",void 0),Object(t.c)([Object(c.b)("value"),Object(t.g)("design:type",Function),Object(t.g)("design:paramtypes",[Object]),Object(t.g)("design:returntype",void 0)],u.prototype,"_valueObserver",null),Object(t.c)([Object(c.c)(),Object(t.g)("design:type",Object)],u.prototype,"maxSelectedItems",void 0),u);function u(){return null!==i&&i.apply(this,arguments)||this}},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,n){n.r(t),n.d(t,"AuCheckBoxGroup",function(){return c}),n.d(t,"option",function(){return c});var i,t=n(0),o=n(2),r=n(596),n=n(879),c=(i=r.a,Object(t.d)(l,i),l.prototype.init=function(e){i.prototype.init.call(this,e),this._selectedIds=this.items.filter(function(e){return e.preselected}).map(function(e){return e.id})},l.prototype.getLastSelectedItem=function(){var t=this;return this.value.find(function(e){return e.id===t._selectedIds[0]})},l.prototype.select=function(e){var t=this;e.forEach(function(e){t.push("_selectedIds",e.id)})},l.prototype.deselect=function(e){var t=this;e.forEach(function(e){e=t._selectedIds.indexOf(e.id);0<=e&&t.splice("_selectedIds",e,1)})},l.prototype._valueChange=function(){this.value&&0<this.value.length&&(this._selectedIds=this.value.map(function(e){return null==(e=e.optionValue)?void 0:e.id}))},l.prototype._selectedIdsChange=function(e){var t=this;e&&0<this.items.length&&(this.value=this.items.filter(function(e){return-1<t._selectedIds.indexOf(e.id)}))},Object(t.c)([Object(o.b)("value.splices"),Object(t.g)("design:type",Function),Object(t.g)("design:paramtypes",[]),Object(t.g)("design:returntype",void 0)],l.prototype,"_valueChange",null),Object(t.c)([Object(o.b)("_selectedIds.splices"),Object(t.g)("design:type",Function),Object(t.g)("design:paramtypes",[Object]),Object(t.g)("design:returntype",void 0)],l.prototype,"_selectedIdsChange",null),Object(t.c)([Object(o.a)("au-option-checkbox-group",n)],l));function l(){return null!==i&&i.apply(this,arguments)||this}}}]);