@ikas/loyalty-widget-renderer 1.0.0-alpha.30 → 1.0.0-alpha.31
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/loyalty-widget-script-injector.iife.js +1 -1
- package/build/loyalty-widget-script-injector.iife.js.map +1 -1
- package/build/models/index.d.ts +1 -3
- package/build/models/index.js +1 -1
- package/build/models/types/index.d.ts +3 -3
- package/build/renderer/components/mini-mode-description/style.js +1 -1
- package/build/renderer/components/style/typography.d.ts +2 -1
- package/build/renderer/components/style/typography.js +1 -1
- package/build/renderer/index.js +1 -1
- package/package.json +1 -1
package/build/models/index.d.ts
CHANGED
|
@@ -26,9 +26,7 @@ export declare class LoyaltyWidgetViewModel {
|
|
|
26
26
|
tiers: LoyaltyProgramTier[];
|
|
27
27
|
pointHistory: LoyaltyProgramPointHistory[];
|
|
28
28
|
callbacks?: LoyaltyWidgetCallbacks;
|
|
29
|
-
constructor(data: Partial<LoyaltyWidgetViewModel> | undefined, cdnURL: string, merchantId: string, currency: string, locale: string, storeURL?: string | null,
|
|
30
|
-
changeWidgetMode: (mode: WidgetMode) => void;
|
|
31
|
-
}, callbacks?: LoyaltyWidgetCallbacks);
|
|
29
|
+
constructor(data: Partial<LoyaltyWidgetViewModel> | undefined, cdnURL: string, merchantId: string, currency: string, locale: string, storeURL?: string | null, isPreviewMode?: boolean, callbacks?: LoyaltyWidgetCallbacks);
|
|
32
30
|
setWidgetMode(mode: WidgetMode): void;
|
|
33
31
|
closeMiniModeDescription(): void;
|
|
34
32
|
}
|
package/build/models/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeObservable as t,observable as
|
|
1
|
+
import{makeObservable as t,observable as i}from"mobx";import{LoyaltyWidget as e}from"./loyalty-widget/index.js";import{WidgetMode as s,LoyaltyWidgetScreenTypeEnum as o}from"./types/index.js";import{LoyaltyProgramSpendingMethod as r}from"./loyalty-program-spending-method/index.js";import{LoyaltyProgramEarningMethod as n}from"./loyalty-program-earning-method/index.js";import{LoyaltyCustomerInfo as d}from"./loyalty-customer-info/index.js";var c=function(){function c(c,a,l,h,p,g,M,y){void 0===c&&(c={}),this.selectedScreen=c.selectedScreen||o.MAIN_SCREEN,this.currentWidgetMode=M?s.WIDGET_MODE:c.currentWidgetMode||s.MINI_MODE,this.isMiniModeDescriptionClosed=c.isMiniModeDescriptionClosed||!1,this.isLoading=c.isLoading||!1,this.loyaltyWidget=c.loyaltyWidget instanceof e?c.loyaltyWidget:new e(c.loyaltyWidget),this.cdnURL=a,this.merchantId=l,this.storeUrl=g||c.storeUrl||"",this.currency=h,this.locale=p,this.cartId=c.cartId||null,this.user=c.user?new d(c.user):null,this.earningMethods=c.earningMethods?c.earningMethods.map(function(t){return new n(t)}):[],this.spendingMethods=c.spendingMethods?c.spendingMethods.map(function(t){return new r(t)}):[],this.tiers=c.tiers?c.tiers:[],this.categories=c.categories?c.categories:[],this.products=c.products?c.products:[],this.brands=c.brands?c.brands:[],this.tags=c.tags?c.tags:[],this.pointHistory=c.pointHistory?c.pointHistory:[],this.callbacks=y||void 0,t(this,{cartId:i,loyaltyWidget:i,isLoading:i,cdnURL:i,merchantId:i,storeUrl:i,currency:i,locale:i,selectedScreen:i,currentWidgetMode:i,isMiniModeDescriptionClosed:i,user:i,earningMethods:i,spendingMethods:i,tiers:i,categories:i,products:i,brands:i,tags:i,pointHistory:i})}return c.prototype.setWidgetMode=function(t){this.currentWidgetMode=t,t===s.WIDGET_MODE&&(this.isMiniModeDescriptionClosed=!0)},c.prototype.closeMiniModeDescription=function(){this.isMiniModeDescriptionClosed=!0},c}();export{c as LoyaltyWidgetViewModel};
|
|
@@ -3,6 +3,7 @@ import type { LoyaltyProgramEarningMethod } from "../loyalty-program-earning-met
|
|
|
3
3
|
import type { LoyaltyCustomerInfo, LoyaltyProgramTier } from "../loyalty-customer-info";
|
|
4
4
|
import type { LoyaltyWidget } from "../loyalty-widget";
|
|
5
5
|
import type { LoyaltyProgramPointHistory } from "../loyalty-program-point-history";
|
|
6
|
+
import { LoyaltyWidgetViewModel } from "models";
|
|
6
7
|
export declare enum LoyaltyWidgetScreenTypeEnum {
|
|
7
8
|
MAIN_SCREEN = "MAIN_SCREEN",
|
|
8
9
|
CREDIT_SPENDING_METHODS_SCREEN = "CREDIT_SPENDING_METHODS_SCREEN",
|
|
@@ -113,7 +114,6 @@ export type IkasLoyaltyWidgetConfig = {
|
|
|
113
114
|
storeURL?: string | null;
|
|
114
115
|
callbacks: LoyaltyWidgetCallbacks;
|
|
115
116
|
position?: "fixed" | "absolute";
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
};
|
|
117
|
+
isPreviewMode?: boolean;
|
|
118
|
+
onViewModelInitialized?: (viewModel: LoyaltyWidgetViewModel) => void;
|
|
119
119
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__makeTemplateObject as n}from'./../../../ext/tslib/tslib.es6.mjs.js';import p from"styled-components";var
|
|
1
|
+
import{__makeTemplateObject as n}from'./../../../ext/tslib/tslib.es6.mjs.js';import p from"styled-components";import{textMD as r}from"../style/typography.js";var o,x,a,i=p.div(o||(o=n(["\n display: flex;\n width: 432px;\n padding: 20px;\n flex-direction: column;\n align-items: flex-start;\n gap: 24px;\n border-radius: 16px;\n border: 1px solid #ECECED;\n background: #FFF;\n box-shadow: 0 22px 6px 0 rgba(0, 0, 0, 0.00), 0 14px 6px 0 rgba(0, 0, 0, 0.01),\n 0 8px 5px 0 rgba(0, 0, 0, 0.05), 0 4px 4px 0 rgba(0, 0, 0, 0.09),\n 0 1px 2px 0 rgba(0, 0, 0, 0.10);\n color: #121926;\n position: relative;\n cursor: pointer;\n margin-bottom: 16px; /* 16px space between description and button */\n"],["\n display: flex;\n width: 432px;\n padding: 20px;\n flex-direction: column;\n align-items: flex-start;\n gap: 24px;\n border-radius: 16px;\n border: 1px solid #ECECED;\n background: #FFF;\n box-shadow: 0 22px 6px 0 rgba(0, 0, 0, 0.00), 0 14px 6px 0 rgba(0, 0, 0, 0.01),\n 0 8px 5px 0 rgba(0, 0, 0, 0.05), 0 4px 4px 0 rgba(0, 0, 0, 0.09),\n 0 1px 2px 0 rgba(0, 0, 0, 0.10);\n color: #121926;\n position: relative;\n cursor: pointer;\n margin-bottom: 16px; /* 16px space between description and button */\n"]))),e=p.div(x||(x=n(["\n position: absolute;\n top: -12px;\n right: -12px;\n cursor: pointer;\n display: inline-flex;\n padding: 6px;\n align-items: center;\n gap: 10px;\n border-radius: 40px;\n background: #F6F6F6;\n box-shadow: 0 22px 6px 0 rgba(0, 0, 0, 0.00), 0 14px 6px 0 rgba(0, 0, 0, 0.01),\n 0 8px 5px 0 rgba(0, 0, 0, 0.05), 0 4px 4px 0 rgba(0, 0, 0, 0.09),\n 0 1px 2px 0 rgba(0, 0, 0, 0.10);\n color: #4B5565;\n\n &:hover {\n color: #667085;\n }\n"],["\n position: absolute;\n top: -12px;\n right: -12px;\n cursor: pointer;\n display: inline-flex;\n padding: 6px;\n align-items: center;\n gap: 10px;\n border-radius: 40px;\n background: #F6F6F6;\n box-shadow: 0 22px 6px 0 rgba(0, 0, 0, 0.00), 0 14px 6px 0 rgba(0, 0, 0, 0.01),\n 0 8px 5px 0 rgba(0, 0, 0, 0.05), 0 4px 4px 0 rgba(0, 0, 0, 0.09),\n 0 1px 2px 0 rgba(0, 0, 0, 0.10);\n color: #4B5565;\n\n &:hover {\n color: #667085;\n }\n"]))),t=p.div(a||(a=n(["\n ",";\n color: #121926;\n"],["\n ",";\n color: #121926;\n"])),r);export{e as CloseButton,i as Container,t as Text};
|
|
@@ -2,10 +2,11 @@ declare const textXSMedium: import("styled-components").FlattenSimpleInterpolati
|
|
|
2
2
|
declare const textSM: import("styled-components").FlattenSimpleInterpolation;
|
|
3
3
|
declare const textSMMedium: import("styled-components").FlattenSimpleInterpolation;
|
|
4
4
|
declare const textSMSemiBold: import("styled-components").FlattenSimpleInterpolation;
|
|
5
|
+
declare const textMD: import("styled-components").FlattenSimpleInterpolation;
|
|
5
6
|
declare const textMDMedium: import("styled-components").FlattenSimpleInterpolation;
|
|
6
7
|
declare const textLGMedium: import("styled-components").FlattenSimpleInterpolation;
|
|
7
8
|
declare const textLGSemiBold: import("styled-components").FlattenSimpleInterpolation;
|
|
8
9
|
declare const textXLSemiBold: import("styled-components").FlattenSimpleInterpolation;
|
|
9
10
|
declare const displayXSSemiBold: import("styled-components").FlattenSimpleInterpolation;
|
|
10
11
|
declare const Badge: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
11
|
-
export { textXSMedium, textSM, textSMMedium, textSMSemiBold, textMDMedium, textLGMedium, textLGSemiBold, textXLSemiBold, displayXSSemiBold, Badge, };
|
|
12
|
+
export { textXSMedium, textSM, textSMMedium, textSMSemiBold, textMD, textMDMedium, textLGMedium, textLGSemiBold, textXLSemiBold, displayXSSemiBold, Badge, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__makeTemplateObject as n}from'./../../../ext/tslib/tslib.es6.mjs.js';import t,{css as e}from"styled-components";var o,i,l,f,p,s,h,x,g,r,a=e(o||(o=n(["\n font-size: 12px;\n font-style: normal;\n font-weight: 500;\n line-height: 18px; /* 150% */\n letter-spacing: -0.24px;\n"],["\n font-size: 12px;\n font-style: normal;\n font-weight: 500;\n line-height: 18px; /* 150% */\n letter-spacing: -0.24px;\n"]))),
|
|
1
|
+
import{__makeTemplateObject as n}from'./../../../ext/tslib/tslib.es6.mjs.js';import t,{css as e}from"styled-components";var o,i,l,f,p,s,h,x,g,r,a,m=e(o||(o=n(["\n font-size: 12px;\n font-style: normal;\n font-weight: 500;\n line-height: 18px; /* 150% */\n letter-spacing: -0.24px;\n"],["\n font-size: 12px;\n font-style: normal;\n font-weight: 500;\n line-height: 18px; /* 150% */\n letter-spacing: -0.24px;\n"]))),y=e(i||(i=n(["\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n line-height: 20px;\n"],["\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n line-height: 20px;\n"]))),d=e(l||(l=n(["\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px; /* 142.857% */\n"],["\n font-size: 14px;\n font-style: normal;\n font-weight: 500;\n line-height: 20px; /* 142.857% */\n"]))),w=e(f||(f=n(["\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n"],["\n font-size: 14px;\n font-style: normal;\n font-weight: 600;\n line-height: 20px;\n"]))),z=e(p||(p=n(["\nfont-size: 16px;\nfont-style: normal;\nfont-weight: 400;\nline-height: 24px\n"],["\nfont-size: 16px;\nfont-style: normal;\nfont-weight: 400;\nline-height: 24px\n"]))),c=e(s||(s=n(["\n font-size: 16px;\n font-style: normal;\n font-weight: 500;\n line-height: 24px; /* 150% */\n"],["\n font-size: 16px;\n font-style: normal;\n font-weight: 500;\n line-height: 24px; /* 150% */\n"]))),b=e(h||(h=n(["\n font-size: 18px;\n font-style: normal;\n font-weight: 500;\n line-height: 28px;\n"],["\n font-size: 18px;\n font-style: normal;\n font-weight: 500;\n line-height: 28px;\n"]))),u=e(x||(x=n(["\n font-size: 18px;\n font-style: normal;\n font-weight: 600;\n line-height: 28px;\n"],["\n font-size: 18px;\n font-style: normal;\n font-weight: 600;\n line-height: 28px;\n"]))),j=e(g||(g=n(["\n font-size: 20px;\n font-style: normal;\n font-weight: 600;\n line-height: 30px;\n"],["\n font-size: 20px;\n font-style: normal;\n font-weight: 600;\n line-height: 30px;\n"]))),k=e(r||(r=n(["\n font-size: 24px;\n font-style: normal;\n font-weight: 600;\n line-height: 32px;\n"],["\n font-size: 24px;\n font-style: normal;\n font-weight: 600;\n line-height: 32px;\n"]))),v=t.span(a||(a=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 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"])),y);export{v as Badge,k as displayXSSemiBold,b as textLGMedium,u as textLGSemiBold,z as textMD,c as textMDMedium,y as textSM,d as textSMMedium,w as textSMSemiBold,j as textXLSemiBold,m as textXSMedium};
|
package/build/renderer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__spreadArray as n}from'./../ext/tslib/tslib.es6.mjs.js';import
|
|
1
|
+
import{__awaiter as e,__generator as t,__spreadArray as n}from'./../ext/tslib/tslib.es6.mjs.js';import o,{useState as r,useRef as i,useEffect as s}from"react";import{observer as l}from"mobx-react";import'./../ext/react-i18next/dist/es/context.js';import{I18nextProvider as c}from'./../ext/react-i18next/dist/es/I18nextProvider.js';import a from"./utils/i18n.js";import{LoyaltyWidgetScreenTypeEnum as d,WidgetMode as u,EarningMethodTypeEnum as m,LoyaltyProgramFilterTypeEnum as f,LoyaltyProgramMethodSpendingTypeEnum as p}from"../models/types/index.js";import{WidgetPositionEnum as y,LoyaltyWidgetLayoutTypeEnum as E}from"../models/loyalty-widget/types/index.js";import g from"./screens/main-screen/index.js";import h from"./screens/credit-spending-methods-screen/index.js";import v from"./screens/credit-earning-methods-screen/index.js";import C from"./screens/credit-history-screen/index.js";import M from"./screens/loyalty-level-screen/index.js";import I from"./components/mini-mode-button/index.js";import R from"./components/mini-mode-description/index.js";import{LoyaltyWidgetViewModel as w}from"../models/index.js";import{LoyaltyWidget as _}from"../models/loyalty-widget/index.js";import{LoyaltyProgramSpendingMethod as S}from"../models/loyalty-program-spending-method/index.js";import{LoyaltyCustomerInfo as N}from"../models/loyalty-customer-info/index.js";import{LoyaltyProgramEarningMethod as T}from"../models/loyalty-program-earning-method/index.js";import{LoyaltyProgramPointHistory as b}from"../models/loyalty-program-point-history/index.js";import{Container as k,MiniModeWrapper as A,Panel as P,ScreenWrapper as D}from"./style.js";var L=l(function(l){var L,x=l.config,j=r(function(){var e=x||window.ikasLoyaltyWidgetConfig;return new w({cartId:(null==e?void 0:e.cartId)||null},(null==e?void 0:e.cdnURL)||"",(null==e?void 0:e.merchantId)||"",(null==e?void 0:e.currency)||"",(null==e?void 0:e.locale)||"",(null==e?void 0:e.storeURL)||null,null==e?void 0:e.isPreviewMode,null==e?void 0:e.callbacks)})[0],O=i(!0);s(function(){var e=x||window.ikasLoyaltyWidgetConfig;(null==e?void 0:e.onViewModelInitialized)&&e.onViewModelInitialized(j)},[j,x]),s(function(){e(void 0,void 0,void 0,function(){var e,o,r,i,s,l,c,a,d,u,y,E,g,h;return t(this,function(t){switch(t.label){case 0:if(!j.callbacks)return[3,6];t.label=1;case 1:return t.trys.push([1,4,5,6]),e=[j.callbacks.getLoyaltyWidget(),j.callbacks.listEarningMethods(),j.callbacks.listLoyaltyProgramTier({})],j.cartId&&(e.push(j.callbacks.listSpendingMethodsByCartId(j.cartId)),e.push(j.callbacks.getLoyaltyCustomerInfo()),e.push(j.callbacks.listLoyaltyProgramPointHistory({}))),[4,Promise.all(e)];case 2:return o=t.sent(),r=o[0],i=o[1],s=o[2],l=[],c=null,a=[],j.cartId&&(l=o[3],c=o[4],a=o[5]),j.loyaltyWidget=r instanceof _?r:new _(r||{}),j.earningMethods=i.map(function(e){return new T(e)}),j.tiers=s||[],j.cartId&&(j.spendingMethods=l.map(function(e){return new S(e)}),j.user=c?new N(c):null,j.pointHistory=a?a.map(function(e){return new b(e)}):[]),d=new Set,u=new Set,y=new Set,E=new Set,j.earningMethods.forEach(function(e){var t,o;e.methodType===m.ORDER_CREATE&&n(n([],(null===(t=e.orderSettings)||void 0===t?void 0:t.productFilters)||[],!0),(null===(o=e.productSettings)||void 0===o?void 0:o.productFilters)||[],!0).forEach(function(e){e.type===f.PRODUCT_AND_VARIANT?e.idList.forEach(function(e){return d.add(e)}):e.type===f.CATEGORY?e.idList.forEach(function(e){return u.add(e)}):e.type===f.PRODUCT_BRAND?e.idList.forEach(function(e){return y.add(e)}):e.type===f.PRODUCT_TAG&&e.idList.forEach(function(e){return E.add(e)})})}),j.spendingMethods&&j.spendingMethods.forEach(function(e){var t,n;e.type===p.FREE_PRODUCT&&(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)&&d.add(e.discountSettings.freeProductId),null===(n=e.productFilters)||void 0===n||n.forEach(function(e){e.type===f.PRODUCT_AND_VARIANT?e.idList.forEach(function(e){return d.add(e)}):e.type===f.CATEGORY?e.idList.forEach(function(e){return u.add(e)}):e.type===f.PRODUCT_BRAND?e.idList.forEach(function(e){return y.add(e)}):e.type===f.PRODUCT_TAG&&e.idList.forEach(function(e){return E.add(e)})})}),g=[],d.size>0&&j.callbacks.getProducts&&g.push(j.callbacks.getProducts(Array.from(d)).then(function(e){return j.products=e})),u.size>0&&j.callbacks.getCategories&&g.push(j.callbacks.getCategories(Array.from(u)).then(function(e){return j.categories=e})),y.size>0&&j.callbacks.getBrands&&g.push(j.callbacks.getBrands(Array.from(y)).then(function(e){return j.brands=e})),E.size>0&&j.callbacks.getTags&&g.push(j.callbacks.getTags(Array.from(E)).then(function(e){return j.tags=e})),[4,Promise.all(g)];case 3:return t.sent(),[3,6];case 4:return h=t.sent(),console.error("Failed to initialize loyalty data",h),[3,6];case 5:return O.current=!1,[7];case 6:return[2]}})})},[]),s(function(){if(!O.current){e(void 0,void 0,void 0,function(){var e,n,o,r,i;return t(this,function(t){switch(t.label){case 0:if(!j.callbacks)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,Promise.all([j.callbacks.listSpendingMethodsByCartId(j.cartId),j.callbacks.getLoyaltyCustomerInfo(),j.callbacks.listLoyaltyProgramPointHistory({})])];case 2:return e=t.sent(),n=e[0],o=e[1],r=e[2],j.spendingMethods=n.map(function(e){return new S(e)}),j.user=o?new N(o):null,j.pointHistory=r?r.map(function(e){return new b(e)}):[],[3,4];case 3:return i=t.sent(),console.error("Failed to fetch cart dependent data",i),[3,4];case 4:return[2]}})})}},[j.cartId]);var W=function(e){j.selectedScreen=e},B=function(){j.setWidgetMode(u.MINI_MODE),setTimeout(function(){j.selectedScreen=d.MAIN_SCREEN},300)},U=j.selectedScreen===d.MAIN_SCREEN,$=r(null),G=$[0],H=$[1];s(function(){j.selectedScreen!==d.MAIN_SCREEN&&H(j.selectedScreen)},[j.selectedScreen]);var z=U?G:j.selectedScreen,F=j.loyaltyWidget.settings.position||y.RIGHT,V=j.loyaltyWidget.settings.type||E.DRAWER;return o.createElement(c,{i18n:a},o.createElement(k,{$layoutType:V,$widgetPosition:F,$widgetMode:j.currentWidgetMode,$position:(null==x?void 0:x.position)||(null===(L=window.ikasLoyaltyWidgetConfig)||void 0===L?void 0:L.position)||"fixed",onClick:function(){j.currentWidgetMode===u.WIDGET_MODE&&B()}},j.currentWidgetMode===u.MINI_MODE?o.createElement(A,null,o.createElement(R,{viewModel:j}),o.createElement(I,{viewModel:j})):o.createElement(P,{$layoutType:V,onClick:function(e){return e.stopPropagation()}},o.createElement(D,{$isActive:U,$isMain:!0},o.createElement(g,{viewModel:j,onClose:B,onNavigate:W})),o.createElement(D,{$isActive:!U,$isMain:!1},function(){switch(z){case d.CREDIT_SPENDING_METHODS_SCREEN:return o.createElement(h,{viewModel:j,onBack:function(){return W(d.MAIN_SCREEN)},onClose:B});case d.CREDIT_EARNING_METHODS_SCREEN:return o.createElement(v,{viewModel:j,onBack:function(){return W(d.MAIN_SCREEN)},onClose:B});case d.CREDIT_HISTORY_SCREEN:return o.createElement(C,{viewModel:j,onBack:function(){return W(d.MAIN_SCREEN)},onClose:B});case d.LOYALTY_LEVEL_SCREEN:return o.createElement(M,{viewModel:j,onBack:function(){return W(d.MAIN_SCREEN)},onClose:B});default:return null}}()))))});export{L as default};
|