@bikdotai/bik-component-library 0.0.679-3 → 0.0.679-5
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/dist/cjs/components/analytics-chips-and-dropdowns/chart/Pie/PieChartAnalytics.js +1 -1
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/components/country-code-picker/CountryCodePicker.d.ts +5 -0
- package/dist/cjs/components/country-code-picker/CountryCodePicker.js +1 -1
- package/dist/cjs/components/input/Input.d.ts +2 -0
- package/dist/cjs/components/input/Input.js +1 -1
- package/dist/cjs/components/input/Input.styled.d.ts +1 -0
- package/dist/cjs/components/input/Input.styled.js +1 -1
- package/dist/cjs/index.d.ts +0 -3
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/Pie/PieChartAnalytics.js +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/country-code-picker/CountryCodePicker.d.ts +5 -0
- package/dist/esm/components/country-code-picker/CountryCodePicker.js +1 -1
- package/dist/esm/components/input/Input.d.ts +2 -0
- package/dist/esm/components/input/Input.js +1 -1
- package/dist/esm/components/input/Input.styled.d.ts +1 -0
- package/dist/esm/components/input/Input.styled.js +1 -1
- package/dist/esm/index.d.ts +0 -3
- package/dist/esm/index.js +1 -1
- package/package.json +1 -5
- package/dist/cjs/components/feature-announcements/FeatureAnnouncementProvider.d.ts +0 -12
- package/dist/cjs/components/feature-announcements/FeatureAnnouncementProvider.js +0 -1
- package/dist/cjs/components/feature-announcements/MajorUpdatePopup.d.ts +0 -13
- package/dist/cjs/components/feature-announcements/MajorUpdatePopup.js +0 -1
- package/dist/cjs/components/feature-announcements/MajorUpdatePopup.style.d.ts +0 -8
- package/dist/cjs/components/feature-announcements/MajorUpdatePopup.style.js +0 -55
- package/dist/cjs/components/feature-announcements/MinorUpdatePopup.d.ts +0 -13
- package/dist/cjs/components/feature-announcements/MinorUpdatePopup.js +0 -1
- package/dist/cjs/components/feature-announcements/MinorUpdatePopup.style.d.ts +0 -12
- package/dist/cjs/components/feature-announcements/MinorUpdatePopup.style.js +0 -93
- package/dist/cjs/components/feature-announcements/VideoModal.d.ts +0 -8
- package/dist/cjs/components/feature-announcements/VideoModal.js +0 -1
- package/dist/cjs/components/feature-announcements/index.d.ts +0 -4
- package/dist/cjs/components/index.d.ts +0 -1
- package/dist/cjs/hooks/index.d.ts +0 -2
- package/dist/cjs/hooks/useElementVisibility.d.ts +0 -11
- package/dist/cjs/hooks/useElementVisibility.js +0 -1
- package/dist/cjs/hooks/useFeatureAnnouncements.d.ts +0 -17
- package/dist/cjs/hooks/useFeatureAnnouncements.js +0 -1
- package/dist/cjs/types/FeatureAnnouncement.types.d.ts +0 -27
- package/dist/cjs/types/index.d.ts +0 -1
- package/dist/esm/components/feature-announcements/FeatureAnnouncementProvider.d.ts +0 -12
- package/dist/esm/components/feature-announcements/FeatureAnnouncementProvider.js +0 -1
- package/dist/esm/components/feature-announcements/MajorUpdatePopup.d.ts +0 -13
- package/dist/esm/components/feature-announcements/MajorUpdatePopup.js +0 -1
- package/dist/esm/components/feature-announcements/MajorUpdatePopup.style.d.ts +0 -8
- package/dist/esm/components/feature-announcements/MajorUpdatePopup.style.js +0 -55
- package/dist/esm/components/feature-announcements/MinorUpdatePopup.d.ts +0 -13
- package/dist/esm/components/feature-announcements/MinorUpdatePopup.js +0 -1
- package/dist/esm/components/feature-announcements/MinorUpdatePopup.style.d.ts +0 -12
- package/dist/esm/components/feature-announcements/MinorUpdatePopup.style.js +0 -93
- package/dist/esm/components/feature-announcements/VideoModal.d.ts +0 -8
- package/dist/esm/components/feature-announcements/VideoModal.js +0 -1
- package/dist/esm/components/feature-announcements/index.d.ts +0 -4
- package/dist/esm/components/index.d.ts +0 -1
- package/dist/esm/hooks/index.d.ts +0 -2
- package/dist/esm/hooks/useElementVisibility.d.ts +0 -11
- package/dist/esm/hooks/useElementVisibility.js +0 -1
- package/dist/esm/hooks/useFeatureAnnouncements.d.ts +0 -17
- package/dist/esm/hooks/useFeatureAnnouncements.js +0 -1
- package/dist/esm/types/FeatureAnnouncement.types.d.ts +0 -27
- package/dist/esm/types/index.d.ts +0 -1
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import e from"styled-components";const t=e.div`
|
|
2
|
-
width: 959px;
|
|
3
|
-
height: 274px;
|
|
4
|
-
display: flex;
|
|
5
|
-
background-color: #212121;
|
|
6
|
-
border-radius: 4px;
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
position: relative;
|
|
9
|
-
`,i=e.div`
|
|
10
|
-
background-color: #212121;
|
|
11
|
-
width: 480px;
|
|
12
|
-
height: 274px;
|
|
13
|
-
position: relative;
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
justify-content: center;
|
|
17
|
-
padding: 8px;
|
|
18
|
-
`,n=e.div`
|
|
19
|
-
color: #9ca3af;
|
|
20
|
-
font-size: 14px;
|
|
21
|
-
text-align: center;
|
|
22
|
-
width: 290px;
|
|
23
|
-
height: 258px;
|
|
24
|
-
display: flex;
|
|
25
|
-
align-items: center;
|
|
26
|
-
justify-content: center;
|
|
27
|
-
`,o=e.div`
|
|
28
|
-
flex: 1;
|
|
29
|
-
display: flex;
|
|
30
|
-
margin: 0 8px 0 0;
|
|
31
|
-
flex-direction: column;
|
|
32
|
-
justify-content: space-between;
|
|
33
|
-
background: transparent;
|
|
34
|
-
`,l=e.div`
|
|
35
|
-
/* No specific styles, just a container */
|
|
36
|
-
`,p=e.h3`
|
|
37
|
-
font-size: 16px;
|
|
38
|
-
font-weight: 600;
|
|
39
|
-
padding: 36px 0 0 0;
|
|
40
|
-
color: #fff;
|
|
41
|
-
line-height: 1.25;
|
|
42
|
-
text-align: left;
|
|
43
|
-
`,a=e.div`
|
|
44
|
-
font-size: 14px;
|
|
45
|
-
line-height: 1.5;
|
|
46
|
-
color: rgba(255, 255, 255, 0.8);
|
|
47
|
-
text-align: left;
|
|
48
|
-
`,r=e.div`
|
|
49
|
-
position: absolute;
|
|
50
|
-
bottom: 16px;
|
|
51
|
-
right: 16px;
|
|
52
|
-
display: flex;
|
|
53
|
-
gap: 8px;
|
|
54
|
-
align-items: center;
|
|
55
|
-
`;export{o as StyledContentContainer,a as StyledDescription,n as StyledFeaturePreviewText,l as StyledHeaderContainer,i as StyledImageContainer,t as StyledMajorUpdateContainer,r as StyledNavigationContainer,p as StyledTitle};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FeatureAnnouncement } from '../../types/FeatureAnnouncement.types';
|
|
3
|
-
interface MinorUpdatePopupProps {
|
|
4
|
-
feature: FeatureAnnouncement;
|
|
5
|
-
currentIndex: number;
|
|
6
|
-
totalFeatures: number;
|
|
7
|
-
onSkip: () => void;
|
|
8
|
-
onExplore: () => void;
|
|
9
|
-
onPrevious: () => void;
|
|
10
|
-
onNext: () => void;
|
|
11
|
-
}
|
|
12
|
-
declare const MinorUpdatePopup: React.FC<MinorUpdatePopupProps>;
|
|
13
|
-
export default MinorUpdatePopup;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import{StyledMinorUpdateContainer as n,StyledImageContainer as i,StyledImageWrapper as o,StyledImageOverlay as l,StyledNewFeatureText as c,StyledFeaturePreviewText as d,StyledContentContainer as a,StyledHeaderContainer as s,StyledTitle as u,StyledDescription as h,StyledActionButtonsContainer as p,StyledUnderstoodText as f}from"./MinorUpdatePopup.style.js";const x=e=>{if(!e)return"";const t=document.createElement("textarea");return t.innerHTML=e,t.value},g=g=>{let{feature:m,currentIndex:b,totalFeatures:y,onSkip:j,onExplore:k,onPrevious:I,onNext:v}=g;return e(t,{children:r(n,{children:[e(i,{children:m.displayImage?r(o,{children:[e("img",{src:m.displayImage,alt:m.title,style:{width:"235px",height:"134px",objectFit:"cover",borderRadius:"4px",display:"block"},onError:e=>{m.image&&(e.target.src=m.image)}}),e(l,{children:e(c,{children:"New feature"})})]}):e(d,{children:"Feature Preview"})}),r(a,{children:[r(s,{children:[e(u,{children:m.title}),e(h,{dangerouslySetInnerHTML:{__html:x(m.content||m.body||"")}})]}),r(p,{children:[e(f,Object.assign({onClick:j},{children:"Understood"})),m.productVideo&&e("button",Object.assign({onClick:()=>{k()},style:{backgroundColor:"#4B1583",border:"none",color:"#ffffff",borderRadius:"4px",fontSize:"14px",fontWeight:"500",cursor:"pointer",width:"154px",height:"32px",transition:"all 0.2s",textAlign:"center",display:"flex",alignItems:"center",justifyContent:"center"}},{children:m.buttonText||"Explore the feature"}))]})]})]})})};export{g as default};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const StyledMinorUpdateContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
-
export declare const StyledImageContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
-
export declare const StyledImageWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
-
export declare const StyledImageOverlay: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
-
export declare const StyledNewFeatureText: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
6
|
-
export declare const StyledFeaturePreviewText: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
-
export declare const StyledContentContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
-
export declare const StyledHeaderContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
-
export declare const StyledTitle: import("styled-components").StyledComponent<"h3", any, {}, never>;
|
|
10
|
-
export declare const StyledDescription: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
|
-
export declare const StyledActionButtonsContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
-
export declare const StyledUnderstoodText: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import i from"styled-components";const t=i.div`
|
|
2
|
-
width: 519px;
|
|
3
|
-
height: 160px;
|
|
4
|
-
display: flex;
|
|
5
|
-
background-color: #ffffff;
|
|
6
|
-
border-radius: 4px;
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
position: relative;
|
|
9
|
-
box-shadow: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
|
|
10
|
-
`,e=i.div`
|
|
11
|
-
background-color: #f9fafb;
|
|
12
|
-
border-radius: 4px;
|
|
13
|
-
position: relative;
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
justify-content: center;
|
|
17
|
-
margin: 13px 10px 13px 10px;
|
|
18
|
-
width: 235px;
|
|
19
|
-
min-width: 235px;
|
|
20
|
-
max-width: 235px;
|
|
21
|
-
height: 134px;
|
|
22
|
-
`,o=i.div`
|
|
23
|
-
position: relative;
|
|
24
|
-
width: 235px;
|
|
25
|
-
height: 134px;
|
|
26
|
-
`,n=i.div`
|
|
27
|
-
position: absolute;
|
|
28
|
-
top: 0px;
|
|
29
|
-
left: 0px;
|
|
30
|
-
right: 0px;
|
|
31
|
-
height: 27px;
|
|
32
|
-
background-color: rgba(0, 0, 0, 0.26);
|
|
33
|
-
border-radius: 4px 4px 4px 4px;
|
|
34
|
-
display: flex;
|
|
35
|
-
align-items: center;
|
|
36
|
-
justify-content: center;
|
|
37
|
-
z-index: 10;
|
|
38
|
-
`,p=i.span`
|
|
39
|
-
color: #ffffff;
|
|
40
|
-
font-weight: 400;
|
|
41
|
-
font-size: 14px;
|
|
42
|
-
`,r=i.div`
|
|
43
|
-
color: #9ca3af;
|
|
44
|
-
font-size: 14px;
|
|
45
|
-
text-align: center;
|
|
46
|
-
width: 100%;
|
|
47
|
-
height: 100%;
|
|
48
|
-
display: flex;
|
|
49
|
-
align-items: center;
|
|
50
|
-
justify-content: center;
|
|
51
|
-
background-color: #f3f4f6;
|
|
52
|
-
border-radius: 4px;
|
|
53
|
-
`,x=i.div`
|
|
54
|
-
flex: 1;
|
|
55
|
-
display: flex;
|
|
56
|
-
margin: 13px 13px 13px 3px;
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
justify-content: space-between;
|
|
59
|
-
background: transparent;
|
|
60
|
-
`,a=i.div`
|
|
61
|
-
/* No specific styles, just a container */
|
|
62
|
-
`,l=i.h3`
|
|
63
|
-
font-size: 16px;
|
|
64
|
-
font-weight: 600;
|
|
65
|
-
padding: 0 0 0 0;
|
|
66
|
-
color: #212121;
|
|
67
|
-
line-height: 1.25;
|
|
68
|
-
text-align: left;
|
|
69
|
-
`,f=i.div`
|
|
70
|
-
font-size: 12px;
|
|
71
|
-
font-weight: 400;
|
|
72
|
-
line-height: 1.2;
|
|
73
|
-
color: #616161;
|
|
74
|
-
text-align: left;
|
|
75
|
-
max-height: 48px;
|
|
76
|
-
overflow: hidden;
|
|
77
|
-
display: -webkit-box;
|
|
78
|
-
-webkit-line-clamp: 3;
|
|
79
|
-
-webkit-box-orient: vertical;
|
|
80
|
-
`,s=i.div`
|
|
81
|
-
position: absolute;
|
|
82
|
-
bottom: 13px;
|
|
83
|
-
right: 10px;
|
|
84
|
-
display: flex;
|
|
85
|
-
gap: 16px;
|
|
86
|
-
align-items: center;
|
|
87
|
-
`,d=i.span`
|
|
88
|
-
color: #4b1583;
|
|
89
|
-
font-size: 14px;
|
|
90
|
-
font-weight: 500;
|
|
91
|
-
cursor: pointer;
|
|
92
|
-
transition: all 0.2s;
|
|
93
|
-
`;export{s as StyledActionButtonsContainer,x as StyledContentContainer,f as StyledDescription,r as StyledFeaturePreviewText,a as StyledHeaderContainer,e as StyledImageContainer,n as StyledImageOverlay,o as StyledImageWrapper,t as StyledMinorUpdateContainer,p as StyledNewFeatureText,l as StyledTitle,d as StyledUnderstoodText};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";const o=o=>{let{isOpen:r,videoUrl:i,onClose:n}=o;if(!r)return null;const c=i.includes("youtube.com")||i.includes("youtu.be")?i.replace("watch?v=","embed/").replace("youtu.be/","youtube.com/embed/"):i,s=i.includes("youtube.com")||i.includes("youtu.be");return e("div",Object.assign({style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.9)",zIndex:2e3,display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},onClick:e=>{e.target===e.currentTarget&&n()}},{children:t("div",Object.assign({style:{position:"relative",width:"90vw",height:"90vh",maxWidth:"1200px",maxHeight:"800px",backgroundColor:"black",borderRadius:"12px",overflow:"hidden",boxShadow:"0 25px 50px rgba(0, 0, 0, 0.8)"},onClick:e=>e.stopPropagation()},{children:[e("button",Object.assign({onClick:n,style:{position:"absolute",top:"20px",right:"20px",background:"rgba(0, 0, 0, 0.7)",border:"none",color:"white",fontSize:"24px",width:"40px",height:"40px",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,transition:"background-color 0.2s"},onMouseOver:e=>{e.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.9)"},onMouseOut:e=>{e.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.7)"}},{children:"×"})),e("div",Object.assign({style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"}},{children:i?s?e("iframe",{width:"100%",height:"100%",src:c,title:"Product Video",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,style:{borderRadius:"12px"}}):t("video",Object.assign({controls:!0,autoPlay:!0,style:{width:"100%",height:"100%",objectFit:"contain",borderRadius:"12px"}},{children:[e("source",{src:i,type:"video/mp4"}),e("source",{src:i,type:"video/webm"}),e("source",{src:i,type:"video/ogg"}),"Your browser does not support the video tag."]})):e("div",Object.assign({style:{color:"white",fontSize:"18px",textAlign:"center"}},{children:"No video available"}))}))]}))}))};export{o as VideoModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './feature-announcements';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface VisibilityState {
|
|
2
|
-
[elementId: string]: boolean;
|
|
3
|
-
}
|
|
4
|
-
interface ElementVisibilityHook {
|
|
5
|
-
visibleElements: VisibilityState;
|
|
6
|
-
observeElement: (elementId: string) => void;
|
|
7
|
-
unobserveElement: (elementId: string) => void;
|
|
8
|
-
isElementVisible: (elementId: string) => boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const useElementVisibility: () => ElementVisibilityHook;
|
|
11
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useState as t,useEffect as e,useCallback as r}from"react";const s=()=>{const[s,n]=t({}),[o,i]=t(new Set),[a,c]=t(null);e((()=>{const t=new IntersectionObserver((t=>{t.forEach((t=>{const e=t.target.id||t.target.getAttribute("data-feature-id");e&&n((r=>Object.assign(Object.assign({},r),{[e]:t.isIntersecting})))}))}),{threshold:.1,rootMargin:"50px"});return c(t),()=>{t.disconnect()}}),[]);const l=r((t=>{if(!a||o.has(t))return;const e=[`#${t}`,`[data-feature-id="${t}"]`,t.startsWith("#")||t.startsWith(".")||t.startsWith("[")?t:`#${t}`];let r=null;for(const t of e)if(r=document.querySelector(t),r)break;r&&(a.observe(r),i((e=>new Set([...e,t]))))}),[a,o]),u=r((t=>{if(!a||!o.has(t))return;const e=[`#${t}`,`[data-feature-id="${t}"]`,t.startsWith("#")||t.startsWith(".")||t.startsWith("[")?t:`#${t}`];let r=null;for(const t of e)if(r=document.querySelector(t),r)break;r&&(a.unobserve(r),i((e=>{const r=new Set(e);return r.delete(t),r})),n((e=>{const r=Object.assign({},e);return delete r[t],r})))}),[a,o]),b=r((t=>s[t]||!1),[s]);return{visibleElements:s,observeElement:l,unobserveElement:u,isElementVisible:b}};export{s as useElementVisibility};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FeatureAnnouncement } from '../types/FeatureAnnouncement.types';
|
|
2
|
-
export interface FeatureAnnouncementRepoInjected {
|
|
3
|
-
fetchVisibleFeatures: () => Promise<[any, FeatureAnnouncement[] | null]>;
|
|
4
|
-
getStoreFeatureProgress: (storeId: string) => Promise<[any, any | null]>;
|
|
5
|
-
fetchFeatureById: (featureId: string) => Promise<[any, FeatureAnnouncement | null]>;
|
|
6
|
-
markFeatureAsViewedForStore: (storeId: string, featureId: string) => Promise<[any]>;
|
|
7
|
-
isFeatureApplicableToCurrentPage: (feature: FeatureAnnouncement) => boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const useFeatureAnnouncements: ({ fetchVisibleFeatures, getStoreFeatureProgress, fetchFeatureById, markFeatureAsViewedForStore, isFeatureApplicableToCurrentPage, }: FeatureAnnouncementRepoInjected) => {
|
|
10
|
-
features: FeatureAnnouncement[];
|
|
11
|
-
majorUpdateFeatures: FeatureAnnouncement[];
|
|
12
|
-
minorUpdateFeatures: FeatureAnnouncement[];
|
|
13
|
-
isLoading: boolean;
|
|
14
|
-
error: string | null;
|
|
15
|
-
markFeatureAsViewed: (featureId: string) => Promise<void>;
|
|
16
|
-
refetch: () => Promise<void>;
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__awaiter as e}from"../_virtual/_tslib.js";import{useRouter as t}from"next/router";import{useState as r,useCallback as o,useEffect as a}from"react";const n=n=>{let{fetchVisibleFeatures:i,getStoreFeatureProgress:l,fetchFeatureById:s,markFeatureAsViewedForStore:u,isFeatureApplicableToCurrentPage:d}=n;const c=(()=>{const[e,t]=r(null);return a((()=>{if("undefined"!=typeof window){let e=null;try{if(e=localStorage.getItem("storeId")||localStorage.getItem("Bik/StoreId")||localStorage.getItem("currentStore")||localStorage.getItem("store"),!e){const t=localStorage.getItem("Bik/CurrentUser");t&&(e=JSON.parse(t).storeId)}e||(e=new URLSearchParams(window.location.search).get("storeId"))}catch(e){console.error("FeatureAnnouncements: Failed to get store ID",e)}t(e)}}),[]),e})(),f=t(),[p,y]=r([]),[g,m]=r([]),[w,F]=r([]),[v,h]=r(!1),[D,x]=r(null),U=o((()=>e(void 0,void 0,void 0,(function*(){if(c){h(!0),x(null);try{const[e,t]=yield i();if(e||!t)return console.error("FeatureAnnouncements: Failed to fetch features",e),void x("Failed to fetch features");const[r,o]=yield l(c);r&&console.warn("FeatureAnnouncements: Progress fetch failed, treating all features as new",r);const a=new Date,n="undefined"!=typeof window?window.location.pathname:"",s=e=>{if(!e.expirationDate)return!0;let t;return"object"==typeof e.expirationDate&&null!==e.expirationDate&&("seconds"in e.expirationDate||"nanoseconds"in e.expirationDate)?t=new Date(1e3*e.expirationDate.seconds):"string"==typeof e.expirationDate?t=new Date(e.expirationDate):e.expirationDate instanceof Date&&(t=e.expirationDate),!(!t||isNaN(t.getTime()))&&a<t},u=e=>{if("Major"===e.featureUpdateType){let t=[];return Array.isArray(e.pageUrls)?t=e.pageUrls:"object"==typeof e.pageUrls&&null!==e.pageUrls&&"length"in e.pageUrls&&(t=Array.from(e.pageUrls)),t.includes(n)}return!0},f=t.filter((e=>{var t;return!((null===(t=null==o?void 0:o.viewedFeatures)||void 0===t?void 0:t[e.id])||!1)&&d(e)&&s(e)&&u(e)})),p=f.filter((e=>"Major"===e.featureUpdateType)),g=f.filter((e=>"Minor"===e.featureUpdateType));y(f),m(p),setTimeout((()=>{F(g)}),2e3)}catch(e){console.error("FeatureAnnouncements: Unexpected error in fetchFeatures",e),x("An unexpected error occurred")}finally{h(!1)}}}))),[c,i,l,d]),I=o((t=>e(void 0,void 0,void 0,(function*(){h(!0),x(null);try{const[e,r]=yield s(t);if(e||!r)return void x("Failed to fetch feature by ID");"Major"===r.featureUpdateType?m([r]):F([r]),y([r])}catch(e){x("An unexpected error occurred while fetching by ID")}finally{h(!1)}}))),[s]),A=o((t=>e(void 0,void 0,void 0,(function*(){if(!c)return;const[e]=yield u(c,t);e?(console.warn("FeatureAnnouncements: Failed to mark feature as viewed, removing from local state anyway",e),y((e=>e.filter((e=>e.id!==t)))),m((e=>e.filter((e=>e.id!==t)))),F((e=>e.filter((e=>e.id!==t))))):(y((e=>e.filter((e=>e.id!==t)))),m((e=>e.filter((e=>e.id!==t)))),F((e=>e.filter((e=>e.id!==t)))))}))),[c,u]);return a((()=>{if(!f.isReady)return;const e=f.query.featureId;e?I(e):U()}),[f.isReady,f.query,U,I]),{features:p,majorUpdateFeatures:g,minorUpdateFeatures:w,isLoading:v,error:D,markFeatureAsViewed:A,refetch:U}};export{n as useFeatureAnnouncements};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface FeatureAnnouncement {
|
|
2
|
-
id: string;
|
|
3
|
-
title: string;
|
|
4
|
-
body: string;
|
|
5
|
-
content: string;
|
|
6
|
-
buttonText: string;
|
|
7
|
-
displayImage: string;
|
|
8
|
-
featureTag: string;
|
|
9
|
-
featureUpdateType: 'Major' | 'Minor';
|
|
10
|
-
image: string;
|
|
11
|
-
module: string[];
|
|
12
|
-
pageUrls: string[];
|
|
13
|
-
productVideo: string;
|
|
14
|
-
redirectUrl: string;
|
|
15
|
-
updates: string;
|
|
16
|
-
visibility: boolean;
|
|
17
|
-
createdAt: any;
|
|
18
|
-
expirationDate?: {
|
|
19
|
-
seconds: number;
|
|
20
|
-
} | string | Date;
|
|
21
|
-
}
|
|
22
|
-
export interface StoreFeatureProgress {
|
|
23
|
-
storeId: string;
|
|
24
|
-
viewedFeatures: {
|
|
25
|
-
[featureId: string]: boolean;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { FeatureAnnouncement } from './FeatureAnnouncement.types';
|