@ikas/loyalty-widget-renderer 1.0.0-alpha.76 → 1.0.0-alpha.78

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.
package/build/utils.d.ts CHANGED
@@ -1,4 +1,27 @@
1
1
  import React from "react";
2
+ interface WidgetStorageData {
3
+ closedDescriptionSessionId?: string;
4
+ }
5
+ /**
6
+ * Get ikas_session_id from cookies
7
+ */
8
+ export declare const getIkasSessionId: () => string | null;
9
+ /**
10
+ * Get widget storage data from localStorage
11
+ */
12
+ export declare const getWidgetStorage: () => WidgetStorageData;
13
+ /**
14
+ * Set widget storage data to localStorage
15
+ */
16
+ export declare const setWidgetStorage: (data: WidgetStorageData) => void;
17
+ /**
18
+ * Check if description is closed for current session
19
+ */
20
+ export declare const isDescriptionClosedForCurrentSession: () => boolean;
21
+ /**
22
+ * Mark description as closed for current session
23
+ */
24
+ export declare const markDescriptionClosedForSession: () => void;
2
25
  import { LoyaltyWidgetViewModel } from "models";
3
26
  import { LoyaltyProgramEarningMethod } from "models/loyalty-program-earning-method";
4
27
  import { LoyaltyProgramSpendingMethod } from "models/loyalty-program-spending-method";
@@ -10,3 +33,4 @@ export declare const getEarningMethodTitle: (earningMethod: LoyaltyProgramEarnin
10
33
  export declare const getSpendingMethodIcon: (spendingMethod: LoyaltyProgramMethodSpendingTypeEnum, widgetIconType: WidgetIconTypeEnum) => React.JSX.Element | null;
11
34
  export declare const getSpendingMethodTitle: (method: LoyaltyProgramSpendingMethod) => string;
12
35
  export declare const getSpendingMethodDescription: (method: LoyaltyProgramSpendingMethod, viewModel: LoyaltyWidgetViewModel) => string | React.JSX.Element;
36
+ export {};
package/build/utils.js CHANGED
@@ -1 +1 @@
1
- import{__makeTemplateObject as e}from'./ext/tslib/tslib.es6.mjs.js';import n from"react";import'./ext/react-i18next/dist/es/context.js';import{useTranslation as t}from'./ext/react-i18next/dist/es/useTranslation.js';import r from'./ext/i18next/dist/esm/i18next.js';import l from"styled-components";import{ArrowRight as i}from"./assets/icons/arrow-right.js";import{BubbleChatDone as s}from"./assets/widget-icons/normal/bubbleChatDone.js";import{CommentAdd01 as o}from"./assets/widget-icons/normal/commentAdd01.js";import{CouponPercent as a}from"./assets/widget-icons/normal/couponPercent.js";import{DiscountTag02 as E}from"./assets/widget-icons/normal/discountTag02.js";import{Gift as m}from"./assets/widget-icons/normal/gift.js";import{MoneyAdd01 as c}from"./assets/widget-icons/normal/moneyAdd01.js";import{PackageDelivered as d}from"./assets/widget-icons/normal/packageDelivered.js";import{SaveMoneyDollar as u}from"./assets/widget-icons/normal/saveMoneyDollar.js";import{ShoppingBasketAdd02 as p}from"./assets/widget-icons/normal/shoppingBasketAdd02.js";import{UserAdd01 as R}from"./assets/widget-icons/normal/userAdd01.js";import{UsersIllustration as T}from"./assets/widget-icons/illustraions/usersIllustration.js";import{BubbleChatIllustration as _}from"./assets/widget-icons/illustraions/bubbleChatIllustration.js";import{ApprovedChatIllustration as f}from"./assets/widget-icons/illustraions/approvedChatIllustration.js";import{TshirtIllustration as g}from"./assets/widget-icons/illustraions/tshirtIllustration.js";import{Medal as I}from"./assets/widget-icons/illustraions/medal.js";import{GiftIllustration as O}from"./assets/widget-icons/illustraions/giftIllustration.js";import{ShippingBox as S}from"./assets/widget-icons/illustraions/shippingBox.js";import{BigSaleMedal as N}from"./assets/widget-icons/illustraions/bigSaleMedal.js";import{ShoppingCartIllustration as C}from"./assets/widget-icons/illustraions/shoppingCartIllustration.js";import{BankCoin as M}from"./assets/widget-icons/illustraions/bankCoin.js";import{WidgetIconTypeEnum as A}from"./models/loyalty-widget/types/index.js";import{EarningMethodTypeEnum as x,LoyaltyWidgetScreenTypeEnum as D,LoyaltyProgramPointEarningTypeEnum as U,LoyaltyProgramMethodSpendingTypeEnum as j}from"./models/types/index.js";import{FlexibleValueContainer as y}from"./renderer/components/flexible-value-container/index.js";import{textSM as h,textXSMedium as w,textXS as P}from"./renderer/components/style/typography.js";var v,L,b,F,G,B,Y,H,V,X=((v={})[A.ILLUSTRATION]=((L={})[x.CUSTOMER_REGISTER]=n.createElement(T,null),L[x.ENABLE_SUBSCRIPTION]=n.createElement(f,null),L[x.BUY_PRODUCT]=n.createElement(g,null),L[x.CUSTOMER_REVIEW]=n.createElement(_,null),L[x.CUSTOMER_SEGMENT]=n.createElement(a,null),L[x.ORDER_CREATE]=n.createElement(C,null),L),v[A.NORMAL]=((b={})[x.CUSTOMER_REGISTER]=n.createElement(R,null),b[x.ENABLE_SUBSCRIPTION]=n.createElement(s,null),b[x.BUY_PRODUCT]=n.createElement(u,null),b[x.CUSTOMER_REVIEW]=n.createElement(o,null),b[x.CUSTOMER_SEGMENT]=n.createElement(a,null),b[x.ORDER_CREATE]=n.createElement(p,null),b),v),k=((F={})[A.ILLUSTRATION]=((G={})[D.MAIN_SCREEN]=n.createElement("div",null),G[D.CREDIT_EARNING_METHODS_SCREEN]=n.createElement(I,null),G[D.CREDIT_SPENDING_METHODS_SCREEN]=n.createElement(N,null),G[D.CREDIT_HISTORY_SCREEN]=n.createElement("div",null),G[D.LOYALTY_LEVEL_SCREEN]=n.createElement("div",null),G),F[A.NORMAL]=((B={})[D.MAIN_SCREEN]=n.createElement("div",null),B[D.CREDIT_EARNING_METHODS_SCREEN]=n.createElement(c,null),B[D.CREDIT_SPENDING_METHODS_SCREEN]=n.createElement(a,null),B[D.CREDIT_HISTORY_SCREEN]=n.createElement("div",null),B[D.LOYALTY_LEVEL_SCREEN]=n.createElement("div",null),B),F),W=function(e,n){return n&&n!==A.NONE&&k[n]?k[n][e]:null},q=function(e,n){return n&&n!==A.NONE&&X[n]?X[n][e]:null},z=function(e){var n=t().t;switch(e.methodType){case x.CUSTOMER_REGISTER:return n("earningMethods.CUSTOMER_REGISTER.title");case x.ENABLE_SUBSCRIPTION:return n("earningMethods.ENABLE_SUBSCRIPTION.title");case x.CUSTOMER_REVIEW:return n("earningMethods.CUSTOMER_REVIEW.title");case x.ORDER_CREATE:if(e.pointEarningType===U.DYNAMIC_ORDER_AMOUNT)return n("earningMethods.ORDER_CREATE.RECEIVE_POINTS_ON_SPEND.title");if(e.pointEarningType===U.STATIC)return n("earningMethods.ORDER_CREATE.BASE.title");case x.BUY_PRODUCT:return n("earningMethods.BUY_PRODUCT.title");case x.CUSTOMER_SEGMENT:return n("earningMethods.CUSTOMER_SEGMENT.title");default:return""}},J=function(e,t){var r,l,i;return t===A.NONE?null:((r={})[A.ILLUSTRATION]=((l={})[j.FIXED_AMOUNT]=n.createElement(M,null),l[j.RATIO]=n.createElement(M,null),l[j.FREE_PRODUCT]=n.createElement(O,null),l[j.FREE_SHIPPING]=n.createElement(S,null),l),r[A.NORMAL]=((i={})[j.FIXED_AMOUNT]=n.createElement(E,null),i[j.RATIO]=n.createElement(E,null),i[j.FREE_PRODUCT]=n.createElement(m,null),i[j.FREE_SHIPPING]=n.createElement(d,null),i),r)[t][e]},K=function(e){var n,l=t().t,i=r.language,s=null===(n=e.translations)||void 0===n?void 0:n.find(function(e){return e.locale===i});if(null==s?void 0:s.description)return s.description;if(e.description)return e.description;switch(e.type){case j.FIXED_AMOUNT:return e.isDynamic?l("spendingMethods.FIXED_AMOUNT.dynamicTitle"):l("spendingMethods.FIXED_AMOUNT.title");case j.RATIO:return l("spendingMethods.RATIO.title");case j.FREE_SHIPPING:return l("spendingMethods.FREE_SHIPPING.title");case j.FREE_PRODUCT:return l("spendingMethods.FREE_PRODUCT.title");default:return""}},Q=l.span(Y||(Y=e(["\n display: flex;\n padding: 2px 8px;\n justify-content: center;\n align-items: center;\n gap: 6px;\n border-radius: 6px;\n border: 0.6px solid #cdd5df;\n opacity: 0.8;\n background: #f8fafc;\n ","\n color: #121926;\n\n @media (max-width: 600px) {\n ","\n }\n"],["\n display: flex;\n padding: 2px 8px;\n justify-content: center;\n align-items: center;\n gap: 6px;\n border-radius: 6px;\n border: 0.6px solid #cdd5df;\n opacity: 0.8;\n background: #f8fafc;\n ","\n color: #121926;\n\n @media (max-width: 600px) {\n ","\n }\n"])),h,w),Z=l.span(H||(H=e(["\n ","\n color: #364152;\n\n @media (max-width: 600px) {\n ","\n }\n"],["\n ","\n color: #364152;\n\n @media (max-width: 600px) {\n ","\n }\n"])),h,P),$=l.span(V||(V=e(["\n color: #697586;\n display: flex;\n align-items: center;\n"],["\n color: #697586;\n display: flex;\n align-items: center;\n"]))),ee=function(e,r){var l,s,o=t().t,a=(null===(l=e.discountSettings)||void 0===l?void 0:l.point)||0,E=null===(s=e.discountSettings)||void 0===s?void 0:s.discountAmount,m=function(e,t){return void 0===t&&(t=!1),n.createElement(y,null,function(l){return l?n.createElement(n.Fragment,null,n.createElement(Z,null,o("earningMethods.xPoints",{points:a})),n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"6px"}},n.createElement($,null,n.createElement(i,null)),n.createElement(Q,null,t&&"number"==typeof e?r.formatCurrency(e):e))):n.createElement(n.Fragment,null,n.createElement(Z,null,o("earningMethods.xPoints",{points:a})),n.createElement($,null,n.createElement(i,null)),n.createElement(Q,null,t&&"number"==typeof e?r.formatCurrency(e):e))})};return e.type===j.FIXED_AMOUNT&&E?m(E,!0):e.type===j.RATIO&&E?m("%".concat(E)):o("earningMethods.xPoints",{points:a})};export{q as getEarningMethodIcon,z as getEarningMethodTitle,W as getScreenIcon,ee as getSpendingMethodDescription,J as getSpendingMethodIcon,K as getSpendingMethodTitle};
1
+ import{__makeTemplateObject as e,__assign as t}from'./ext/tslib/tslib.es6.mjs.js';import n from"react";import'./ext/react-i18next/dist/es/context.js';import{useTranslation as r}from'./ext/react-i18next/dist/es/useTranslation.js';import i from'./ext/i18next/dist/esm/i18next.js';import s from"styled-components";import{ArrowRight as l}from"./assets/icons/arrow-right.js";import{BubbleChatDone as o}from"./assets/widget-icons/normal/bubbleChatDone.js";import{CommentAdd01 as a}from"./assets/widget-icons/normal/commentAdd01.js";import{CouponPercent as E}from"./assets/widget-icons/normal/couponPercent.js";import{DiscountTag02 as m}from"./assets/widget-icons/normal/discountTag02.js";import{Gift as c}from"./assets/widget-icons/normal/gift.js";import{MoneyAdd01 as d}from"./assets/widget-icons/normal/moneyAdd01.js";import{PackageDelivered as u}from"./assets/widget-icons/normal/packageDelivered.js";import{SaveMoneyDollar as p}from"./assets/widget-icons/normal/saveMoneyDollar.js";import{ShoppingBasketAdd02 as R}from"./assets/widget-icons/normal/shoppingBasketAdd02.js";import{UserAdd01 as T}from"./assets/widget-icons/normal/userAdd01.js";import{UsersIllustration as f}from"./assets/widget-icons/illustraions/usersIllustration.js";import{BubbleChatIllustration as g}from"./assets/widget-icons/illustraions/bubbleChatIllustration.js";import{ApprovedChatIllustration as _}from"./assets/widget-icons/illustraions/approvedChatIllustration.js";import{TshirtIllustration as I}from"./assets/widget-icons/illustraions/tshirtIllustration.js";import{Medal as S}from"./assets/widget-icons/illustraions/medal.js";import{GiftIllustration as O}from"./assets/widget-icons/illustraions/giftIllustration.js";import{ShippingBox as N}from"./assets/widget-icons/illustraions/shippingBox.js";import{BigSaleMedal as C}from"./assets/widget-icons/illustraions/bigSaleMedal.js";import{ShoppingCartIllustration as M}from"./assets/widget-icons/illustraions/shoppingCartIllustration.js";import{BankCoin as A}from"./assets/widget-icons/illustraions/bankCoin.js";import{WidgetIconTypeEnum as D}from"./models/loyalty-widget/types/index.js";import{EarningMethodTypeEnum as U,LoyaltyWidgetScreenTypeEnum as x,LoyaltyProgramPointEarningTypeEnum as y,LoyaltyProgramMethodSpendingTypeEnum as h}from"./models/types/index.js";import{FlexibleValueContainer as j}from"./renderer/components/flexible-value-container/index.js";import{textSM as v,textXSMedium as w,textXS as P}from"./renderer/components/style/typography.js";var L,b,F,G,B,Y,H,k,V,X="ikas-storefront-widget",W=function(){try{for(var e=document.cookie.split(";"),t=0,n=e;t<n.length;t++){var r=n[t].trim().split("="),i=r[0],s=r[1];if("ikas_session_id"===i){var l=decodeURIComponent(s);return JSON.parse(l).id||null}}return null}catch(e){return null}},J=function(){try{var e=localStorage.getItem(X);return e?JSON.parse(e):{}}catch(e){return{}}},q=function(e){try{var n=J(),r=t(t({},n),e);localStorage.setItem(X,JSON.stringify(r))}catch(e){}},z=function(){var e=W();return!!e&&J().closedDescriptionSessionId===e},K=function(){var e=W();e&&q({closedDescriptionSessionId:e})},Q=((L={})[D.ILLUSTRATION]=((b={})[U.CUSTOMER_REGISTER]=n.createElement(f,null),b[U.ENABLE_SUBSCRIPTION]=n.createElement(_,null),b[U.BUY_PRODUCT]=n.createElement(I,null),b[U.CUSTOMER_REVIEW]=n.createElement(g,null),b[U.CUSTOMER_SEGMENT]=n.createElement(E,null),b[U.ORDER_CREATE]=n.createElement(M,null),b),L[D.NORMAL]=((F={})[U.CUSTOMER_REGISTER]=n.createElement(T,null),F[U.ENABLE_SUBSCRIPTION]=n.createElement(o,null),F[U.BUY_PRODUCT]=n.createElement(p,null),F[U.CUSTOMER_REVIEW]=n.createElement(a,null),F[U.CUSTOMER_SEGMENT]=n.createElement(E,null),F[U.ORDER_CREATE]=n.createElement(R,null),F),L),Z=((G={})[D.ILLUSTRATION]=((B={})[x.MAIN_SCREEN]=n.createElement("div",null),B[x.CREDIT_EARNING_METHODS_SCREEN]=n.createElement(S,null),B[x.CREDIT_SPENDING_METHODS_SCREEN]=n.createElement(C,null),B[x.CREDIT_HISTORY_SCREEN]=n.createElement("div",null),B[x.LOYALTY_LEVEL_SCREEN]=n.createElement("div",null),B),G[D.NORMAL]=((Y={})[x.MAIN_SCREEN]=n.createElement("div",null),Y[x.CREDIT_EARNING_METHODS_SCREEN]=n.createElement(d,null),Y[x.CREDIT_SPENDING_METHODS_SCREEN]=n.createElement(E,null),Y[x.CREDIT_HISTORY_SCREEN]=n.createElement("div",null),Y[x.LOYALTY_LEVEL_SCREEN]=n.createElement("div",null),Y),G),$=function(e,t){return t&&t!==D.NONE&&Z[t]?Z[t][e]:null},ee=function(e,t){return t&&t!==D.NONE&&Q[t]?Q[t][e]:null},te=function(e){var t=r().t;switch(e.methodType){case U.CUSTOMER_REGISTER:return t("earningMethods.CUSTOMER_REGISTER.title");case U.ENABLE_SUBSCRIPTION:return t("earningMethods.ENABLE_SUBSCRIPTION.title");case U.CUSTOMER_REVIEW:return t("earningMethods.CUSTOMER_REVIEW.title");case U.ORDER_CREATE:if(e.pointEarningType===y.DYNAMIC_ORDER_AMOUNT)return t("earningMethods.ORDER_CREATE.RECEIVE_POINTS_ON_SPEND.title");if(e.pointEarningType===y.STATIC)return t("earningMethods.ORDER_CREATE.BASE.title");case U.BUY_PRODUCT:return t("earningMethods.BUY_PRODUCT.title");case U.CUSTOMER_SEGMENT:return t("earningMethods.CUSTOMER_SEGMENT.title");default:return""}},ne=function(e,t){var r,i,s;return t===D.NONE?null:((r={})[D.ILLUSTRATION]=((i={})[h.FIXED_AMOUNT]=n.createElement(A,null),i[h.RATIO]=n.createElement(A,null),i[h.FREE_PRODUCT]=n.createElement(O,null),i[h.FREE_SHIPPING]=n.createElement(N,null),i),r[D.NORMAL]=((s={})[h.FIXED_AMOUNT]=n.createElement(m,null),s[h.RATIO]=n.createElement(m,null),s[h.FREE_PRODUCT]=n.createElement(c,null),s[h.FREE_SHIPPING]=n.createElement(u,null),s),r)[t][e]},re=function(e){var t,n=r().t,s=i.language,l=null===(t=e.translations)||void 0===t?void 0:t.find(function(e){return e.locale===s});if(null==l?void 0:l.description)return l.description;if(e.description)return e.description;switch(e.type){case h.FIXED_AMOUNT:return e.isDynamic?n("spendingMethods.FIXED_AMOUNT.dynamicTitle"):n("spendingMethods.FIXED_AMOUNT.title");case h.RATIO:return n("spendingMethods.RATIO.title");case h.FREE_SHIPPING:return n("spendingMethods.FREE_SHIPPING.title");case h.FREE_PRODUCT:return n("spendingMethods.FREE_PRODUCT.title");default:return""}},ie=s.span(H||(H=e(["\n display: flex;\n padding: 2px 8px;\n justify-content: center;\n align-items: center;\n gap: 6px;\n border-radius: 6px;\n border: 0.6px solid #cdd5df;\n opacity: 0.8;\n background: #f8fafc;\n ","\n color: #121926;\n\n @media (max-width: 600px) {\n ","\n }\n"],["\n display: flex;\n padding: 2px 8px;\n justify-content: center;\n align-items: center;\n gap: 6px;\n border-radius: 6px;\n border: 0.6px solid #cdd5df;\n opacity: 0.8;\n background: #f8fafc;\n ","\n color: #121926;\n\n @media (max-width: 600px) {\n ","\n }\n"])),v,w),se=s.span(k||(k=e(["\n ","\n color: #364152;\n\n @media (max-width: 600px) {\n ","\n }\n"],["\n ","\n color: #364152;\n\n @media (max-width: 600px) {\n ","\n }\n"])),v,P),le=s.span(V||(V=e(["\n color: #697586;\n display: flex;\n align-items: center;\n"],["\n color: #697586;\n display: flex;\n align-items: center;\n"]))),oe=function(e,t){var i,s,o=r().t,a=(null===(i=e.discountSettings)||void 0===i?void 0:i.point)||0,E=null===(s=e.discountSettings)||void 0===s?void 0:s.discountAmount,m=function(e,r){return void 0===r&&(r=!1),n.createElement(j,null,function(i){return i?n.createElement(n.Fragment,null,n.createElement(se,null,o("earningMethods.xPoints",{points:a})),n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"6px"}},n.createElement(le,null,n.createElement(l,null)),n.createElement(ie,null,r&&"number"==typeof e?t.formatCurrency(e):e))):n.createElement(n.Fragment,null,n.createElement(se,null,o("earningMethods.xPoints",{points:a})),n.createElement(le,null,n.createElement(l,null)),n.createElement(ie,null,r&&"number"==typeof e?t.formatCurrency(e):e))})};return e.type===h.FIXED_AMOUNT&&E?m(E,!0):e.type===h.RATIO&&E?m("%".concat(E)):o("earningMethods.xPoints",{points:a})};export{ee as getEarningMethodIcon,te as getEarningMethodTitle,W as getIkasSessionId,$ as getScreenIcon,oe as getSpendingMethodDescription,ne as getSpendingMethodIcon,re as getSpendingMethodTitle,J as getWidgetStorage,z as isDescriptionClosedForCurrentSession,K as markDescriptionClosedForSession,q as setWidgetStorage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/loyalty-widget-renderer",
3
- "version": "1.0.0-alpha.76",
3
+ "version": "1.0.0-alpha.78",
4
4
  "description": "",
5
5
  "author": "ucy",
6
6
  "license": "ISC",