@equinor/subsurface-app-management 2.5.1 → 2.5.2
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.
|
@@ -4,6 +4,7 @@ interface TutorialContextType {
|
|
|
4
4
|
allTutorials: MyTutorialDto[];
|
|
5
5
|
tutorialsOnThisPage: MyTutorialDto[];
|
|
6
6
|
unseenTutorialsOnThisPage: MyTutorialDto[];
|
|
7
|
+
seenTutorialIDs: string[];
|
|
7
8
|
activeTutorial: MyTutorialDto | undefined;
|
|
8
9
|
startTutorial: (tutorialId: string) => void;
|
|
9
10
|
skipTutorial: (tutorialId: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{createContext as o,useContext as t,useState as i,useMemo as e}from"react";import{useLocation as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{createContext as o,useContext as t,useState as i,useMemo as e}from"react";import{useLocation as s,matchPath as n}from"react-router";import{useSeenTutorials as a}from"./useSeenTutorials.js";import"../FeatureToggleProvider.js";import"@tanstack/react-query";import"../../api/core/OpenAPI.js";import{useTutorialsQuery as u}from"../../hooks/useTutorialsQuery.js";import{usePrefetchTutorialStepImages as d}from"./hooks/usePrefetchTutorialStepImages.js";const l=o(void 0);function p(){const r=t(l);if(void 0===r)throw new Error("'useTutorials' must be used within provider");return r}const c=({children:o})=>{const{pathname:t}=s(),{data:p=[]}=u(),[c,v]=i(void 0),[f,m]=i(void 0),[h,T]=a();d();const w=e((()=>p?.filter((r=>null!==n(r.path,t)))),[t,p]),g=e((()=>w?.filter((r=>!h.includes(r.id)&&r.willPopUp))),[h,w]);return r(l.Provider,{value:{allTutorials:p,tutorialsOnThisPage:w,unseenTutorialsOnThisPage:g,activeTutorial:c,activeStep:f,seenTutorialIDs:h,startTutorial:r=>{if(!p?.some((o=>r===o.id)))throw new Error("Tutorial not found");v(p.find((o=>r===o.id))),m(0)},skipTutorial:r=>{c&&c.id===r&&(v(void 0),m(void 0)),T(r)},goToNextStep:()=>{if(!c)throw new Error("No currently active tutorial!");if(void 0===f)throw new Error("activeStep is undefined!");f+1>=c.steps.length?(T(c.id),v(void 0),m(void 0)):m(f+1)},goToPreviousStep:()=>{if(!c)throw new Error("No currently active tutorial!");if(void 0===f)throw new Error("activeStep is undefined!");0===f?(v(void 0),m(void 0)):m(f-1)}},children:o})};export{l as TutorialDataContext,c as TutorialProvider,p as useTutorials};
|