@ikas/popup-renderer 1.0.117 → 1.0.120

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;console.log("validate",c),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
+ 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{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 d(n.image):new d({}),this.name=n.name?new t(n.name):new t({horizontalPadding:0,verticalPadding:6}),this.discountRatio=n.discountRatio?new t(n.discountRatio):new t({horizontalPadding:0,verticalPadding:8}),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})},d=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})},l=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,l as ProductDiscountRatioSettings,d as ProductImageSettings};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/popup-renderer",
3
- "version": "1.0.117",
3
+ "version": "1.0.120",
4
4
  "description": "",
5
5
  "author": "ucy",
6
6
  "license": "ISC",