@equinor/amplify-component-lib 9.14.0-beta.3 → 9.14.1-beta.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.
- package/dist/providers/TutorialHighlightingProvider/TutorialHighlightingProvider.d.ts +2 -1
- package/dist/providers/TutorialHighlightingProvider/TutorialHighlightingProvider.js +1 -1
- package/dist/providers/TutorialHighlightingProvider/TutorialHighlightingProviderInner.d.ts +2 -1
- package/dist/providers/TutorialHighlightingProvider/TutorialHighlightingProviderInner.js +2 -2
- package/dist/providers/TutorialHighlightingProvider/TutorialPopover/TutorialPopover.d.ts +2 -1
- package/dist/providers/TutorialHighlightingProvider/TutorialPopover/TutorialPopover.js +2 -2
- package/dist/providers/TutorialHighlightingProvider/TutorialPopover/hooks/useTutorialPopoverPosition.d.ts +3 -1
- package/dist/providers/TutorialHighlightingProvider/TutorialPopover/hooks/useTutorialPopoverPosition.js +1 -1
- package/dist/providers/TutorialHighlightingProvider/hooks/useReversedScrollY.d.ts +2 -1
- package/dist/providers/TutorialHighlightingProvider/hooks/useReversedScrollY.js +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { FC, ReactElement } from 'react';
|
|
1
|
+
import { FC, ReactElement, RefObject } from 'react';
|
|
2
2
|
interface TutorialHighlightingContextType {
|
|
3
3
|
customStepContent: Record<string, ReactElement>;
|
|
4
4
|
}
|
|
5
5
|
export declare function useTutorialHighlighting(): TutorialHighlightingContextType;
|
|
6
6
|
interface TutorialHighlightingProviderProps {
|
|
7
7
|
children: ReactElement | ReactElement[];
|
|
8
|
+
contentRef: RefObject<HTMLElement | null>;
|
|
8
9
|
customStepContent?: Record<string, ReactElement>;
|
|
9
10
|
}
|
|
10
11
|
export declare const TutorialHighlightingProvider: FC<TutorialHighlightingProviderProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{createContext as r,useContext as e}from"react";import{TutorialProvider as i}from"@equinor/subsurface-app-management";import{TutorialHighlightingProviderInner as n}from"./TutorialHighlightingProviderInner.js";const o=r(void 0);function c(){const t=e(o);if(!t)throw new Error("useTutorialHighlighting must be used within a TutorialHighlightingProvider");return t}const u=({children:r,contentRef:e,customStepContent:c})=>t(o.Provider,{value:{customStepContent:c??{}},children:t(i,{children:t(n,{contentRef:e,children:r})})});export{u as TutorialHighlightingProvider,c as useTutorialHighlighting};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FC, ReactElement } from 'react';
|
|
1
|
+
import { FC, ReactElement, RefObject } from 'react';
|
|
2
2
|
interface TutorialHighlightingProviderInnerProps {
|
|
3
3
|
children: ReactElement | ReactElement[];
|
|
4
|
+
contentRef: RefObject<HTMLElement | null>;
|
|
4
5
|
}
|
|
5
6
|
export declare const TutorialHighlightingProviderInner: FC<TutorialHighlightingProviderInnerProps>;
|
|
6
7
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsxs as t,Fragment as i,jsx as e}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{jsxs as t,Fragment as i,jsx as e}from"react/jsx-runtime";import{useState as n,useEffect as r}from"react";import{useTutorials as o}from"@equinor/subsurface-app-management";import{useIsFetching as s}from"@tanstack/react-query";import{useReversedScrollY as h}from"./hooks/useReversedScrollY.js";import{TutorialPopover as l}from"./TutorialPopover/TutorialPopover.js";import{TUTORIAL_HIGHLIGHT_ANIMATION_PROPS as a}from"./TutorialHighlightingProvider.constants.js";import"../../atoms/style/colors.js";import{spacings as d}from"../../atoms/style/spacings.js";import{getHighlightElementBoundingBox as m}from"../../atoms/utils/tutorials.js";import{motion as c}from"framer-motion";import p from"styled-components";const g=p.svg`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -21,4 +21,4 @@ import{jsxs as t,Fragment as i,jsx as e}from"react/jsx-runtime";import{useState
|
|
|
21
21
|
height: 100vh;
|
|
22
22
|
background: none;
|
|
23
23
|
pointer-events: none;
|
|
24
|
-
`,u=({children:d})=>{const{activeTutorial:
|
|
24
|
+
`,u=({children:d,contentRef:p})=>{const{activeTutorial:u,activeStep:w,unseenTutorialsOnThisPage:v}=o(),$=s()>0,y=h(p),[j,k]=n({width:window.innerWidth,height:window.innerHeight});r(()=>{const t=()=>{k({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]);const[x,E]=n([]);r(()=>{if($)return;(async()=>{if(u&&void 0!==w){if(!u.steps[w].highlightElement)return E([]);const t=await m(u.id,w,j);return E(t?[t]:[])}const t=await Promise.all(v.map(t=>{if(t.steps.at(0)?.highlightElement)return m(t.id,0,j)}));E(t.filter(t=>void 0!==t))})()},[w,u,$,v,j]);const T=u?[u]:v.filter(t=>t.steps[0].highlightElement&&x.some(t=>t.id)||!t.steps[0].highlightElement);return T.length>0?t(i,{children:[d,e(f,{children:T.map(t=>{const i=x.find(i=>i.id===t.id);return e(l,{isHighlighting:x.length>0,contentRef:p,...t,...i},t.id)})}),t(g,{children:[t("mask",{id:"tutorials-rectangles",children:[e("rect",{width:"100%",height:"100%",fill:"white"}),e(c.g,{style:{translateY:y},children:x.map(t=>e(c.path,{"data-testid":`tutorial-mask-${t.id}`,initial:{opacity:0,d:`M ${t.left} ${t.top} h ${t.width} v ${t.height} h -${t.width} Z`},animate:{opacity:1,d:`M ${t.left} ${t.top} h ${t.width} v ${t.height} h -${t.width} Z`},fill:"black"},t.id))})]}),e(c.rect,{width:"100%",height:"100%",fill:"rgba(111, 111, 111, 0.35)",mask:"url(#tutorials-rectangles)",...a})]})]}):e(i,{children:d})};export{u as TutorialHighlightingProviderInner};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, RefObject } from 'react';
|
|
2
2
|
import { MyTutorialDto } from '@equinor/subsurface-app-management';
|
|
3
3
|
interface TutorialPopoverProps extends MyTutorialDto {
|
|
4
|
+
contentRef: RefObject<HTMLElement | null>;
|
|
4
5
|
isHighlighting: boolean;
|
|
5
6
|
top?: number;
|
|
6
7
|
left?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsxs as t,jsx as r,Fragment as
|
|
1
|
+
import{jsxs as t,jsx as r,Fragment as e}from"react/jsx-runtime";import{useState as i}from"react";import{Card as o,Icon as n,Typography as a,Button as s}from"@equinor/eds-core-react";import{info_circle as l}from"@equinor/eds-icons";import{useTutorials as c,useTutorialStepImage as d}from"@equinor/subsurface-app-management";import{useTutorialHighlighting as m}from"../TutorialHighlightingProvider.js";import{TUTORIAL_HIGHLIGHT_ANIMATION_PROPS as h}from"../TutorialHighlightingProvider.constants.js";import{useTutorialPopoverPosition as g}from"./hooks/useTutorialPopoverPosition.js";import{StepIndicator as p}from"./StepIndicator.js";import{elevation as u}from"../../../atoms/style/index.js";import{motion as f}from"framer-motion";import v,{css as b}from"styled-components";import{spacings as x}from"../../../atoms/style/spacings.js";import{colors as $}from"../../../atoms/style/colors.js";const y=v(f(o))`
|
|
2
2
|
width: 360px;
|
|
3
3
|
padding: ${x.medium};
|
|
4
4
|
background: ${$.ui.background__tutorial_card.rgba};
|
|
@@ -72,4 +72,4 @@ import{jsxs as t,jsx as r,Fragment as i}from"react/jsx-runtime";import{useState
|
|
|
72
72
|
margin-right: auto;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
`,_=({
|
|
75
|
+
`,_=({contentRef:o,isHighlighting:u,id:f,top:v,left:b,width:x,height:_,name:j,steps:w})=>{const{customStepContent:P}=m(),{activeTutorial:T,activeStep:C,skipTutorial:S,startTutorial:E,goToNextStep:H,goToPreviousStep:q}=c(),{data:I}=d(T?.steps.at(C)?.imgUrl??void 0),[z,D]=i(void 0),{style:N,highlightingElement:R,caretPosition:A}=g({contentRef:o,top:v,left:b,width:x,height:_,popoverSize:z}),B=t=>{D(t?{width:t.clientWidth,height:t.clientHeight}:void 0)},F=()=>{S(f)},U=()=>{E(f)};if(void 0!==C&&w[C].custom&&!P[w[C].id])throw new Error(`[TutorialHighlightingProvider]: Custom step content not found, tutorial ID: ${f}, step ID: ${w[C].id}`);return!R&&u?null:t(y,T&&void 0!==C?{ref:B,style:{...N,width:w[C].custom?"auto":void 0},$caretPosition:A,$highlightingElement:R,...h,children:[w[C].custom?P[w[C].id]:t(e,{children:[t("header",{children:[r(n,{data:l,color:$.interactive.primary__resting.rgba}),r(a,{variant:"h6",children:w[C]?.title})]}),r(a,{variant:"body_short",children:w[C]?.body}),I?r("img",{src:I,alt:w[C].title}):null]}),t(k,{children:[r(s,{variant:"outlined",disabled:0===C,onClick:q,children:"Back"}),r(s,{variant:"ghost",onClick:F,children:"Cancel"}),r(s,{onClick:H,children:C===w.length-1?"Finish":"Next"})]}),r(p,{stepAmount:w.length})]}:{ref:B,style:{...N},$highlightingElement:R,$caretPosition:A,...h,children:[t("header",{children:[r(n,{data:l,color:$.interactive.primary__resting.rgba}),r(a,{variant:"h6",children:j})]}),t(k,{children:[r(s,{variant:"ghost",onClick:F,children:"Skip"}),r(s,{onClick:U,children:"Start tour"})]})]})};export{_ as TutorialPopover};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
1
2
|
import { MotionStyle } from 'framer-motion';
|
|
2
3
|
export declare const CARET_OFFSET = 16;
|
|
3
4
|
interface UseTutorialPopoverPositionArgs {
|
|
5
|
+
contentRef: RefObject<HTMLElement | null>;
|
|
4
6
|
top?: number;
|
|
5
7
|
left?: number;
|
|
6
8
|
width?: number;
|
|
@@ -17,5 +19,5 @@ export interface UseTutorialPopoverPositionReturn {
|
|
|
17
19
|
highlightingElement: boolean;
|
|
18
20
|
caretPosition: VerticalPosition | HorizontalPosition | `${VerticalPosition}-${HorizontalPosition}`;
|
|
19
21
|
}
|
|
20
|
-
export declare function useTutorialPopoverPosition({ top, left, width, height, popoverSize, }: UseTutorialPopoverPositionArgs): UseTutorialPopoverPositionReturn;
|
|
22
|
+
export declare function useTutorialPopoverPosition({ top, left, width, height, popoverSize, contentRef, }: UseTutorialPopoverPositionArgs): UseTutorialPopoverPositionReturn;
|
|
21
23
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useReversedScrollY as i}from"../../hooks/useReversedScrollY.js";import{useTransform as o}from"framer-motion";const t=16;function d({top:d,left:e,width:
|
|
1
|
+
import{useReversedScrollY as i}from"../../hooks/useReversedScrollY.js";import{useTransform as o}from"framer-motion";const t=16;function d({top:d,left:e,width:n,height:h,popoverSize:v,contentRef:r}){const w=i(r);let l=d&&h?d+h+t:void 0,s=e&&n?e+n/2:void 0;const g=!!l&&!!s;let c="top";const f=(v?.width??0)/2+t,p=window.innerWidth-t,m=window.innerHeight-t,u=void 0!==d&&void 0!==h&&void 0!==e&&void 0!==n&&void 0!==s&&void 0!==v&&s<v.width/2,b=void 0!==d&&void 0!==h&&void 0!==e&&void 0!==n&&void 0!==s&&void 0!==v&&s+v.width>window.innerWidth;u?(s=e+n+v.width/2+t,l=d-v.height/2-4,c="left"):b&&(s=e-v.width/2-t,l=d-v.height/2-4,c="right");const a=void 0!==d&&void 0!==h&&void 0!==l&&void 0!==v&&d+h/2+v.height>=window.innerHeight,H=void 0!==d&&void 0!==h&&void 0!==l&&void 0!==v&&l<v.height;H?l=d+h+t:a&&(l=d-v.height-h-32),u&&(H||a)?s=e+v?.width/2:b&&(H||a)&&(s=e+n-v?.width/2),H&&u?c="top-left":H&&b&&(c="top-right"),a&&u?c="bottom-left":a&&b?c="bottom-right":a&&(c="bottom");const R=o(w,i=>{if(!g||!l)return null;const o=i+l;return o<32?32:o>m?m:o});return s&&s<f?s=f:s&&s>p&&(s=p),{style:{position:g?"absolute":void 0,top:R,left:s},highlightingElement:g,caretPosition:c}}export{t as CARET_OFFSET,d as useTutorialPopoverPosition};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export declare function useReversedScrollY(contentRef: RefObject<HTMLElement | null>): import("motion-dom").MotionValue<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScroll as
|
|
1
|
+
import{useScroll as o,useTransform as r}from"framer-motion";function n(n){const{scrollY:t}=o({container:n});return r(t,o=>o>0?-1*o:0)}export{n as useReversedScrollY};
|