import React from 'react' import classnames from 'classnames' import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props' import { globalProps } from '../utilities/globalProps' import Joyride, { TooltipRenderProps } from 'react-joyride' import Button from '../pb_button/_button' import Flex from '../pb_flex/_flex' import SectionSeparator from '../pb_section_separator/_section_separator' import Title from '../pb_title/_title' type WalkthroughProps = { aria?: { [key: string]: string }, callback?: () => void, className?: string, continuous?: boolean, data?: { [key: string]: string }, htmlOptions?: {[key: string]: string | number | boolean | Function}, id?: string, run?: boolean, steps?: [], stepIndex?: number, debug?: boolean, disableCloseOnEsc?: boolean, disableOverlay?: boolean, disableOverlayClose?: boolean, disableScrolling?: boolean, floaterProps?: object, hideBackButton?: boolean, hideCloseButton?: boolean, showProgress?: boolean, showSkipButton?: boolean, spotlightClicks?: boolean, spotlightPadding?: number, styles?: { options: { beaconSize?: number, arrowColor?: string, backgroundColor?: string, primaryColor?: string, overlayColor?: string, spotlightShadow?: string, width?: number, zIndex?: number, }, }, } type TooltipProps = { continuous?: boolean, className?: string, index?: number, isLastStep?: boolean, size?: number, step: { title?: string, content?: React.ReactNode[] | React.ReactNode | string, target: string, disableBeacon?: boolean, }, skip?: boolean, backProps?: object, closeProps?: object, primaryProps?: object, skipProps?: object, tooltipProps?: object, } const Tooltip = React.forwardRef((props: TooltipProps) => (
{props.step.title &&
{props.step.title} {props.skip && (
} {props.step.content} {props.index > 0 && (
)) as unknown as React.ForwardRefRenderFunction const Walkthrough = (props: WalkthroughProps) => { const { aria = {}, callback, className, continuous = false, data = {}, disableOverlay, floaterProps = { offset: 50, }, htmlOptions = {}, id, run = false, steps, styles = { options: { zIndex: 20000, }, }, showSkipButton, } = props const ariaProps = buildAriaProps(aria) const dataProps = buildDataProps(data) const htmlProps = buildHtmlProps(htmlOptions) const classes = classnames(buildCss('pb_walkthrough'), globalProps(props), className) return (
) } export default Walkthrough