@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
1 lines • 6.12 kB
JavaScript
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[11],{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),r=i(1),o=i(448),l=i(423);class a extends o.a{init(i){super.init(i);var e=this._copySelection();this.items=i.values.map((e,t)=>(!r.a.isNullOrUndefined(e.id)&&-1!==e.id||(e.id=t),"image"!==i.type&&e.imageUrl&&(e.imageUrl=null),new l.a(e,e.disabled))),r.a.isNotNullOrUndefined(e)&&this._restoreSelection(e),this.enableFilter=r.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 r.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)},461:function(e,t,i){i.d(t,"a",function(){return o});var t=i(0),n=i(431),r=i(423),i=i(2);class o extends n.a{init(e){if(super.init(e),0!==this.items.length){let e=this.items.find(e=>e.optionValue.preselected);e=(e=e||this.items.find(e=>0===e.price))||this.items[0],this.value=e}}_selectedChange(t){0<this.items.length&&(this.value=this.items.find(e=>e.id===t))}_valueChange(e){e&&0<this.items.length&&this._selectedId!==e.id&&(this._selectedId=e.id),this._onOptionChange()}updateSelectedValue(t){if(1<t.length)throw new Error("Multiple option value is not available");var e=t.length?this.items.find(e=>e.id===t[0].id):null;(this.value&&!e||!this.value&&e||this.value&&e&&this.value.id!==e.id)&&(this.value=e)}}Object(t.a)([Object(i.c)({notify:!0}),Object(t.b)("design:type",Number)],o.prototype,"_selectedId",void 0),Object(t.a)([Object(i.b)("_selectedId"),Object(t.b)("design:type",Function),Object(t.b)("design:paramtypes",[Number]),Object(t.b)("design:returntype",void 0)],o.prototype,"_selectedChange",null),Object(t.a)([Object(i.b)("value"),Object(t.b)("design:type",Function),Object(t.b)("design:paramtypes",[r.a]),Object(t.b)("design:returntype",void 0)],o.prototype,"_valueChange",null)},878:function(e,t){e.exports='<style>\n :host {\n width: 100%;\n }\n\n iron-selector {\n display: inline-flex;\n flex-direction: row;\n flex-wrap: wrap;\n }\n\n .item {\n align-items: center;\n position: relative;\n margin: 4px 12px 4px 0px;\n cursor: pointer;\n }\n\n .item-description {\n text-align: center;\n width: 60px;\n overflow: hidden;\n word-break: break-word;\n hyphens: manual;\n }\n\n .item-title {\n @apply --au-caption-font;\n }\n\n .item.iron-selected .item-title {\n color: var(--active-option-text-color, --theme-primary-color);\n }\n\n .item.iron-selected .item-selection-frame {\n border-color: var(--active-border-color, --theme-primary-color);\n border-radius: var(--border-radius);\n }\n\n .item-selection-frame {\n border: var(--theme-secondary-color) 2px solid;\n display: inline-block;\n padding: 8px;\n }\n\n .item-disabled {\n pointer-events: none;\n opacity: 0.4;\n }\n\n .item {\n background-color: var(--inactive-item-bg, --theme-background-color);\n border: var(--inactive-border-color, --theme-secondary-color) 2px solid;\n }\n .item>div>span {\n color: var(--inactive-option-text-color, black);\n }\n .item.iron-selected {\n background-color: var(--active-item-bg, --theme-background-color);\n border: var(--active-border-color, --theme-primary-color) 2px solid;\n }\n .item.iron-selected>div>span {\n color: var(--active-option-text-color, --theme-primary-color);\n }\n</style>\n\n<iron-selector name="option" class="radio-rect-item" attr-for-selected="name" selected="{{_selectedId}}">\n <dom-repeat items="[[items]]">\n <template>\n <div tabindex="1" role="menuitemradio" name="{{item.id}}" class$="item [[_disabledClass(item.disabled)]]"\n title$="[[item.title]]">\n <div class="item-selection-frame">\n <span class="item-title">[[_getItemPriceTitle(item)]]</span>\n </div>\n </div>\n </template>\n </dom-repeat>\n</iron-selector>\n'},918:function(e,t,i){i.r(t),i.d(t,"AuRadioOptionCompact",function(){return a}),i.d(t,"option",function(){return a});let n=i(0),r=i(878),o=i(461),l=i(2),a=class extends o.a{};a=Object(n.a)([Object(l.a)("au-option-radio-group-compact",r)],a)}}]);