UNPKG

@awsui/components-react

Version:

AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A

18 lines (17 loc) 905 B
import React, { useCallback, useEffect, useState } from 'react'; import AnnotationTrigger from './annotation-trigger'; import { scrollIntoViewWithOffset } from './utils'; export function ClosedAnnotation(_a) { var globalStepIndex = _a.globalStepIndex, onOpen = _a.onOpen, i18nStrings = _a.i18nStrings, focusOnRender = _a.focusOnRender; var _b = useState(null), hotspotRef = _b[0], setHotspotRef = _b[1]; var onClick = useCallback(function () { onOpen(globalStepIndex); }, [globalStepIndex, onOpen]); useEffect(function () { if (focusOnRender && hotspotRef) { hotspotRef.focus({ preventScroll: true }); scrollIntoViewWithOffset(hotspotRef, { top: 40, bottom: 0 }); } }, [focusOnRender, hotspotRef]); return React.createElement(AnnotationTrigger, { open: false, onClick: onClick, i18nStrings: i18nStrings, ref: setHotspotRef }); }