UNPKG

@aurigma/ui-framework

Version:

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

1 lines 6.57 kB
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[43],{875:function(e,t){e.exports='<style>\n .content {\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n .content au-widget {\n margin-bottom: var(--group-padding-content-bottom, 30px);\n height: var(--au-widget-height, auto);\n width: var(--au-width, 100%);\n }\n</style>\n\n<div class="content">\n <dom-repeat items="{{options}}" id="repeater">\n <template>\n <au-widget name="{{item.name}}" language="{{language}}" driver="{{driver}}"\n definition="{{item}}"></au-widget>\n </template>\n </dom-repeat>\n</div>\n\n'},932:function(e,t,n){"use strict";n.r(t),n.d(t,"AuWidgetPimOptions",(function(){return d})),n.d(t,"widget",(function(){return d}));var i=n(0),o=n(2),s=n(1),a=n(17),r=n(395),u=n(160),c=n(875),l=function(e,t){var n,o,s=function(n,i){var o=t.find((function(e){return e.id===+n}));Array.isArray(i)?(a.name=o.name,a.value=o.values.filter((function(e){return i.includes(e.id)})).map((function(e){return e.name})),a.visible=e.isVisible):(a.name=o.name,a.value=o.values.find((function(e){return e.id===i})).name,a.visible=e.isVisible)},a=this;try{for(var r=Object(i.k)(Object.entries(e._)),u=r.next();!u.done;u=r.next()){var c=Object(i.h)(u.value,2);s(c[0],c[1])}}catch(l){n={error:l}}finally{try{u&&!u.done&&(o=r.return)&&o.call(r)}finally{if(n)throw n.error}}},p=function(e,t){var n,i,o;this.name=e.name,this.type="pim-option";var s=e.options.find((function(t){return t.name===e.name})),a="true"===(null===(n=s.appearanceDataItems)||void 0===n?void 0:n.find((function(e){return"OptionTooltip"===e.key})).value),r="true"===(null===(i=s.appearanceDataItems)||void 0===i?void 0:i.find((function(e){return"OptionDescription"===e.key})).value),u="true"===(null===(o=s.appearanceDataItems)||void 0===o?void 0:o.find((function(e){return"ValueAdditionText"===e.key})).value);this.params={option:{name:s.name,id:s.id,values:s.values,selected:s.selected,tooltip:a?s.tooltip:null,description:r?s.description:null,isMultiSelect:s.isMultiSelect,showValueAdditionalText:u,type:e.type?e.type:s.type,subType:e.subType?e.subType:null},config:e.config,style:e.style,css:e.css,visible:e.visible,active:e.active,onChange:e.onChange,parentWidgetName:t}},d=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.options=[],t._optionsWidgets=[],t._optionsNames=[],t._optionsAreLoaded=!1,t.isLoading=!1,t}return Object(i.d)(t,e),Object.defineProperty(t.prototype,"_",{get:function(){if(this._optionsWidgets.length>0&&!this.isLoading){var e={};return this._optionsWidgets.forEach((function(t){t.isActive&&Object.assign(e,t._)})),e}return[]},enumerable:!1,configurable:!0}),t.prototype.checkOptionsLoading=function(){this._optionsAreLoaded||0===this.options.length||this.options.length!==this._optionsWidgets.length||(this._optionsAreLoaded=!0,this._onReadyFunction&&this._onReadyFunction())},Object.defineProperty(t.prototype,"summary",{get:function(){var e=this;if(this._optionsWidgets.length>0){var t=[];return this._optionsWidgets.forEach((function(n){(null==n?void 0:n._)&&n.isActive&&t.push(new l(n,e._options))})),t}return[]},enumerable:!1,configurable:!0}),t.prototype.updateParams=function(e){var t,n,o,a=this;if(e&&e.options&&!(e.options.length<1)){this.isLoading=!0,this._options=e.options;var r=[];if(e.onReady&&(this._onReadyFunction=s.a.functionWrapperConstructor(e.onReady)),e.onChange&&(this._onChange=s.a.functionWrapperConstructor(e.onChange)),e.options.length>0){var u=new Map;(null===(t=this.paramsRaw)||void 0===t?void 0:t.modifiers)&&(null===(n=this.paramsRaw)||void 0===n?void 0:n.modifiers.length)>0&&(null===(o=this.paramsRaw)||void 0===o||o.modifiers.forEach((function(e){return u.set(e.name,{type:e.type,subType:e.subType,style:e.style,css:e.css,config:e.config,visible:e.visible,preselectedValue:e.preselectedValue?JSON.parse(JSON.stringify(e.preselectedValue)):void 0,onChange:e.onChange})}))),e.options.forEach((function(t){var n,o,s,c,l=Object(i.j)([],Object(i.h)(e.options),!1),d=u.has(t.name),h=d?u.get(t.name).visible:void 0,v=h,g=1===t.values.length,f=d&&(null===(n=u.get(t.name))||void 0===n?void 0:n.preselectedValue);g&&(v=!1!==h,h=!!h),f&&!g&&(l=l.map((function(e){return Object(i.a)(Object(i.a)({},e),{selected:e.values.filter((function(e){return f===e.name||(null==f?void 0:f.includes(e.name))}))})})),v=!0);var m={name:t.name,options:l,visible:null==h||h,style:d?null===(o=u.get(t.name))||void 0===o?void 0:o.style:null,css:d?null===(s=u.get(t.name))||void 0===s?void 0:s.css:null,active:v,config:d?null===(c=u.get(t.name))||void 0===c?void 0:c.config:null,onChange:d?u.get(t.name).onChange:null,type:d?u.get(t.name).type:null,subType:d?u.get(t.name).subType:null},b=new p(m,a.name);r.push(b)}))}this.options=r,this._optionsNames=this.options.map((function(e){return e.name})),this.isLoading=!1}},t.prototype.updateParamsAsync=function(t){return Object(i.b)(this,void 0,void 0,(function(){return Object(i.e)(this,(function(n){switch(n.label){case 0:return[4,e.prototype.updateParamsAsync.call(this,t)];case 1:return n.sent(),[2]}}))}))},t.prototype.connectedCallback=function(){return Object(i.b)(this,void 0,void 0,(function(){var t=this;return Object(i.e)(this,(function(n){return e.prototype.connectedCallback.call(this),this._subscription=this.observe(a.a.WIDGET_CHANGE).pipe(Object(r.a)((function(e){var n;return t._optionsNames.indexOf(e.name)>=0&&t.name===(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.parentWidgetName)&&!!e.sender._}))).subscribe((function(e){t._updateWidgets(e),t._onChange&&t._onChange(e),t.checkOptionsLoading()})),[2]}))}))},t.prototype._updateWidgets=function(e){return Object(i.b)(this,void 0,void 0,(function(){var t;return Object(i.e)(this,(function(n){return this._optionsWidgets.length>0?((t=this._optionsWidgets.filter((function(t){return t.name!==e.sender.name}))).push(e.sender),this._optionsWidgets=t):this._optionsWidgets.push(e.sender),[2]}))}))},t.prototype.disconnectedCallback=function(){var t;e.prototype.disconnectedCallback.call(this),this._subscription.unsubscribe(),null===(t=this.template)||void 0===t||t.removeEventListener("scroll")},t.prototype.clearSelection=function(){},Object(i.c)([Object(o.c)(),Object(i.g)("design:type",Object)],t.prototype,"options",void 0),Object(i.c)([Object(o.c)(),Object(i.g)("design:type",Object),Object(i.g)("design:paramtypes",[])],t.prototype,"_",null),Object(i.c)([Object(o.a)("au-widget-pim-options",c)],t)}(u.b)}}]);