@equinor/subsurface-app-management 2.3.1 → 2.5.0

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.
Files changed (44) hide show
  1. package/dist/api/index.d.ts +2 -0
  2. package/dist/api/models/MyTutorialDto.d.ts +9 -0
  3. package/dist/api/models/StepDto.d.ts +8 -0
  4. package/dist/api/services/TutorialService.d.ts +23 -0
  5. package/dist/api/services/TutorialService.js +1 -1
  6. package/dist/components/Feature/Feature.js +1 -1
  7. package/dist/constants/queryKeys.d.ts +1 -0
  8. package/dist/constants/queryKeys.js +1 -1
  9. package/dist/hooks/index.d.ts +5 -4
  10. package/dist/hooks/useTutorialStepImage.d.ts +1 -0
  11. package/dist/hooks/useTutorialStepImage.js +1 -0
  12. package/dist/hooks/useTutorialsQuery.d.ts +1 -0
  13. package/dist/hooks/useTutorialsQuery.js +1 -0
  14. package/dist/index.js +1 -1
  15. package/dist/providers/OldTutorialProvider/OldTutorialDialog.d.ts +6 -0
  16. package/dist/providers/OldTutorialProvider/OldTutorialDialog.js +1 -0
  17. package/dist/providers/OldTutorialProvider/OldTutorialProvider.d.ts +47 -0
  18. package/dist/providers/{TutorialProvider/TutorialProvider.hooks.d.ts → OldTutorialProvider/OldTutorialProvider.hooks.d.ts} +2 -1
  19. package/dist/providers/OldTutorialProvider/OldTutorialProvider.hooks.js +1 -0
  20. package/dist/providers/OldTutorialProvider/OldTutorialProvider.js +1 -0
  21. package/dist/providers/OldTutorialProvider/OldTutorialProvider.utils.js +1 -0
  22. package/dist/providers/OldTutorialProvider/OldTutorialProviderInner.d.ts +3 -0
  23. package/dist/providers/OldTutorialProvider/OldTutorialProviderInner.js +1 -0
  24. package/dist/providers/OldTutorialProvider/OldTutorialStepIndicator.d.ts +8 -0
  25. package/dist/providers/TutorialProvider/TutorialProvider.d.ts +14 -40
  26. package/dist/providers/TutorialProvider/TutorialProvider.js +1 -1
  27. package/dist/providers/TutorialProvider/useSeenTutorials.d.ts +2 -0
  28. package/dist/providers/TutorialProvider/useSeenTutorials.js +1 -0
  29. package/dist/providers/index.d.ts +3 -2
  30. package/package.json +1 -3
  31. package/dist/providers/TutorialProvider/TutorialDialog.d.ts +0 -6
  32. package/dist/providers/TutorialProvider/TutorialDialog.js +0 -1
  33. package/dist/providers/TutorialProvider/TutorialProvider.hooks.js +0 -1
  34. package/dist/providers/TutorialProvider/TutorialProvider.utils.js +0 -1
  35. package/dist/providers/TutorialProvider/TutorialProviderInner.d.ts +0 -3
  36. package/dist/providers/TutorialProvider/TutorialProviderInner.js +0 -1
  37. package/dist/providers/TutorialProvider/TutorialStepIndicator.d.ts +0 -8
  38. /package/dist/providers/{TutorialProvider/TutorialProvider.const.d.ts → OldTutorialProvider/OldTutorialProvider.const.d.ts} +0 -0
  39. /package/dist/providers/{TutorialProvider/TutorialProvider.const.js → OldTutorialProvider/OldTutorialProvider.const.js} +0 -0
  40. /package/dist/providers/{TutorialProvider/TutorialProvider.styles.d.ts → OldTutorialProvider/OldTutorialProvider.styles.d.ts} +0 -0
  41. /package/dist/providers/{TutorialProvider/TutorialProvider.styles.js → OldTutorialProvider/OldTutorialProvider.styles.js} +0 -0
  42. /package/dist/providers/{TutorialProvider/TutorialProvider.types.d.ts → OldTutorialProvider/OldTutorialProvider.types.d.ts} +0 -0
  43. /package/dist/providers/{TutorialProvider/TutorialProvider.utils.d.ts → OldTutorialProvider/OldTutorialProvider.utils.d.ts} +0 -0
  44. /package/dist/providers/{TutorialProvider/TutorialStepIndicator.js → OldTutorialProvider/OldTutorialStepIndicator.js} +0 -0
@@ -18,6 +18,8 @@ export type { ServiceNowIncidentResponse } from './models/ServiceNowIncidentResp
18
18
  export { ServiceNowUrgency } from './models/ServiceNowUrgency';
19
19
  export type { Step } from './models/Step';
20
20
  export type { Tutorial } from './models/Tutorial';
21
+ export type { MyTutorialDto } from './models/MyTutorialDto';
22
+ export type { StepDto } from './models/StepDto';
21
23
  export { TutorialPosition } from './models/TutorialPosition';
22
24
  export type { MyFeatureDto } from './models/MyFeatureDto';
23
25
  export { AmplifyApplicationService } from './services/AmplifyApplicationService';
@@ -0,0 +1,9 @@
1
+ import type { StepDto } from './StepDto';
2
+ export type MyTutorialDto = {
3
+ id: string;
4
+ name: string;
5
+ path: string;
6
+ application: string;
7
+ steps: Array<StepDto>;
8
+ willPopUp: boolean;
9
+ };
@@ -0,0 +1,8 @@
1
+ export type StepDto = {
2
+ id: string | null;
3
+ title?: string | null;
4
+ body?: string | null;
5
+ imgUrl?: string | null;
6
+ highlightElement?: boolean | null;
7
+ custom?: boolean | null;
8
+ };
@@ -1,4 +1,5 @@
1
1
  import { CancelablePromise, Tutorial } from './..';
2
+ import { MyTutorialDto } from '../models/MyTutorialDto';
2
3
  export declare class TutorialService {
3
4
  /**
4
5
  * Gets all tutorials for Application
@@ -13,4 +14,26 @@ export declare class TutorialService {
13
14
  * @throws ApiError
14
15
  */
15
16
  static getTutorialSasToken(): CancelablePromise<string>;
17
+ /**
18
+ * Gets all tutorials for Application
19
+ * @param applicationName
20
+ * @param includeDrafts
21
+ * @returns TutorialDto OK
22
+ * @throws ApiError
23
+ */
24
+ static getMyTutorials(applicationName: string): CancelablePromise<Array<MyTutorialDto>>;
25
+ /**
26
+ * Gets all draft tutorials for an application
27
+ * @param applicationName
28
+ * @returns TutorialDto OK
29
+ * @throws ApiError
30
+ */
31
+ static getDraftTutorialsForApplication(applicationName: string): CancelablePromise<Array<MyTutorialDto>>;
32
+ /**
33
+ * Get tutorial image
34
+ * @param path
35
+ * @returns string OK
36
+ * @throws ApiError
37
+ */
38
+ static getTutorialImage(path: string): CancelablePromise<string>;
16
39
  }
@@ -1 +1 @@
1
- import{OpenAPI_JSEMBARK_Prod as t}from"../core/OpenAPI.js";import{request as o}from"../core/request.js";class r{static getTutorialsForApplication(r){return o(t,{method:"GET",url:"/api/v1/Tutorial/{applicationName}",path:{applicationName:r}})}static getTutorialSasToken(){return o(t,{method:"GET",url:"/api/v1/Tutorial/SASToken"})}}export{r as TutorialService};
1
+ import{OpenAPI_JSEMBARK_Prod as t,OpenAPI_SAM_Prod as a}from"../core/OpenAPI.js";import{request as r}from"../core/request.js";class i{static getTutorialsForApplication(a){return r(t,{method:"GET",url:"/api/v1/Tutorial/{applicationName}",path:{applicationName:a}})}static getTutorialSasToken(){return r(t,{method:"GET",url:"/api/v1/Tutorial/SASToken"})}static getMyTutorials(t){return r(a,{method:"GET",url:"/api/v1/Tutorial/{applicationName}/false",path:{applicationName:t}})}static getDraftTutorialsForApplication(t){return r(a,{method:"GET",url:"/api/v1/Tutorial/draft/{applicationName}",path:{applicationName:t}})}static getTutorialImage(t){return r(a,{method:"GET",url:"/api/v1/Tutorial/gettutorialimage/{path}",path:{path:t},errors:{404:"Not Found"}})}}export{i as TutorialService};
@@ -1 +1 @@
1
- import{jsx as r,Fragment as e}from"react/jsx-runtime";import"../../providers/FeatureToggleProvider.js";import{useFeatureToggling as o}from"../../hooks/useFeatureToggling.js";import"@tanstack/react-query";import"../../api/core/OpenAPI.js";const t=({children:t,fallback:i,...n})=>{const{showContent:s}=o({...n});return s?r(e,{children:t}):void 0===i?null:r(e,{children:i})};export{t as Feature};
1
+ import{jsx as o,Fragment as e}from"react/jsx-runtime";import"../../providers/FeatureToggleProvider.js";import{useFeatureToggling as r}from"../../hooks/useFeatureToggling.js";import"@tanstack/react-query";import"../../api/core/OpenAPI.js";import"../../api/models/ApplicationCategory.js";import"../../api/models/ServiceNowUrgency.js";import"../../api/models/TutorialPosition.js";import"../../types/Environment.js";import"../../types/ReleaseNotes.js";const t=({children:t,fallback:i,...s})=>{const{showContent:p}=r({...s});return p?o(e,{children:t}):void 0===i?null:o(e,{children:i})};export{t as Feature};
@@ -2,4 +2,5 @@ export declare const GET_FEATURE_TOGGLES_FOR_APP = "getFeatureToggleFromAppName"
2
2
  export declare const GET_TUTORIALS_FOR_APP = "getTutorialsForApp";
3
3
  export declare const GET_TUTORIALS_SAS_TOKEN = "getTutorialsSasToken";
4
4
  export declare const GET_RELEASE_NOTES = "getReleaseNotes";
5
+ export declare const GET_TUTORIAL_STEP_IMAGE = "getTutorialStepImage";
5
6
  export declare const SAM_QUERIES: string[];
@@ -1 +1 @@
1
- const e="getFeatureToggleFromAppName",t="getTutorialsForApp",o="getTutorialsSasToken",a="getReleaseNotes",g=[e,t,o,a];export{e as GET_FEATURE_TOGGLES_FOR_APP,a as GET_RELEASE_NOTES,t as GET_TUTORIALS_FOR_APP,o as GET_TUTORIALS_SAS_TOKEN,g as SAM_QUERIES};
1
+ const e="getFeatureToggleFromAppName",t="getTutorialsForApp",o="getTutorialsSasToken",a="getReleaseNotes",g="getTutorialStepImage",r=[e,t,o,a];export{e as GET_FEATURE_TOGGLES_FOR_APP,a as GET_RELEASE_NOTES,t as GET_TUTORIALS_FOR_APP,o as GET_TUTORIALS_SAS_TOKEN,g as GET_TUTORIAL_STEP_IMAGE,r as SAM_QUERIES};
@@ -1,4 +1,5 @@
1
- import { useFeatureToggleContext } from '../providers/FeatureToggleProvider';
2
- import { useFeatureToggling } from './useFeatureToggling';
3
- import { useReleaseNotesQuery } from './useReleaseNotesQuery';
4
- export { useFeatureToggling, useReleaseNotesQuery, useFeatureToggleContext };
1
+ export { useFeatureToggleContext } from '../providers/FeatureToggleProvider';
2
+ export { useFeatureToggling } from './useFeatureToggling';
3
+ export { useReleaseNotesQuery } from './useReleaseNotesQuery';
4
+ export { useTutorialsQuery } from './useTutorialsQuery';
5
+ export { useTutorialStepImage } from './useTutorialStepImage';
@@ -0,0 +1 @@
1
+ export declare function useTutorialStepImage(imgUrl: string | undefined): import("@tanstack/react-query").UseQueryResult<string, Error>;
@@ -0,0 +1 @@
1
+ import{useQuery as r}from"@tanstack/react-query";import{TutorialService as e}from"../api/services/TutorialService.js";import{GET_TUTORIAL_STEP_IMAGE as t}from"../constants/queryKeys.js";function o(o){return r({queryKey:[t,o],queryFn:()=>e.getTutorialImage(o),enabled:void 0!==o})}export{o as useTutorialStepImage};
@@ -0,0 +1 @@
1
+ export declare function useTutorialsQuery(): import("@tanstack/react-query").UseQueryResult<import("../api").MyTutorialDto[], Error>;
@@ -0,0 +1 @@
1
+ import{useQuery as t}from"@tanstack/react-query";import"../api/core/OpenAPI.js";import"../api/models/ApplicationCategory.js";import"../api/models/ServiceNowUrgency.js";import"../api/models/TutorialPosition.js";import{TutorialService as r}from"../api/services/TutorialService.js";import{GET_TUTORIALS_FOR_APP as e}from"../constants/queryKeys.js";import{EnvironmentType as o}from"../types/Environment.js";import"../types/ReleaseNotes.js";import{getEnvironmentName as i,getAppName as s}from"../utils/environment.js";function m(){return t({queryKey:[e],queryFn:async()=>i(import.meta.env.VITE_ENVIRONMENT_NAME)===o.PRODUCTION?r.getMyTutorials(s(import.meta.env.VITE_NAME)):r.getDraftTutorialsForApplication(s(import.meta.env.VITE_NAME))})}export{m as useTutorialsQuery};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{Feature}from"./components/Feature/Feature.js";export{FeatureRoute}from"./components/FeatureRoute/FeatureRoute.js";export{FeatureToggleProvider,useFeatureToggleContext}from"./providers/FeatureToggleProvider.js";export{useFeatureToggling}from"./hooks/useFeatureToggling.js";export{useReleaseNotesQuery}from"./hooks/useReleaseNotesQuery.js";export{TutorialProvider}from"./providers/TutorialProvider/TutorialProvider.js";export{useTutorial}from"./providers/TutorialProvider/TutorialProvider.hooks.js";export{EnvironmentType}from"./types/Environment.js";export{RELEASENOTE_TYPES_INFORMATION,ReleaseNoteType}from"./types/ReleaseNotes.js";import*as e from"./utils/environment.js";export{e as environment};export{ApiError}from"./api/core/ApiError.js";export{CancelError,CancelablePromise}from"./api/core/CancelablePromise.js";export{OpenAPI_APP,getJSEmbarkToken,getPortalToken,getSAMToken}from"./api/core/OpenAPI.js";export{request}from"./api/core/request.js";export{ApplicationCategory}from"./api/models/ApplicationCategory.js";export{ServiceNowUrgency}from"./api/models/ServiceNowUrgency.js";export{TutorialPosition}from"./api/models/TutorialPosition.js";export{AmplifyApplicationService}from"./api/services/AmplifyApplicationService.js";export{FeatureToggleService}from"./api/services/FeatureToggleService.js";export{ImpersonateUserService}from"./api/services/ImpersonateUserService.js";export{ReleaseNotesService}from"./api/services/ReleaseNotesService.js";export{ServiceNowService}from"./api/services/ServiceNowService.js";export{SlackService}from"./api/services/SlackService.js";export{TutorialService}from"./api/services/TutorialService.js";export{GET_FEATURE_TOGGLES_FOR_APP,GET_RELEASE_NOTES,GET_TUTORIALS_FOR_APP,GET_TUTORIALS_SAS_TOKEN,SAM_QUERIES}from"./constants/queryKeys.js";
1
+ export{Feature}from"./components/Feature/Feature.js";export{FeatureRoute}from"./components/FeatureRoute/FeatureRoute.js";export{FeatureToggleProvider,useFeatureToggleContext}from"./providers/FeatureToggleProvider.js";export{useFeatureToggling}from"./hooks/useFeatureToggling.js";export{useReleaseNotesQuery}from"./hooks/useReleaseNotesQuery.js";export{useTutorialsQuery}from"./hooks/useTutorialsQuery.js";export{useTutorialStepImage}from"./hooks/useTutorialStepImage.js";export{OldTutorialProvider}from"./providers/OldTutorialProvider/OldTutorialProvider.js";export{useOldTutorial}from"./providers/OldTutorialProvider/OldTutorialProvider.hooks.js";export{TutorialProvider,useTutorials}from"./providers/TutorialProvider/TutorialProvider.js";export{EnvironmentType}from"./types/Environment.js";export{RELEASENOTE_TYPES_INFORMATION,ReleaseNoteType}from"./types/ReleaseNotes.js";import*as e from"./utils/environment.js";export{e as environment};export{ApiError}from"./api/core/ApiError.js";export{CancelError,CancelablePromise}from"./api/core/CancelablePromise.js";export{OpenAPI_APP,getJSEmbarkToken,getPortalToken,getSAMToken}from"./api/core/OpenAPI.js";export{request}from"./api/core/request.js";export{ApplicationCategory}from"./api/models/ApplicationCategory.js";export{ServiceNowUrgency}from"./api/models/ServiceNowUrgency.js";export{TutorialPosition}from"./api/models/TutorialPosition.js";export{AmplifyApplicationService}from"./api/services/AmplifyApplicationService.js";export{FeatureToggleService}from"./api/services/FeatureToggleService.js";export{ImpersonateUserService}from"./api/services/ImpersonateUserService.js";export{ReleaseNotesService}from"./api/services/ReleaseNotesService.js";export{ServiceNowService}from"./api/services/ServiceNowService.js";export{SlackService}from"./api/services/SlackService.js";export{TutorialService}from"./api/services/TutorialService.js";export{GET_FEATURE_TOGGLES_FOR_APP,GET_RELEASE_NOTES,GET_TUTORIALS_FOR_APP,GET_TUTORIALS_SAS_TOKEN,GET_TUTORIAL_STEP_IMAGE,SAM_QUERIES}from"./constants/queryKeys.js";
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ interface OldTutorialDialogProps {
3
+ resetHasStartedTutorial: () => void;
4
+ }
5
+ declare const OldTutorialDialog: FC<OldTutorialDialogProps>;
6
+ export default OldTutorialDialog;
@@ -0,0 +1 @@
1
+ import{jsxs as t,Fragment as r,jsx as e}from"react/jsx-runtime";import{useMemo as i}from"react";import{Button as o}from"@equinor/eds-core-react";import{DIALOG_EDGE_MARGIN as a,TUTORIAL_LOCALSTORAGE_VALUE_STRING as n}from"./OldTutorialProvider.const.js";import{useGetTutorialSasToken as l,useOldTutorial as s}from"./OldTutorialProvider.hooks.js";import{DialogTypography as m,DialogImage as c,DialogWrapper as d,StyledTutorialDialog as p,DialogContent as u,DialogActions as g,NavigateSteps as h}from"./OldTutorialProvider.styles.js";import{getBestPositionWithoutOverlap as T}from"./OldTutorialProvider.utils.js";import f from"./OldTutorialStepIndicator.js";import"../../api/core/OpenAPI.js";import"../../api/models/ApplicationCategory.js";import"../../api/models/ServiceNowUrgency.js";import{TutorialPosition as v}from"../../api/models/TutorialPosition.js";const O=({resetHasStartedTutorial:O})=>{const{data:y}=l(),{activeTutorial:P,currentStep:S,setCurrentStep:j,setActiveTutorial:x,dialogRef:k,allElementsToHighlight:$,customStepComponents:C,isLastStep:R,currentStepObject:B,setAllElementsToHighlight:E,shortNameFromParams:H,viewportWidth:I,clearSearchParam:_}=s(),w=i((()=>{if(B)return B.key&&C?C.find((t=>t.key===B.key))?.element:void 0===B.key||null===B.key?t(r,{children:[e(m,{variant:"h5",children:B.title}),e(m,{group:"paragraph",variant:"body_short",children:B.body}),B.imgUrl&&y&&e(c,{"data-testid":"tutorial-image",alt:"tutorial-image",src:`${B.imgUrl}?${y}`})]}):void 0}),[B,C,y]),L=i((()=>{if(P&&I&&$&&k.current)return P.steps[S].position?P.steps[S].position:P.dynamicPositioning?T($[S].getBoundingClientRect(),k.current.getBoundingClientRect()):v.BOTTOM_RIGHT}),[P,I,$,k,S]),N=i((()=>{if(L&&L!==v.CENTER)switch(L){case v.TOP_LEFT:return{marginTop:`${a}px`,marginLeft:`${a}px`};case v.TOP_RIGHT:return{marginTop:`${a}px`,marginRight:`${a}px`};case v.BOTTOM_LEFT:return{marginBottom:`${a}px`,marginLeft:`${a}px`};case v.BOTTOM_RIGHT:default:return{marginBottom:`${a}px`,marginRight:`${a}px`}}}),[L]),A=()=>{H&&_(),P&&(window.localStorage.setItem(P?.shortName,n),x(void 0),k.current?.close(),j(0),E(void 0),O())};return e(d,{children:e(p,{"data-testid":"tutorial-dialog",ref:k,style:N??void 0,children:t(u,{children:[w,e(f,{steps:P?.steps??[],currentStep:S}),t(g,{children:[e(o,{variant:"ghost",onClick:()=>{A()},children:"Skip"}),t(h,{children:[S&&0!==S?e(o,{variant:"ghost",onClick:()=>{j((t=>t-1))},children:"Previous"}):null,e(o,{variant:"outlined",onClick:()=>{R?A():j((t=>t+1))},children:R?"Done":"Next"})]})]})]})})})};export{O as default};
@@ -0,0 +1,47 @@
1
+ import { Dispatch, FC, MutableRefObject, ReactNode, SetStateAction } from 'react';
2
+ import { CustomTutorialComponent } from './OldTutorialProvider.types';
3
+ import { Step, Tutorial } from '../../api';
4
+ import { EnvironmentType } from '../../types';
5
+ export interface TutorialContextType {
6
+ activeTutorial: Tutorial | undefined;
7
+ setActiveTutorial: Dispatch<SetStateAction<Tutorial | undefined>>;
8
+ currentStep: number;
9
+ setCurrentStep: Dispatch<SetStateAction<number>>;
10
+ allElementsToHighlight: HTMLElement[] | undefined;
11
+ setAllElementsToHighlight: Dispatch<SetStateAction<HTMLElement[] | undefined>>;
12
+ customStepComponents: CustomTutorialComponent[] | undefined;
13
+ currentStepObject: Step | undefined;
14
+ isLastStep: boolean;
15
+ dialogRef: MutableRefObject<HTMLDialogElement | null>;
16
+ clearSearchParam: () => void;
17
+ shortNameFromParams: string | undefined;
18
+ setShortNameFromParams: Dispatch<SetStateAction<string | undefined>>;
19
+ tutorialsFromProps: Tutorial[];
20
+ tutorialError: boolean;
21
+ setTutorialError: Dispatch<SetStateAction<boolean>>;
22
+ viewportWidth: number;
23
+ appName: string;
24
+ environmentName: EnvironmentType;
25
+ }
26
+ export declare const TutorialContext: import("react").Context<TutorialContextType | undefined>;
27
+ interface OldTutorialProviderProps {
28
+ children: ReactNode;
29
+ overrideAppName?: string;
30
+ overrideEnvironmentName?: EnvironmentType;
31
+ customStepComponents?: CustomTutorialComponent[];
32
+ tutorials?: Tutorial[];
33
+ ignoredQueryKeys?: string[];
34
+ }
35
+ /**
36
+ * Tutorial provider expects to be within a QueryClientProvider
37
+ * @deprecated - Use new TutorialProvider instead
38
+ * @param children Expects to wrap the application globally, typically in a providers file with multiple providers
39
+ * @param overrideAppName Overrides the "NAME" env variable, which is used to fetch the relevant tutorials for your app
40
+ * @param overrideEnvironmentName Overrides the "ENVIRONMENT_NAME" env variable, which is used for the possibility to hide tutorials in "production"
41
+ * @param customStepComponents Adds custom steps components with a key that can be used to link it to a step in a tutorial
42
+ * @param tutorials Passing tutorial object directly. This does not replace any tutorials found from API call, but rather is appended to them
43
+ * @param ignoredQueryKeys An array of query keys TutorialProviders will not wait to finish loading before looking for elements to highlight
44
+ * @constructor
45
+ */
46
+ export declare const OldTutorialProvider: FC<OldTutorialProviderProps>;
47
+ export {};
@@ -3,6 +3,7 @@ export declare const useGetTutorialsForApp: (appName: string) => import("@tansta
3
3
  export declare const useGetTutorialSasToken: () => import("@tanstack/react-query").UseQueryResult<string, Error>;
4
4
  /**
5
5
  * Use with caution. There has not been much testing of how using this hook in an app affects the tutorial logic
6
+ * @deprecated - Use new Tutorial hook instead
6
7
  */
7
- export declare const useTutorial: () => import("./TutorialProvider").TutorialContextType;
8
+ export declare const useOldTutorial: () => import("./OldTutorialProvider").TutorialContextType;
8
9
  export declare const useIsFetchingWithTimeout: (predicateFn: (query: Query) => boolean) => boolean;
@@ -0,0 +1 @@
1
+ import{useContext as r,useState as t,useEffect 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"./OldTutorialProvider.js";const c=r=>i({queryKey:[s,r],queryFn:()=>u.getTutorialsForApplication(r)}),m=()=>i({queryKey:[a],queryFn:()=>u.getTutorialSasToken()}),p=()=>{const t=r(n);if(void 0===t)throw new Error("'useTutorial' must be used within a TutorialProvider");return t},l=r=>{const[i,u]=t(!0),s=o({predicate:r})>0;return e((()=>{const r=setTimeout((()=>{u(s)}),100);return()=>clearTimeout(r)}),[s]),i||i!==s};export{m as useGetTutorialSasToken,c as useGetTutorialsForApp,l as useIsFetchingWithTimeout,p as useOldTutorial};
@@ -0,0 +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 l}from"react";import{useSearchParams as m}from"react-router-dom";import{TUTORIAL_SEARCH_PARAM_KEY as a}from"./OldTutorialProvider.const.js";import{useIsFetchingWithTimeout as u}from"./OldTutorialProvider.hooks.js";import{getAllElementsToHighlight as d}from"./OldTutorialProvider.utils.js";import c from"./OldTutorialProviderInner.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,O]=o(void 0),[A,x]=o(0),[I,F]=o(void 0),[H,L]=o(window.innerWidth),M=u((e=>!E?.some((t=>e.queryKey.includes(t))))),V=i(null),W=f??p(import.meta.env.VITE_NAME),_=y??h(import.meta.env.VITE_ENVIRONMENT_NAME),z=n((()=>{if(w)return w.steps.at(A)}),[w,A]),K=n((()=>!!w&&A>=w?.steps.length-1),[w,A]),R=s((()=>{S.delete(a),j(S),O(void 0)}),[S,j]);return l((()=>{if(C)return;const e=S.get(a);e&&O(e)}),[S,C]),l((()=>{const e=()=>{L(window.innerWidth)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),l((()=>{if(!w||P||M)return;const e=d(w);e.every((e=>null!==e))?F(e):(async()=>{await new Promise((e=>setTimeout(e,300)));const e=d(w);e.every((e=>null!==e))?F(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,A,P,C,M]),l((()=>{if(!w||P||M)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,M,g,P]),e(v.Provider,{value:{currentStepObject:z,activeTutorial:w,setActiveTutorial:N,currentStep:A,setCurrentStep:x,allElementsToHighlight:I,setAllElementsToHighlight:F,customStepComponents:g,isLastStep:K,dialogRef:V,clearSearchParam:R,shortNameFromParams:C,setShortNameFromParams:O,tutorialsFromProps:T??[],tutorialError:P,setTutorialError:k,viewportWidth:H,appName:W,environmentName:_},children:[t(c,{}),r]})};export{f as OldTutorialProvider,v as TutorialContext};
@@ -0,0 +1 @@
1
+ import{DIALOG_EDGE_MARGIN as t}from"./OldTutorialProvider.const.js";import"../../api/core/OpenAPI.js";import"../../api/models/ApplicationCategory.js";import"../../api/models/ServiceNowUrgency.js";import{TutorialPosition as T}from"../../api/models/TutorialPosition.js";const o=(t,T)=>!(t.top>T.bottom||t.bottom<T.top||t.right<T.left||t.left>T.right),e=(o,e)=>{const i=e===T.BOTTOM_RIGHT||e===T.BOTTOM_LEFT,O=e===T.TOP_RIGHT||e===T.BOTTOM_RIGHT,r=innerWidth-t-o.width,p=innerHeight-t-o.height;return new DOMRect(O?r:t,i?p:t,o.width,o.height)},i=(t,i)=>o(t,e(i,T.BOTTOM_RIGHT))?o(t,e(i,T.BOTTOM_LEFT))?o(t,e(i,T.TOP_RIGHT))?o(t,e(i,T.TOP_LEFT))?T.BOTTOM_RIGHT:T.TOP_LEFT:T.TOP_RIGHT:T.BOTTOM_LEFT:T.BOTTOM_RIGHT,O=t=>t.steps.map(((T,o)=>document.getElementById(`${t.shortName}-${o}`)));export{O as getAllElementsToHighlight,i as getBestPositionWithoutOverlap};
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ declare const OldTutorialProviderInner: FC;
3
+ export default OldTutorialProviderInner;
@@ -0,0 +1 @@
1
+ import{jsxs as t,jsx as r,Fragment as e}from"react/jsx-runtime";import{useRef as o,useMemo as i,useCallback as l,useEffect as n}from"react";import{useLocation as a}from"react-router";import{Typography as s,Button as h}from"@equinor/eds-core-react";import{HIGHLIGHT_PADDING as p,TUTORIAL_HIGHLIGHTER_DATATEST_ID as c}from"./OldTutorialProvider.const.js";import{useOldTutorial as m,useGetTutorialsForApp as u}from"./OldTutorialProvider.hooks.js";import{TutorialErrorDialog as d,Highlighter as f}from"./OldTutorialProvider.styles.js";import g from"./OldTutorialDialog.js";import{EnvironmentType as w}from"../../types/Environment.js";const T=()=>{const{pathname:T}=a(),{activeTutorial:v,setActiveTutorial:P,dialogRef:j,allElementsToHighlight:x,shortNameFromParams:N,tutorialError:O,tutorialsFromProps:b,currentStep:C,viewportWidth:k,setTutorialError:E,clearSearchParam:I,appName:S,environmentName:$}=m(),y=o(!1),{data:D}=u(S),R=i((()=>{if(!(D||b&&0!==b.length))return[];const t=[];return b&&t.push(...b),D&&t.push(...D),t}),[D,b]),U=i((()=>{if(!x||!v||!k)return;const t=x[C],r=t.getBoundingClientRect();return t&&t.scrollIntoView({behavior:"smooth",block:"center"}),{top:r.top-p+window.scrollY,left:r.left-p,height:r.height+2*p,width:r.width+2*p}}),[v,x,C,k]),B=i((()=>R.filter((t=>T.includes(t.path)))),[R,T]),F=l((t=>{y.current||(P(t),y.current=!0)}),[P]);n((()=>{U&&!j.current?.open&&j.current?.showModal()}),[j,U]),n((()=>{if(B.length<1)return;const t=B.find((t=>t.shortName===N)),r=B.find((t=>!window.localStorage.getItem(t.shortName)&&t.willPopUp));t?F(t):r&&F(r)}),[F,N,B]);const H=()=>{I(),E(!1),P(void 0)},q=l((()=>{y.current=!1}),[]);return(v?.showInProd||$!==w.PRODUCTION)&&(v?.willPopUp||N)?O&&N?t(d,{open:!0,isDismissable:!0,onClose:H,children:[r(s,{children:"There was a problem starting this tutorial. Please report this in using the feedback function in the Top Bar."}),r(h,{variant:"outlined",onClick:H,children:"Close"})]}):O?null:t(e,{children:[U&&r(f,{"data-testid":c,style:{top:`${U.top}px`,left:`${U.left}px`,width:`${U.width}px`,height:`${U.height}px`}}),r(g,{resetHasStartedTutorial:q})]}):null};export{T as default};
@@ -0,0 +1,8 @@
1
+ import { FC } from 'react';
2
+ import { Step } from '../../api';
3
+ interface OldTutorialStepIndicatorProps {
4
+ steps: Step[];
5
+ currentStep: number;
6
+ }
7
+ declare const OldTutorialStepIndicator: FC<OldTutorialStepIndicatorProps>;
8
+ export default OldTutorialStepIndicator;
@@ -1,46 +1,20 @@
1
- import { Dispatch, FC, MutableRefObject, ReactNode, SetStateAction } from 'react';
2
- import { CustomTutorialComponent } from './TutorialProvider.types';
3
- import { Step, Tutorial } from '../../api';
4
- import { EnvironmentType } from '../../types';
5
- export interface TutorialContextType {
6
- activeTutorial: Tutorial | undefined;
7
- setActiveTutorial: Dispatch<SetStateAction<Tutorial | undefined>>;
8
- currentStep: number;
9
- setCurrentStep: Dispatch<SetStateAction<number>>;
10
- allElementsToHighlight: HTMLElement[] | undefined;
11
- setAllElementsToHighlight: Dispatch<SetStateAction<HTMLElement[] | undefined>>;
12
- customStepComponents: CustomTutorialComponent[] | undefined;
13
- currentStepObject: Step | undefined;
14
- isLastStep: boolean;
15
- dialogRef: MutableRefObject<HTMLDialogElement | null>;
16
- clearSearchParam: () => void;
17
- shortNameFromParams: string | undefined;
18
- setShortNameFromParams: Dispatch<SetStateAction<string | undefined>>;
19
- tutorialsFromProps: Tutorial[];
20
- tutorialError: boolean;
21
- setTutorialError: Dispatch<SetStateAction<boolean>>;
22
- viewportWidth: number;
23
- appName: string;
24
- environmentName: EnvironmentType;
1
+ import { FC, ReactNode } from 'react';
2
+ import { MyTutorialDto } from '../../api/models/MyTutorialDto';
3
+ interface TutorialContextType {
4
+ allTutorials: MyTutorialDto[];
5
+ tutorialsOnThisPage: MyTutorialDto[];
6
+ unseenTutorialsOnThisPage: MyTutorialDto[];
7
+ activeTutorial: MyTutorialDto | undefined;
8
+ startTutorial: (tutorialId: string) => void;
9
+ skipTutorial: (tutorialId: string) => void;
10
+ activeStep: number | undefined;
11
+ goToNextStep: () => void;
12
+ goToPreviousStep: () => void;
25
13
  }
26
- export declare const TutorialContext: import("react").Context<TutorialContextType | undefined>;
14
+ export declare const TutorialDataContext: import("react").Context<TutorialContextType | undefined>;
15
+ export declare function useTutorials(): TutorialContextType;
27
16
  interface TutorialProviderProps {
28
17
  children: ReactNode;
29
- overrideAppName?: string;
30
- overrideEnvironmentName?: EnvironmentType;
31
- customStepComponents?: CustomTutorialComponent[];
32
- tutorials?: Tutorial[];
33
- ignoredQueryKeys?: string[];
34
18
  }
35
- /**
36
- * Tutorial provider expects to be within a QueryClientProvider
37
- * @param children Expects to wrap the application globally, typically in a providers file with multiple providers
38
- * @param overrideAppName Overrides the "NAME" env variable, which is used to fetch the relevant tutorials for your app
39
- * @param overrideEnvironmentName Overrides the "ENVIRONMENT_NAME" env variable, which is used for the possibility to hide tutorials in "production"
40
- * @param customStepComponents Adds custom steps components with a key that can be used to link it to a step in a tutorial
41
- * @param tutorials Passing tutorial object directly. This does not replace any tutorials found from API call, but rather is appended to them
42
- * @param ignoredQueryKeys An array of query keys TutorialProviders will not wait to finish loading before looking for elements to highlight
43
- * @constructor
44
- */
45
19
  export declare const TutorialProvider: FC<TutorialProviderProps>;
46
20
  export {};
@@ -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 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};
1
+ import{jsx as r}from"react/jsx-runtime";import{createContext as o,useContext as i,useState as t,useMemo as e}from"react";import{useLocation as n,matchPath as a}from"react-router";import{useSeenTutorials as u}from"./useSeenTutorials.js";import"../FeatureToggleProvider.js";import"@tanstack/react-query";import"../../api/core/OpenAPI.js";import{useTutorialsQuery as s}from"../../hooks/useTutorialsQuery.js";const d=o(void 0);function l(){const r=i(d);if(void 0===r)throw new Error("'useTutorials' must be used within provider");return r}const p=({children:o})=>{const{pathname:i}=n(),{data:l=[]}=s(),[p,v]=t(void 0),[c,f]=t(void 0),[m,h]=u(),w=e((()=>l?.filter((r=>null!==a(r.path,i)))),[i,l]),T=e((()=>w?.filter((r=>!m.includes(r.id)&&r.willPopUp))),[m,w]);return r(d.Provider,{value:{allTutorials:l,tutorialsOnThisPage:w,unseenTutorialsOnThisPage:T,activeTutorial:p,activeStep:c,startTutorial:r=>{if(!l?.some((o=>r===o.id)))throw new Error("Tutorial not found");v(l.find((o=>r===o.id))),f(0)},skipTutorial:r=>{p&&p.id===r&&(v(void 0),f(void 0)),h(r)},goToNextStep:()=>{if(!p)throw new Error("No currently active tutorial!");if(void 0===c)throw new Error("activeStep is undefined!");c+1>=p.steps.length?(h(p.id),v(void 0),f(void 0)):f(c+1)},goToPreviousStep:()=>{if(!p)throw new Error("No currently active tutorial!");if(void 0===c)throw new Error("activeStep is undefined!");0===c?(v(void 0),f(void 0)):f(c-1)}},children:o})};export{d as TutorialDataContext,p as TutorialProvider,l as useTutorials};
@@ -0,0 +1,2 @@
1
+ export declare const SEEN_TUTORIALS_LOCALSTORAGE_KEY: string;
2
+ export declare function useSeenTutorials(): readonly [string[], (tutorialId: string) => void];
@@ -0,0 +1 @@
1
+ import{useState as r,useCallback as t}from"react";import{getAppName as e}from"../../utils/environment.js";const o=`sam-seen-tutorials-${e(import.meta.env.VITE_NAME)}`;function n(){const[e,n]=r(function(){const r=localStorage.getItem(o);if(r)try{const t=JSON.parse(r);if(!Array.isArray(t)||!t.every((r=>"string"==typeof r)))throw new Error("Invalid seen tutorial data in localStorage");return t}catch(r){console.error(r)}return[]}());return[e,t((r=>{n((t=>{const e=[...t,r];return localStorage.setItem(o,JSON.stringify(e)),e}))}),[])]}export{o as SEEN_TUTORIALS_LOCALSTORAGE_KEY,n as useSeenTutorials};
@@ -1,3 +1,4 @@
1
- export { TutorialProvider } from './TutorialProvider/TutorialProvider';
1
+ export { OldTutorialProvider } from './OldTutorialProvider/OldTutorialProvider';
2
2
  export { FeatureToggleProvider } from './FeatureToggleProvider';
3
- export { useTutorial } from './TutorialProvider/TutorialProvider.hooks';
3
+ export { useOldTutorial } from './OldTutorialProvider/OldTutorialProvider.hooks';
4
+ export { TutorialProvider, useTutorials, } from './TutorialProvider/TutorialProvider';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/subsurface-app-management",
3
- "version": "2.3.1",
3
+ "version": "2.5.0",
4
4
  "description": "React Typescript components/hooks to communicate with equinor/sam",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -29,8 +29,6 @@
29
29
  "lint:fix": "eslint ./src ./.storybook --fix",
30
30
  "test": "vitest watch",
31
31
  "test:ci": "vitest run",
32
- "test:coverage": "vitest run --coverage",
33
- "test:coverage-ci": "CI=true vitest run --coverage --coverage.reporter=json --coverage.reporter=json-summary --silent",
34
32
  "setup-husky": "husky install",
35
33
  "precommit": "npx lint-staged",
36
34
  "build": "rollup -c && tsc --project tsconfig.build.json && resolve-tspaths --project tsconfig.build.json",
@@ -1,6 +0,0 @@
1
- import { FC } from 'react';
2
- interface TutorialDialogProps {
3
- resetHasStartedTutorial: () => void;
4
- }
5
- declare const TutorialDialog: FC<TutorialDialogProps>;
6
- export default TutorialDialog;
@@ -1 +0,0 @@
1
- import{jsxs as t,Fragment as r,jsx as e}from"react/jsx-runtime";import{useMemo as i}from"react";import{Button as o}from"@equinor/eds-core-react";import{DIALOG_EDGE_MARGIN as a,TUTORIAL_LOCALSTORAGE_VALUE_STRING as n}from"./TutorialProvider.const.js";import{useGetTutorialSasToken as s,useTutorial as l}from"./TutorialProvider.hooks.js";import{DialogTypography as m,DialogImage as c,DialogWrapper as p,StyledTutorialDialog as d,DialogContent as u,DialogActions as g,NavigateSteps as h}from"./TutorialProvider.styles.js";import{getBestPositionWithoutOverlap as T}from"./TutorialProvider.utils.js";import f from"./TutorialStepIndicator.js";import"../../api/core/OpenAPI.js";import"../../api/models/ApplicationCategory.js";import"../../api/models/ServiceNowUrgency.js";import{TutorialPosition as v}from"../../api/models/TutorialPosition.js";const y=({resetHasStartedTutorial:y})=>{const{data:P}=s(),{activeTutorial:S,currentStep:j,setCurrentStep:x,setActiveTutorial:k,dialogRef:O,allElementsToHighlight:$,customStepComponents:C,isLastStep:R,currentStepObject:B,setAllElementsToHighlight:E,shortNameFromParams:H,viewportWidth:I,clearSearchParam:_}=l(),w=i((()=>{if(B)return B.key&&C?C.find((t=>t.key===B.key))?.element:void 0===B.key||null===B.key?t(r,{children:[e(m,{variant:"h5",children:B.title}),e(m,{group:"paragraph",variant:"body_short",children:B.body}),B.imgUrl&&P&&e(c,{"data-testid":"tutorial-image",alt:"tutorial-image",src:`${B.imgUrl}?${P}`})]}):void 0}),[B,C,P]),L=i((()=>{if(S&&I&&$&&O.current)return S.steps[j].position?S.steps[j].position:S.dynamicPositioning?T($[j].getBoundingClientRect(),O.current.getBoundingClientRect()):v.BOTTOM_RIGHT}),[S,I,$,O,j]),N=i((()=>{if(L&&L!==v.CENTER)switch(L){case v.TOP_LEFT:return{marginTop:`${a}px`,marginLeft:`${a}px`};case v.TOP_RIGHT:return{marginTop:`${a}px`,marginRight:`${a}px`};case v.BOTTOM_LEFT:return{marginBottom:`${a}px`,marginLeft:`${a}px`};case v.BOTTOM_RIGHT:default:return{marginBottom:`${a}px`,marginRight:`${a}px`}}}),[L]),A=()=>{H&&_(),S&&(window.localStorage.setItem(S?.shortName,n),k(void 0),O.current?.close(),x(0),E(void 0),y())};return e(p,{children:e(d,{"data-testid":"tutorial-dialog",ref:O,style:N??void 0,children:t(u,{children:[w,e(f,{steps:S?.steps??[],currentStep:j}),t(g,{children:[e(o,{variant:"ghost",onClick:()=>{A()},children:"Skip"}),t(h,{children:[j&&0!==j?e(o,{variant:"ghost",onClick:()=>{x((t=>t-1))},children:"Previous"}):null,e(o,{variant:"outlined",onClick:()=>{R?A():x((t=>t+1))},children:R?"Done":"Next"})]})]})]})})})};export{y as default};
@@ -1 +0,0 @@
1
- import{useContext as r,useState as t,useEffect 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 t=r(n);if(void 0===t)throw new Error("'useTutorial' must be used within a TutorialProvider");return t},y=r=>{const[i,u]=t(!0),s=o({predicate:r})>0;return e((()=>{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 +0,0 @@
1
- import{DIALOG_EDGE_MARGIN as t}from"./TutorialProvider.const.js";import"../../api/core/OpenAPI.js";import"../../api/models/ApplicationCategory.js";import"../../api/models/ServiceNowUrgency.js";import{TutorialPosition as T}from"../../api/models/TutorialPosition.js";const o=(t,T)=>!(t.top>T.bottom||t.bottom<T.top||t.right<T.left||t.left>T.right),e=(o,e)=>{const i=e===T.BOTTOM_RIGHT||e===T.BOTTOM_LEFT,r=e===T.TOP_RIGHT||e===T.BOTTOM_RIGHT,O=innerWidth-t-o.width,p=innerHeight-t-o.height;return new DOMRect(r?O:t,i?p:t,o.width,o.height)},i=(t,i)=>o(t,e(i,T.BOTTOM_RIGHT))?o(t,e(i,T.BOTTOM_LEFT))?o(t,e(i,T.TOP_RIGHT))?o(t,e(i,T.TOP_LEFT))?T.BOTTOM_RIGHT:T.TOP_LEFT:T.TOP_RIGHT:T.BOTTOM_LEFT:T.BOTTOM_RIGHT,r=t=>t.steps.map(((T,o)=>document.getElementById(`${t.shortName}-${o}`)));export{r as getAllElementsToHighlight,i as getBestPositionWithoutOverlap};
@@ -1,3 +0,0 @@
1
- import { FC } from 'react';
2
- declare const TutorialProviderInner: FC;
3
- export default TutorialProviderInner;
@@ -1 +0,0 @@
1
- import{jsxs as t,jsx as r,Fragment as e}from"react/jsx-runtime";import{useRef as o,useMemo as i,useCallback as n,useEffect as l}from"react";import{useLocation as a}from"react-router";import{Typography as s,Button as h}from"@equinor/eds-core-react";import p from"./TutorialDialog.js";import{HIGHLIGHT_PADDING as c,TUTORIAL_HIGHLIGHTER_DATATEST_ID as m}from"./TutorialProvider.const.js";import{useTutorial as u,useGetTutorialsForApp as d}from"./TutorialProvider.hooks.js";import{TutorialErrorDialog as f,Highlighter as g}from"./TutorialProvider.styles.js";import{EnvironmentType as w}from"../../types/Environment.js";const T=()=>{const{pathname:T}=a(),{activeTutorial:v,setActiveTutorial:P,dialogRef:j,allElementsToHighlight:x,shortNameFromParams:N,tutorialError:b,tutorialsFromProps:C,currentStep:k,viewportWidth:E,setTutorialError:I,clearSearchParam:S,appName:$,environmentName:y}=u(),D=o(!1),{data:R}=d($),U=i((()=>{if(!(R||C&&0!==C.length))return[];const t=[];return C&&t.push(...C),R&&t.push(...R),t}),[R,C]),B=i((()=>{if(!x||!v||!E)return;const t=x[k],r=t.getBoundingClientRect();return t&&t.scrollIntoView({behavior:"smooth",block:"center"}),{top:r.top-c+window.scrollY,left:r.left-c,height:r.height+2*c,width:r.width+2*c}}),[v,x,k,E]),F=i((()=>U.filter((t=>T.includes(t.path)))),[U,T]),H=n((t=>{D.current||(P(t),D.current=!0)}),[P]);l((()=>{B&&!j.current?.open&&j.current?.showModal()}),[j,B]),l((()=>{if(F.length<1)return;const t=F.find((t=>t.shortName===N)),r=F.find((t=>!window.localStorage.getItem(t.shortName)&&t.willPopUp));t?H(t):r&&H(r)}),[H,N,F]);const O=()=>{S(),I(!1),P(void 0)},q=n((()=>{D.current=!1}),[]);return(v?.showInProd||y!==w.PRODUCTION)&&(v?.willPopUp||N)?b&&N?t(f,{open:!0,isDismissable:!0,onClose:O,children:[r(s,{children:"There was a problem starting this tutorial. Please report this in using the feedback function in the Top Bar."}),r(h,{variant:"outlined",onClick:O,children:"Close"})]}):b?null:t(e,{children:[B&&r(g,{"data-testid":m,style:{top:`${B.top}px`,left:`${B.left}px`,width:`${B.width}px`,height:`${B.height}px`}}),r(p,{resetHasStartedTutorial:q})]}):null};export{T as default};
@@ -1,8 +0,0 @@
1
- import { FC } from 'react';
2
- import { Step } from '../../api';
3
- interface TutorialStepIndicatorProps {
4
- steps: Step[];
5
- currentStep: number;
6
- }
7
- declare const TutorialStepIndicator: FC<TutorialStepIndicatorProps>;
8
- export default TutorialStepIndicator;