@equinor/subsurface-app-management 1.1.18 → 1.1.19

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.
@@ -1,3 +1,5 @@
1
+ import { Query } from '@tanstack/react-query';
1
2
  export declare const useGetTutorialsForApp: (appName: string) => import("@tanstack/react-query").UseQueryResult<import("../..").Tutorial[], Error>;
2
3
  export declare const useGetTutorialSasToken: () => import("@tanstack/react-query").UseQueryResult<string, Error>;
3
4
  export declare const useTutorial: () => import("./TutorialProvider").TutorialContextType;
5
+ export declare const useIsFetchingWithTimeout: (predicateFn: (query: Query) => boolean) => boolean;
@@ -1 +1 @@
1
- import{useContext as r}from"react";import{useQuery as o}from"@tanstack/react-query";import{TutorialService as t}from"../../api/services/TutorialService.js";import{GET_TUTORIALS_FOR_APP as e,GET_TUTORIALS_SAS_TOKEN as i}from"../../constants/queryKeys.js";import{TutorialContext as s}from"./TutorialProvider.js";const u=r=>o({queryKey:[e,r],queryFn:()=>t.getTutorialsForApplication(r)}),a=()=>o({queryKey:[i],queryFn:()=>t.getTutorialSasToken()}),n=()=>{const o=r(s);if(void 0===o)throw new Error("'useTutorial' must be used within a TutorialProvider");return o};export{a as useGetTutorialSasToken,u as useGetTutorialsForApp,n as useTutorial};
1
+ import{useState as r,useEffect as t,useContext as e}from"react";import{useIsFetching as o,useQuery as i}from"@tanstack/react-query";import{TutorialService as u}from"../../api/services/TutorialService.js";import{GET_TUTORIALS_FOR_APP as s,GET_TUTORIALS_SAS_TOKEN as a}from"../../constants/queryKeys.js";import{TutorialContext as n}from"./TutorialProvider.js";const c=r=>i({queryKey:[s,r],queryFn:()=>u.getTutorialsForApplication(r)}),m=()=>i({queryKey:[a],queryFn:()=>u.getTutorialSasToken()}),p=()=>{const r=e(n);if(void 0===r)throw new Error("'useTutorial' must be used within a TutorialProvider");return r},y=e=>{const[i,u]=r(!0),s=o({predicate:e})>0;return t((()=>{const r=setTimeout((()=>{u(s)}),100);return()=>clearTimeout(r)}),[s]),i||i!==s};export{m as useGetTutorialSasToken,c as useGetTutorialsForApp,y as useIsFetchingWithTimeout,p as useTutorial};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{createContext as r,useState as o,useRef as i,useMemo as n,useCallback as s,useEffect as a}from"react";import{useSearchParams as l}from"react-router-dom";import{useIsFetching as m}from"@tanstack/react-query";import{TUTORIAL_SEARCH_PARAM_KEY as u}from"./TutorialProvider.const.js";import{getAllElementsToHighlight as c}from"./TutorialProvider.utils.js";import d from"./TutorialProviderInner.js";import{getAppName as p,getEnvironmentName as h}from"../../utils/environment.js";const v=r(void 0),f=({children:r,overrideAppName:f,overrideEnvironmentName:y,customStepComponents:g,tutorials:E,ignoredQueryKeys:T})=>{const[w,N]=o(void 0),[P,k]=o(!1),[S,j]=l(),[C,A]=o(void 0),[x,I]=o(0),[F,H]=o(void 0),[L,M]=o(window.innerWidth),V=m({predicate:e=>!T?.some((t=>e.queryKey.includes(t)))})>0,W=i(null),_=f??p(import.meta.env.VITE_NAME),q=y??h(import.meta.env.VITE_ENVIRONMENT_NAME),z=n((()=>{if(w)return w.steps.at(x)}),[w,x]),K=n((()=>!!w&&x>=w?.steps.length-1),[w,x]),O=s((()=>{S.delete(u),j(S),A(void 0)}),[S,j]);return a((()=>{if(C)return;const e=S.get(u);e&&A(e)}),[S,C]),a((()=>{const e=()=>{M(window.innerWidth)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),a((()=>{if(!w||P||V)return;const e=c(w);e.every((e=>null!==e))?H(e):(async()=>{await new Promise((e=>setTimeout(e,300)));const e=c(w);e.every((e=>null!==e))?H(e):(console.error("Could not find all elements to highlight for the tutorial. \n This is a list of elements that were found for each step: ",e),k(!0))})().catch((e=>{console.error("Error trying to get elements to highlight",e)}))}),[w,x,P,C,V]),a((()=>{if(!w||P||V)return;const e=w.steps.filter((e=>void 0!==e.key&&null!==e.key)).map((e=>e.key));if(0===e.length)return;const t=g?.map((e=>e.key));if(!t||0===t.length)return console.error("Could not find any custom components passed to the TutorialProvider \nExpected these keys for the active tutorial: ",e),void k(!0);e.map((e=>e&&t?.includes(e))).some((e=>!0!==e))&&(console.error("Could not find the custom components related to the active tutorial. \n The active tutorial expected to find these keys: ",e,"\n However in the custom components we only found these keys: ",t),k(!0))}),[w,V,g,P]),e(v.Provider,{value:{currentStepObject:z,activeTutorial:w,setActiveTutorial:N,currentStep:x,setCurrentStep:I,allElementsToHighlight:F,setAllElementsToHighlight:H,customStepComponents:g,isLastStep:K,dialogRef:W,clearSearchParam:O,shortNameFromParams:C,setShortNameFromParams:A,tutorialsFromProps:E??[],tutorialError:P,setTutorialError:k,viewportWidth:L,appName:_,environmentName:q},children:[t(d,{}),r]})};export{v as TutorialContext,f as TutorialProvider};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{createContext as r,useState as o,useRef as i,useMemo as n,useCallback as s,useEffect as l}from"react";import{useSearchParams as m}from"react-router-dom";import{TUTORIAL_SEARCH_PARAM_KEY as a}from"./TutorialProvider.const.js";import{getAllElementsToHighlight as u}from"./TutorialProvider.utils.js";import d from"./TutorialProviderInner.js";import{useIsFetchingWithTimeout as c}from"./TutorialProvider.hooks.js";import{getAppName as p,getEnvironmentName as h}from"../../utils/environment.js";const v=r(void 0),f=({children:r,overrideAppName:f,overrideEnvironmentName:y,customStepComponents:g,tutorials:T,ignoredQueryKeys:E})=>{const[w,N]=o(void 0),[P,k]=o(!1),[S,j]=m(),[C,A]=o(void 0),[x,I]=o(0),[F,H]=o(void 0),[L,M]=o(window.innerWidth),V=c((e=>!E?.some((t=>e.queryKey.includes(t))))),W=i(null),_=f??p(import.meta.env.VITE_NAME),z=y??h(import.meta.env.VITE_ENVIRONMENT_NAME),K=n((()=>{if(w)return w.steps.at(x)}),[w,x]),O=n((()=>!!w&&x>=w?.steps.length-1),[w,x]),R=s((()=>{S.delete(a),j(S),A(void 0)}),[S,j]);return l((()=>{if(C)return;const e=S.get(a);e&&A(e)}),[S,C]),l((()=>{const e=()=>{M(window.innerWidth)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),l((()=>{if(!w||P||V)return;const e=u(w);e.every((e=>null!==e))?H(e):(async()=>{await new Promise((e=>setTimeout(e,300)));const e=u(w);e.every((e=>null!==e))?H(e):(console.error("Could not find all elements to highlight for the tutorial. \n This is a list of elements that were found for each step: ",e),k(!0))})().catch((e=>{console.error("Error trying to get elements to highlight",e)}))}),[w,x,P,C,V]),l((()=>{if(!w||P||V)return;const e=w.steps.filter((e=>void 0!==e.key&&null!==e.key)).map((e=>e.key));if(0===e.length)return;const t=g?.map((e=>e.key));if(!t||0===t.length)return console.error("Could not find any custom components passed to the TutorialProvider \nExpected these keys for the active tutorial: ",e),void k(!0);e.map((e=>e&&t?.includes(e))).some((e=>!0!==e))&&(console.error("Could not find the custom components related to the active tutorial. \n The active tutorial expected to find these keys: ",e,"\n However in the custom components we only found these keys: ",t),k(!0))}),[w,V,g,P]),e(v.Provider,{value:{currentStepObject:K,activeTutorial:w,setActiveTutorial:N,currentStep:x,setCurrentStep:I,allElementsToHighlight:F,setAllElementsToHighlight:H,customStepComponents:g,isLastStep:O,dialogRef:W,clearSearchParam:R,shortNameFromParams:C,setShortNameFromParams:A,tutorialsFromProps:T??[],tutorialError:P,setTutorialError:k,viewportWidth:L,appName:_,environmentName:z},children:[t(d,{}),r]})};export{v as TutorialContext,f as TutorialProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/subsurface-app-management",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
4
4
  "description": "React Typescript components/hooks to communicate with equinor/sam",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",