@ikas/loyalty-widget-renderer 1.0.0-alpha.13 → 1.0.0-alpha.14
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/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 r,{useState as o,useRef as i,useEffect as s}from"react";import{observer as c}from'./../ext/mobx-react/dist/mobxreact.esm.js';import'./../ext/react-i18next/dist/es/context.js';import{I18nextProvider as a}from'./../ext/react-i18next/dist/es/I18nextProvider.js';import l from"./utils/i18n.js";import{LoyaltyWidgetScreenTypeEnum as d,EarningMethodTypeEnum as u,LoyaltyProgramFilterTypeEnum as m,LoyaltyProgramMethodSpendingTypeEnum as f}from"../models/types/index.js";import p from"./screens/main-screen/index.js";import
|
|
1
|
+
import{__awaiter as e,__generator as t,__spreadArray as n}from'./../ext/tslib/tslib.es6.mjs.js';import r,{useState as o,useRef as i,useEffect as s}from"react";import{observer as c}from'./../ext/mobx-react/dist/mobxreact.esm.js';import'./../ext/react-i18next/dist/es/context.js';import{I18nextProvider as a}from'./../ext/react-i18next/dist/es/I18nextProvider.js';import l from"./utils/i18n.js";import{LoyaltyWidgetScreenTypeEnum as d,EarningMethodTypeEnum as u,LoyaltyProgramFilterTypeEnum as m,LoyaltyProgramMethodSpendingTypeEnum as f}from"../models/types/index.js";import p from"./screens/main-screen/index.js";import y from"./screens/credit-spending-methods-screen/index.js";import E from"./screens/credit-earning-methods-screen/index.js";import g from"./screens/credit-history-screen/index.js";import h from"./screens/loyalty-level-screen/index.js";import{LoyaltyWidgetViewModel as v}from"../models/index.js";import{LoyaltyWidget as C}from"../models/loyalty-widget/index.js";import{LoyaltyProgramSpendingMethod as R}from"../models/loyalty-program-spending-method/index.js";import{LoyaltyCustomerInfo as b}from"../models/loyalty-customer-info/index.js";import{LoyaltyProgramEarningMethod as I}from"../models/loyalty-program-earning-method/index.js";import{LoyaltyProgramPointHistory as S}from"../models/loyalty-program-point-history/index.js";import{Container as _,Drawer as k,ScreenWrapper as A}from"./style.js";var N=c(function(c){var N,w=c.config,T=o(function(){var e=w||window.ikasLoyaltyWidgetConfig;return new v({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.callbacks)})[0],M=i(!0);s(function(){e(void 0,void 0,void 0,function(){var e,r,o,i,s,c,a,l,d,p,y,E,g,h;return t(this,function(t){switch(t.label){case 0:if(!T.callbacks)return[3,6];t.label=1;case 1:return t.trys.push([1,4,5,6]),e=[T.callbacks.getLoyaltyWidget(),T.callbacks.listEarningMethods(),T.callbacks.listLoyaltyProgramTier({includeDeleted:!1})],T.cartId&&(e.push(T.callbacks.listSpendingMethodsByCartId(T.cartId)),e.push(T.callbacks.getLoyaltyCustomerInfo()),e.push(T.callbacks.listLoyaltyProgramPointHistory({}))),[4,Promise.all(e)];case 2:return r=t.sent(),o=r[0],i=r[1],s=r[2],c=[],a=null,l=[],T.cartId&&(c=r[3],a=r[4],l=r[5]),T.loyaltyWidget=new C(o),T.earningMethods=i.map(function(e){return new I(e)}),T.tiers=s||[],T.cartId&&(T.spendingMethods=c.map(function(e){return new R(e)}),T.user=a?new b(a):null,T.pointHistory=l?l.map(function(e){return new S(e)}):[]),d=new Set,p=new Set,y=new Set,E=new Set,T.earningMethods.forEach(function(e){var t,r;e.methodType===u.ORDER_CREATE&&n(n([],(null===(t=e.orderSettings)||void 0===t?void 0:t.productFilters)||[],!0),(null===(r=e.productSettings)||void 0===r?void 0:r.productFilters)||[],!0).forEach(function(e){e.type===m.PRODUCT_AND_VARIANT?e.idList.forEach(function(e){return d.add(e)}):e.type===m.CATEGORY?e.idList.forEach(function(e){return p.add(e)}):e.type===m.PRODUCT_BRAND?e.idList.forEach(function(e){return y.add(e)}):e.type===m.PRODUCT_TAG&&e.idList.forEach(function(e){return E.add(e)})})}),T.spendingMethods&&T.spendingMethods.forEach(function(e){var t,n;e.type===f.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===m.PRODUCT_AND_VARIANT?e.idList.forEach(function(e){return d.add(e)}):e.type===m.CATEGORY?e.idList.forEach(function(e){return p.add(e)}):e.type===m.PRODUCT_BRAND?e.idList.forEach(function(e){return y.add(e)}):e.type===m.PRODUCT_TAG&&e.idList.forEach(function(e){return E.add(e)})})}),g=[],d.size>0&&T.callbacks.getProducts&&g.push(T.callbacks.getProducts(Array.from(d)).then(function(e){return T.products=e})),p.size>0&&T.callbacks.getCategories&&g.push(T.callbacks.getCategories(Array.from(p)).then(function(e){return T.categories=e})),y.size>0&&T.callbacks.getBrands&&g.push(T.callbacks.getBrands(Array.from(y)).then(function(e){return T.brands=e})),E.size>0&&T.callbacks.getTags&&g.push(T.callbacks.getTags(Array.from(E)).then(function(e){return T.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 M.current=!1,[7];case 6:return[2]}})})},[]),s(function(){if(!M.current){e(void 0,void 0,void 0,function(){var e,n,r,o,i;return t(this,function(t){switch(t.label){case 0:if(!T.callbacks)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,Promise.all([T.callbacks.listSpendingMethodsByCartId(T.cartId),T.callbacks.getLoyaltyCustomerInfo(),T.callbacks.listLoyaltyProgramPointHistory({})])];case 2:return e=t.sent(),n=e[0],r=e[1],o=e[2],T.spendingMethods=n.map(function(e){return new R(e)}),T.user=r?new b(r):null,T.pointHistory=o?o.map(function(e){return new S(e)}):[],[3,4];case 3:return i=t.sent(),console.error("Failed to fetch cart dependent data",i),[3,4];case 4:return[2]}})})}},[T.cartId]);var L=function(e){T.selectedScreen=e},P=function(){var e;(null===(e=T.callbacks)||void 0===e?void 0:e.onWidgetClose)&&T.callbacks.onWidgetClose()},x=T.selectedScreen===d.MAIN_SCREEN,j=o(null),D=j[0],O=j[1];s(function(){T.selectedScreen!==d.MAIN_SCREEN&&O(T.selectedScreen)},[T.selectedScreen]);var B=x?D:T.selectedScreen;return r.createElement(a,{i18n:l},r.createElement(_,{$position:(null==w?void 0:w.position)||(null===(N=window.ikasLoyaltyWidgetConfig)||void 0===N?void 0:N.position)||"fixed"},r.createElement(k,null,r.createElement(A,{$isActive:x,$isMain:!0},r.createElement(p,{viewModel:T,onClose:P,onNavigate:L})),r.createElement(A,{$isActive:!x,$isMain:!1},function(){switch(B){case d.CREDIT_SPENDING_METHODS_SCREEN:return r.createElement(y,{viewModel:T,onBack:function(){return L(d.MAIN_SCREEN)},onClose:P});case d.CREDIT_EARNING_METHODS_SCREEN:return r.createElement(E,{viewModel:T,onBack:function(){return L(d.MAIN_SCREEN)},onClose:P});case d.CREDIT_HISTORY_SCREEN:return r.createElement(g,{viewModel:T,onBack:function(){return L(d.MAIN_SCREEN)},onClose:P});case d.LOYALTY_LEVEL_SCREEN:return r.createElement(h,{viewModel:T,onBack:function(){return L(d.MAIN_SCREEN)},onClose:P});default:return null}}()))))});export{N as default};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export declare const Container: import("styled-components").StyledComponent<"div", any, {
|
|
1
|
+
export declare const Container: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
$position?: "fixed" | "absolute";
|
|
3
|
+
}, never>;
|
|
2
4
|
export declare const Drawer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
5
|
export declare const ScreenWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
4
6
|
$isActive: boolean;
|
package/build/renderer/style.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__makeTemplateObject as n}from'./../ext/tslib/tslib.es6.mjs.js';import o,{css as t}from"styled-components";var i,r,e,f,a,s=o.div(i||(i=n(["\n position:
|
|
1
|
+
import{__makeTemplateObject as n}from'./../ext/tslib/tslib.es6.mjs.js';import o,{css as t}from"styled-components";var i,r,e,f,a,s=o.div(i||(i=n(["\n position: ",";\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n\n width: 100%;\n height: 100vh;\n background-color: rgba(0, 0, 0, 0.5);\n z-index: 9999;\n"],["\n position: ",";\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n\n width: 100%;\n height: 100vh;\n background-color: rgba(0, 0, 0, 0.5);\n z-index: 9999;\n"])),function(n){return n.$position||"fixed"}),d=o.div(r||(r=n(["\n position: absolute;\n top: 0;\n right: 0;\n width: 520px;\n max-width: 100%;\n height: 100%;\n background-color: #ffffff;\n \n overflow-x: hidden;\n box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);\n"],["\n position: absolute;\n top: 0;\n right: 0;\n width: 520px;\n max-width: 100%;\n height: 100%;\n background-color: #ffffff;\n \n overflow-x: hidden;\n box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);\n"]))),h=o.div(a||(a=n(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: #ffffff;\n transition: transform 0.3s ease-in-out;\n overflow-y: auto;\n\n ","\n"],["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: #ffffff;\n transition: transform 0.3s ease-in-out;\n overflow-y: auto;\n\n ","\n"])),function(o){var i=o.$isActive;return o.$isMain?t(e||(e=n(["\n transform: translateX(",");\n z-index: 1;\n "],["\n transform: translateX(",");\n z-index: 1;\n "])),i?"0%":"-100%"):t(f||(f=n(["\n transform: translateX(",");\n z-index: 2;\n "],["\n transform: translateX(",");\n z-index: 2;\n "])),i?"0%":"100%")});export{s as Container,d as Drawer,h as ScreenWrapper};
|