@ikas/popup-renderer 1.0.118 → 1.0.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import t from"react";import{observer as n}from"mobx-react";import{getHorizontalAlignment as o,injectFontScript as a,validateEmail as i,validatePhoneNumber as l}from"../../helpers/index.js";import{FormItemTypeEnum as s}from"../../models/modal/step/elements/form/index.js";import u from"../button-element-renderer/index.js";import m from"./input-item-view/index.js";import{CheckboxItemView as c}from"./checkbox-item-view/index.js";import d from"./date-item-view/index.js";import f from"./gender-item-view/index.js";var E=n((function(n){var E=n.element,p=n.popup,v=n.isPreviewMode,C=n.sfProps,I=t.useState(!1);I[0];var M=I[1],h=E,S=h.rows.slice().sort((function(e,r){return e.order-r.order})),g=h.formSettings,R=h.buttonSettings,O=h.bgColor,T={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:o(h.horizontalAlignment),gap:"".concat(g.gapBetweenItems,"px"),padding:"".concat(h.outerVerticalPadding,"px ").concat(h.outerHorizontalPadding,"px"),backgroundColor:O,width:"100%"},_={display:"flex",flexDirection:"row",width:"100%",gap:"".concat(g.gapBetweenItems,"px")},U={flex:1,display:"flex",alignItems:"flex-end",fontFamily:a(g.fontFamily),fontSize:g.fontSize},b=function(){return e(void 0,void 0,void 0,(function(){var e,t,n;return r(this,(function(r){switch(r.label){case 0:return e=p.modal.steps.findIndex((function(e){return e.id===p.modal.selectedStep.id})),t=e===p.modal.steps.length-2,!v&&C&&t?(M(!0),function(){var e=!1;return h.rows.forEach((function(r){r.columns.forEach((function(r){switch(r.type){case s.CUSTOMER_BIRTHDAY:var t=r.formItem;t.required&&!t.value&&(t.required.hasError=!0,e=!0);break;case s.CUSTOMER_EMAIL:case s.CUSTOMER_PHONE:case s.CUSTOMER_NAME:case s.CUSTOMER_SURNAME:var n=r.formItem;if(n.required&&!n.value){if(n.type===s.CUSTOMER_EMAIL&&(null==C?void 0:C.isCustomerLoggedIn))return;n.required.hasError=!0,e=!0}else if(r.type===s.CUSTOMER_EMAIL){var o=i(n.value||"");n.validEmailError.hasError=!o,e=!o}else if(r.type===s.CUSTOMER_PHONE){var a=l(n.value||"");n.validPhoneError.hasError=!a,e=!a}break;case s.CUSTOMER_GENDER:var u=r.formItem,m=u.genders.find((function(e){return e.isSelected}));u.required&&!m&&(u.required.hasError=!0,e=!0);break;case s.CHECKBOX_FORM_ITEM:var c=r.formItem;
|
|
1
|
+
import{__awaiter as e,__generator as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import t from"react";import{observer as n}from"mobx-react";import{getHorizontalAlignment as o,injectFontScript as a,validateEmail as i,validatePhoneNumber as l}from"../../helpers/index.js";import{FormItemTypeEnum as s}from"../../models/modal/step/elements/form/index.js";import u from"../button-element-renderer/index.js";import m from"./input-item-view/index.js";import{CheckboxItemView as c}from"./checkbox-item-view/index.js";import d from"./date-item-view/index.js";import f from"./gender-item-view/index.js";var E=n((function(n){var E=n.element,p=n.popup,v=n.isPreviewMode,C=n.sfProps,I=t.useState(!1);I[0];var M=I[1],h=E,S=h.rows.slice().sort((function(e,r){return e.order-r.order})),g=h.formSettings,R=h.buttonSettings,O=h.bgColor,T={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:o(h.horizontalAlignment),gap:"".concat(g.gapBetweenItems,"px"),padding:"".concat(h.outerVerticalPadding,"px ").concat(h.outerHorizontalPadding,"px"),backgroundColor:O,width:"100%"},_={display:"flex",flexDirection:"row",width:"100%",gap:"".concat(g.gapBetweenItems,"px")},U={flex:1,display:"flex",alignItems:"flex-end",fontFamily:a(g.fontFamily),fontSize:g.fontSize},b=function(){return e(void 0,void 0,void 0,(function(){var e,t,n;return r(this,(function(r){switch(r.label){case 0:return e=p.modal.steps.findIndex((function(e){return e.id===p.modal.selectedStep.id})),t=e===p.modal.steps.length-2,!v&&C&&t?(M(!0),function(){var e=!1;return h.rows.forEach((function(r){r.columns.forEach((function(r){switch(r.type){case s.CUSTOMER_BIRTHDAY:var t=r.formItem;t.required&&!t.value&&(t.required.hasError=!0,e=!0);break;case s.CUSTOMER_EMAIL:case s.CUSTOMER_PHONE:case s.CUSTOMER_NAME:case s.CUSTOMER_SURNAME:var n=r.formItem;if(n.required&&!n.value){if(n.type===s.CUSTOMER_EMAIL&&(null==C?void 0:C.isCustomerLoggedIn))return;n.required.hasError=!0,e=!0}else if(r.type===s.CUSTOMER_EMAIL){var o=i(n.value||"");n.validEmailError.hasError=!o,e=!o}else if(r.type===s.CUSTOMER_PHONE){var a=l(n.value||"");n.validPhoneError.hasError=!a,e=!a}break;case s.CUSTOMER_GENDER:var u=r.formItem,m=u.genders.find((function(e){return e.isSelected}));u.required&&!m&&(u.required.hasError=!0,e=!0);break;case s.CHECKBOX_FORM_ITEM:var c=r.formItem;c.requiredToBeChecked&&!c.isChecked&&(c.requiredToBeChecked.hasError=!0,e=!0)}}))})),e}()?(M(!1),[2]):(n={},h.rows.forEach((function(e){e.columns.forEach((function(e){var r;switch(e.type){case s.CUSTOMER_BIRTHDAY:n.birthday=e.formItem.value;break;case s.CUSTOMER_EMAIL:n.email=e.formItem.value;break;case s.CUSTOMER_GENDER:n.gender=(null===(r=e.formItem.genders.find((function(e){return e.isSelected})))||void 0===r?void 0:r.type)||"";break;case s.CUSTOMER_PHONE:n.phone=e.formItem.value;break;case s.CUSTOMER_NAME:n.firstName=e.formItem.value||"";break;case s.CUSTOMER_SURNAME:n.lastName=e.formItem.value||"";break;case s.CHECKBOX_FORM_ITEM:n.hasPermission=e.formItem.isChecked}}))})),[4,C.onCustomerSave(n)])):[3,2];case 1:r.sent(),M(!1),r.label=2;case 2:return-1!==e&&e<p.modal.steps.length&&(p.modal.selectedStep=p.modal.steps[e+1]),[2]}}))}))},x={width:"".concat(R.width,"%"),minWidth:"fit-content"};return t.createElement("div",{style:T},S.map((function(e,r){return t.createElement("div",{style:_,key:r},e.columns.slice().sort((function(e,r){return e.order-r.order})).map((function(e,r){return t.createElement("div",{style:U,key:r},function(e){switch(e.type){case s.CUSTOMER_EMAIL:case s.CUSTOMER_PHONE:case s.CUSTOMER_NAME:case s.CUSTOMER_SURNAME:var r=e.formItem;if(r.type===s.CUSTOMER_EMAIL&&(null==C?void 0:C.isCustomerLoggedIn)&&!v)return null;var n=void 0;if(e.type===s.CUSTOMER_EMAIL){var o=r;o.validEmailError.hasError&&(n=o.validEmailError.validationErrorMessage)}else if(e.type===s.CUSTOMER_PHONE){var a=r;a.validPhoneError.hasError&&(n=a.validPhoneError.validationErrorMessage)}return t.createElement(m,{formInputSettings:g.formInputSettings,inputLabel:r.inputLabel,isRequired:r.required,onValueChange:function(e){return v?null:r.value=e},placeholder:r.placeholder,updateCurrentInfo:r.updateCurrentInfo,value:r.value||"",validationErrorMessage:n});case s.CUSTOMER_BIRTHDAY:var i=e.formItem;return t.createElement(d,{formInputSettings:g.formInputSettings,inputLabel:i.inputLabel,isRequired:i.required,onValueChange:function(e){return v?null:i.value=e},placeholder:i.placeholder,updateCurrentInfo:i.updateCurrentInfo,value:i.value||""});case s.CUSTOMER_GENDER:var l=e.formItem;return t.createElement(f,{genderFormItem:l,formInputSettings:g.formInputSettings,onValueChange:function(e){return v?null:l.genders.forEach((function(r){r.isSelected=r.label===e}))}});case s.CHECKBOX_FORM_ITEM:return t.createElement(c,{checkboxItem:e.formItem})}}(e))})))})),t.createElement("div",{style:x,onClick:function(e){b(),e.preventDefault(),e.stopPropagation()}},t.createElement(u,{element:R})," "))}));export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__extends as t,__assign as o}from'./../../../../../../ext/tslib/tslib.es6.mjs.js';import{makeObservable as r,observable as n,action as e}from"mobx";import{PopupElementTypeEnum as i,BaseElement as s}from"../base/index.js";import{ButtonElement as a}from"../button/index.js";import{FormSettings as l}from"./form-settings/index.js";import{CustomerNameFormItem as u}from"./customer-name/index.js";import{CustomerSurnameFormItem as d}from"./customer-surname/index.js";import{CustomerEmailFormItem as m}from"./customer-email/index.js";import{CustomerPhoneFormItem as p}from"./customer-phone/index.js";import{CustomerBirthdayFormItem as E}from"./customer-birthday/index.js";import{CustomerGenderFormItem as c}from"./customer-gender/index.js";import{CheckboxFormItem as h}from"./checkbox/index.js";import{CustomerAttributeFormItem as T}from"./customer-attribute/index.js";import{Popup as C}from"../../../../index.js";var M;!function(t){t.CUSTOMER_NAME="CUSTOMER_NAME",t.CUSTOMER_SURNAME="CUSTOMER_SURNAME",t.CUSTOMER_EMAIL="CUSTOMER_EMAIL",t.CUSTOMER_PHONE="CUSTOMER_PHONE",t.CUSTOMER_BIRTHDAY="CUSTOMER_BIRTHDAY",t.CUSTOMER_GENDER="CUSTOMER_GENDER",t.CHECKBOX_FORM_ITEM="CHECKBOX_FORM_ITEM",t.CUSTOMER_ATTRIBUTE="CUSTOMER_ATTRIBUTE"}(M||(M={}));var f=function(o){function s(t,s){void 0===t&&(t={});var u,d,m,p,E=this;return(E=o.call(this,t)||this).type=i.FORM,E.rows=t.rows?t.rows.map((function(t){return new R(t)})):[],E.formSettings=t.formSettings||new l,E.buttonSettings=t.buttonSettings||new a({outerHorizontalPadding:0,outerVerticalPadding:0,buttonBgColor:"#000000",borderColor:"#000000"}),E.bgColor=t.bgColor||"",E.outerVerticalPadding=null!==(u=t.outerVerticalPadding)&&void 0!==u?u:
|
|
1
|
+
import{__extends as t,__assign as o}from'./../../../../../../ext/tslib/tslib.es6.mjs.js';import{makeObservable as r,observable as n,action as e}from"mobx";import{PopupElementTypeEnum as i,BaseElement as s}from"../base/index.js";import{ButtonElement as a}from"../button/index.js";import{FormSettings as l}from"./form-settings/index.js";import{CustomerNameFormItem as u}from"./customer-name/index.js";import{CustomerSurnameFormItem as d}from"./customer-surname/index.js";import{CustomerEmailFormItem as m}from"./customer-email/index.js";import{CustomerPhoneFormItem as p}from"./customer-phone/index.js";import{CustomerBirthdayFormItem as E}from"./customer-birthday/index.js";import{CustomerGenderFormItem as c}from"./customer-gender/index.js";import{CheckboxFormItem as h}from"./checkbox/index.js";import{CustomerAttributeFormItem as T}from"./customer-attribute/index.js";import{Popup as C}from"../../../../index.js";var M;!function(t){t.CUSTOMER_NAME="CUSTOMER_NAME",t.CUSTOMER_SURNAME="CUSTOMER_SURNAME",t.CUSTOMER_EMAIL="CUSTOMER_EMAIL",t.CUSTOMER_PHONE="CUSTOMER_PHONE",t.CUSTOMER_BIRTHDAY="CUSTOMER_BIRTHDAY",t.CUSTOMER_GENDER="CUSTOMER_GENDER",t.CHECKBOX_FORM_ITEM="CHECKBOX_FORM_ITEM",t.CUSTOMER_ATTRIBUTE="CUSTOMER_ATTRIBUTE"}(M||(M={}));var f=function(o){function s(t,s){void 0===t&&(t={});var u,d,m,p,E=this;return(E=o.call(this,t)||this).type=i.FORM,E.rows=t.rows?t.rows.map((function(t){return new R(t)})):[],E.formSettings=t.formSettings||new l,E.buttonSettings=t.buttonSettings||new a({outerHorizontalPadding:0,outerVerticalPadding:0,buttonBgColor:"#000000",borderColor:"#000000"}),E.bgColor=t.bgColor||"",E.outerVerticalPadding=null!==(u=t.outerVerticalPadding)&&void 0!==u?u:10,E.outerHorizontalPadding=null!==(d=t.outerHorizontalPadding)&&void 0!==d?d:0,E.verticalPadding=null!==(m=t.verticalPadding)&&void 0!==m?m:0,E.horizontalPadding=null!==(p=t.horizontalPadding)&&void 0!==p?p:0,r(E,{rows:n,formSettings:n,buttonSettings:n,bgColor:n,addNewElement:e.bound}),0===E.rows.length&&1===s&&E.addNewElement(M.CUSTOMER_EMAIL),E}return t(s,o),s.prototype.addNewElement=function(t){var o=new R({order:this.rows.length,columns:[new w({type:t,order:0})]});this.rows.push(o)},s}(s),R=function(){function t(t){var o;void 0===t&&(t={}),this.id=t.id||Date.now().toString(),this.order=null!==(o=t.order)&&void 0!==o?o:0,this.columns=t.columns?t.columns.map((function(t){return new w(t)})):[],r(this,{id:n,order:n,columns:n,addNewElement:e.bound,changeColumnSort:e.bound})}return t.prototype.addNewElement=function(t){this.columns.push(new w({type:t,order:this.columns.length}))},t.prototype.changeColumnSort=function(){this.columns.forEach((function(t,o){0===o?t.order=t.order+1:1===o&&(t.order=t.order-1)})),this.columns=this.columns.sort((function(t,o){return t.order-o.order}))},t}(),w=function(){function t(t){var o;void 0===t&&(t={}),this.id=t.id||Date.now().toString(),this.order=null!==(o=t.order)&&void 0!==o?o:0,this.type=t.type||M.CUSTOMER_NAME,this.formItem=this.setFormItems(t.formItem),r(this,{id:n,order:n,type:n,formItem:n,setFormItems:e.bound})}return t.prototype.setFormItems=function(t){switch(this.type){case M.CUSTOMER_NAME:return new u(t?o({},t):{inputLabel:new S({text:C.t("popup:initialClassTranslations.firstName")})});case M.CUSTOMER_SURNAME:return new d(t?o({},t):{inputLabel:new S({text:C.t("popup:initialClassTranslations.lastName")})});case M.CUSTOMER_EMAIL:return new m(t?o({},t):{inputLabel:new S({text:C.t("popup:initialClassTranslations.email")})});case M.CUSTOMER_PHONE:return new p(t?o({},t):{inputLabel:new S({text:C.t("popup:initialClassTranslations.phone")})});case M.CUSTOMER_BIRTHDAY:return new E(t?o({},t):{inputLabel:new S({text:C.t("popup:initialClassTranslations.birthday")})});case M.CUSTOMER_GENDER:return new c(t?o({},t):{inputLabel:new S({text:C.t("popup:initialClassTranslations.gender")})});case M.CHECKBOX_FORM_ITEM:return new h(o({},t));case M.CUSTOMER_ATTRIBUTE:return new T(o({},t))}},t}(),S=function(t){void 0===t&&(t={}),this.text=t.text||C.t("popup:initialClassTranslations.inputLabel"),r(this,{text:n})},g=function(t){void 0===t&&(t={}),this.validationErrorMessage=t.validationErrorMessage||C.t("popup:initialClassTranslations.requiredFieldErrorMessage"),this.hasError=t.hasError||!1,r(this,{validationErrorMessage:n,hasError:n})},O=function(t){void 0===t&&(t={}),this.text=t.text||C.t("popup:initialClassTranslations.placeholder"),r(this,{text:n})};export{w as FormColumn,f as FormElement,M as FormItemTypeEnum,R as FormRow,S as InputLabel,O as InputPlaceholder,g as RequiredInput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeObservable as i,observable as o}from"mobx";import{TextElement as t}from"../../text/index.js";import{IkasPopupRendererFontFamily as n}from"../../base/index.js";import{Popup as a}from"../../../../../index.js";var r,e=function(n){void 0===n&&(n={}),this.image=n.image?new
|
|
1
|
+
import{makeObservable as i,observable as o}from"mobx";import{TextElement as t}from"../../text/index.js";import{IkasPopupRendererFontFamily as n}from"../../base/index.js";import{Popup as a}from"../../../../../index.js";var r,e=function(n){void 0===n&&(n={}),this.image=n.image?new l(n.image):new l({}),this.name=n.name?new t(n.name):new t({horizontalPadding:0,verticalPadding:6}),this.discountRatio=n.discountRatio?new t(n.discountRatio):null,this.originalPrice=n.originalPrice?new t(n.originalPrice):new t({horizontalPadding:0,verticalPadding:2,fontSize:14,color:"#697586"}),this.finalPrice=n.finalPrice?new t(n.finalPrice):new t({horizontalPadding:0,verticalPadding:2}),this.button=n.button?new s(n.button):new s({}),i(this,{image:o,name:o,discountRatio:o,originalPrice:o,finalPrice:o,button:o})},l=function(t){var n,a;this.bgColor=t.bgColor||"",this.maxWidth=null!==(n=t.maxWidth)&&void 0!==n?n:100,this.borderRadius=null!==(a=t.borderRadius)&&void 0!==a?a:0,i(this,{bgColor:o,maxWidth:o,borderRadius:o})},d=function(t){var a;void 0===t&&(t={}),this.color=t.color||"#000000",this.bgColor=t.bgColor||"",this.fontFamily=new n(t.fontFamily),this.fontSize=null!==(a=t.fontSize)&&void 0!==a?a:24,i(this,{color:o,bgColor:o,fontFamily:o,fontSize:o})};!function(i){i.ADD_TO_CART="ADD_TO_CART",i.NAVIGATE_TO_PRODUCT_DETAIL="NAVIGATE_TO_PRODUCT_DETAIL"}(r||(r={}));var s=function(t){void 0===t&&(t={}),this.text=t.text||a.t("popup:initialClassTranslations.productButtonText"),this.action=t.action||r.ADD_TO_CART,i(this,{text:o,action:o})};export{r as ProductActionTypeEnum,s as ProductButtonSettings,e as ProductDetailSettings,d as ProductDiscountRatioSettings,l as ProductImageSettings};
|