@equinor/subsurface-app-management 1.1.19 → 1.1.21

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/index.js CHANGED
@@ -1 +1 @@
1
- export{Feature}from"./components/Feature/Feature.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{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_SAM,getPortalToken}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_TUTORIALS_FOR_APP,GET_TUTORIALS_SAS_TOKEN,SAM_QUERIES}from"./constants/queryKeys.js";
1
+ export{Feature}from"./components/Feature/Feature.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_SAM,getPortalToken}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_TUTORIALS_FOR_APP,GET_TUTORIALS_SAS_TOKEN,SAM_QUERIES}from"./constants/queryKeys.js";
@@ -1,3 +1,6 @@
1
1
  import { FC } from 'react';
2
- declare const TutorialDialog: FC;
2
+ interface TutorialDialogProps {
3
+ resetHasStartedTutorial: () => void;
4
+ }
5
+ declare const TutorialDialog: FC<TutorialDialogProps>;
3
6
  export default TutorialDialog;
@@ -1 +1 @@
1
- import{jsxs as t,Fragment as r,jsx as i}from"react/jsx-runtime";import{useMemo as e}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=()=>{const{data:y}=s(),{activeTutorial:P,currentStep:j,setCurrentStep:x,setActiveTutorial:S,dialogRef:k,allElementsToHighlight:O,customStepComponents:$,isLastStep:C,currentStepObject:R,setAllElementsToHighlight:B,shortNameFromParams:E,viewportWidth:I,clearSearchParam:_}=l(),w=e((()=>{if(R)return R.key&&$?$.find((t=>t.key===R.key))?.element:void 0===R.key||null===R.key?t(r,{children:[i(m,{variant:"h5",children:R.title}),i(m,{group:"paragraph",variant:"body_short",children:R.body}),R.imgUrl&&y&&i(c,{"data-testid":"tutorial-image",alt:"tutorial-image",src:`${R.imgUrl}?${y}`})]}):void 0}),[R,$,y]),H=e((()=>{if(P&&I&&O&&k.current)return P.steps[j].position?P.steps[j].position:P.dynamicPositioning?T(O[j].getBoundingClientRect(),k.current.getBoundingClientRect()):v.BOTTOM_RIGHT}),[P,I,O,k,j]),L=e((()=>{if(H&&H!==v.CENTER)switch(H){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`}}}),[H]),N=()=>{E&&_(),P&&(window.localStorage.setItem(P?.shortName,n),S(void 0),k.current?.close(),x(0),B(void 0))};return i(p,{children:i(d,{"data-testid":"tutorial-dialog",ref:k,style:L??void 0,children:t(u,{children:[w,i(f,{steps:P?.steps??[],currentStep:j}),t(g,{children:[i(o,{variant:"ghost",onClick:()=>{N()},children:"Skip"}),t(h,{children:[j&&0!==j?i(o,{variant:"ghost",onClick:()=>{x((t=>t-1))},children:"Previous"}):null,i(o,{variant:"outlined",onClick:()=>{C?N():x((t=>t+1))},children:C?"Done":"Next"})]})]})]})})})};export{y as default};
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,5 +1,8 @@
1
1
  import { Query } from '@tanstack/react-query';
2
2
  export declare const useGetTutorialsForApp: (appName: string) => import("@tanstack/react-query").UseQueryResult<import("../..").Tutorial[], Error>;
3
3
  export declare const useGetTutorialSasToken: () => import("@tanstack/react-query").UseQueryResult<string, Error>;
4
+ /**
5
+ * Use with caution. There has not been much testing of how using this hook in an app affects the tutorial logic
6
+ */
4
7
  export declare const useTutorial: () => import("./TutorialProvider").TutorialContextType;
5
8
  export declare const useIsFetchingWithTimeout: (predicateFn: (query: Query) => boolean) => boolean;
@@ -1 +1 @@
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
+ 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 +1 @@
1
- import{jsxs as t,jsx as r,Fragment as o}from"react/jsx-runtime";import{useRef as e,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 m,TUTORIAL_HIGHLIGHTER_DATATEST_ID as c}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 v=()=>{const{pathname:v}=a(),{activeTutorial:P,setActiveTutorial:T,dialogRef:j,allElementsToHighlight:x,shortNameFromParams:N,tutorialError:b,tutorialsFromProps:C,currentStep:k,viewportWidth:E,setTutorialError:I,clearSearchParam:$,appName:y,environmentName:D}=u(),R=e(!1),{data:S}=d(y),U=i((()=>{if(!(S||C&&0!==C.length))return[];const t=[];return C&&t.push(...C),S&&t.push(...S),t}),[S,C]),B=i((()=>{if(!x||!P||!E)return;const t=x[k],r=t.getBoundingClientRect();return t&&t.scrollIntoView({behavior:"smooth",block:"center"}),{top:r.top-m+window.scrollY,left:r.left-m,height:r.height+2*m,width:r.width+2*m}}),[P,x,k,E]),F=i((()=>U.filter((t=>v.includes(t.path)))),[U,v]),O=n((t=>{R.current||(T(t),R.current=!0)}),[T]);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?O(t):r&&O(r)}),[O,N,F]);const q=()=>{$(),I(!1),T(void 0)};return(P?.showInProd||D!==w.PRODUCTION)&&(P?.willPopUp||N)?b&&N?t(f,{open:!0,isDismissable:!0,onClose:q,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:q,children:"Close"})]}):b?null:t(o,{children:[B&&r(g,{"data-testid":c,style:{top:`${B.top}px`,left:`${B.left}px`,width:`${B.width}px`,height:`${B.height}px`}}),r(p,{})]}):null};export{v as default};
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,2 +1,3 @@
1
1
  export { TutorialProvider } from './TutorialProvider/TutorialProvider';
2
2
  export { FeatureToggleProvider } from './FeatureToggleProvider';
3
+ export { useTutorial } from './TutorialProvider/TutorialProvider.hooks';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/subsurface-app-management",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
4
4
  "description": "React Typescript components/hooks to communicate with equinor/sam",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",