playbook_ui 12.20.0 → 12.21.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,197 +0,0 @@
1
- /* eslint-disable react/display-name */
2
- /* eslint-disable no-unused-vars */
3
-
4
- /* @flow */
5
-
6
- import React from 'react'
7
- import classnames from 'classnames'
8
- import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
9
- import { globalProps } from '../utilities/globalProps'
10
- import Joyride from 'react-joyride'
11
- import Button from '../pb_button/_button'
12
- import Flex from '../pb_flex/_flex'
13
- import SectionSeparator from '../pb_section_separator/_section_separator'
14
- import Title from '../pb_title/_title'
15
-
16
- type WalkthroughProps = {
17
- aria?: object,
18
- callback?: () => void,
19
- className?: string,
20
- continuous?: boolean,
21
- data?: object,
22
- id?: string,
23
- run?: boolean,
24
- steps?: array,
25
- stepIndex?: number,
26
- debug?: Boolean,
27
- disableCloseOnEsc?: Boolean,
28
- disableOverlay?: Boolean,
29
- disableOverlayClose?: Boolean,
30
- disableScrolling?: Boolean,
31
- floaterProps?: object,
32
- hideBackButton?: Boolean,
33
- hideCloseButton?: Boolean,
34
- showProgress?: Boolean,
35
- showSkipButton?: Boolean,
36
- spotlightClicks?: Boolean,
37
- spotlightPadding?: number,
38
- styles?: {
39
- options: {
40
- beaconSize?: Number,
41
- arrowColor?: String,
42
- backgroundColor?: String,
43
- primaryColor?: String,
44
- overlayColor?: String,
45
- spotlightShadow?: String,
46
- width?: Number,
47
- zIndex?: Number,
48
- },
49
- },
50
- }
51
-
52
- type TooltipProps = {
53
- continuous?: Boolean,
54
- className?: String,
55
- index?: number,
56
- isLastStep?: Boolean,
57
- size?: number,
58
- step: {
59
- title?: String,
60
- content?: array<React.ReactNode> | React.ReactNode | String,
61
- target: String,
62
- disableBeacon?: Boolean,
63
- },
64
- skip?: Boolean,
65
- backProps?: object,
66
- closeProps?: object,
67
- primaryProps?: object,
68
- skipProps?: object,
69
- tooltipProps?: object,
70
- }
71
-
72
- const Tooltip = React.forwardRef((props: TooltipProps, ref) => (
73
- <div
74
- className="pb_card_kit_border_none p_none"
75
- {...props.tooltipProps}
76
- >
77
- {props.step.title && <div>
78
- <Flex
79
- align="center"
80
- justify="between"
81
- padding="xs"
82
- >
83
- <Title
84
- paddingLeft="xs"
85
- size={4}
86
- >
87
- {props.step.title}
88
- </Title>
89
- {props.skip && (<Button
90
- {...props.skipProps}
91
- id="skip"
92
- text="Skip Tour"
93
- variant="link"
94
- />)}
95
- <Button
96
- {...props.skipProps}
97
- id="skip"
98
- text="Skip Tour"
99
- variant="link"
100
- />
101
- </Flex>
102
- <SectionSeparator />
103
- </div>}
104
-
105
- <Flex padding="sm">{props.step.content}</Flex>
106
- <SectionSeparator />
107
- <Flex
108
- justify={props.index == 0 ? 'end' : 'between'}
109
- padding="xs"
110
- >
111
-
112
- {props.index > 0 && (
113
- <Button
114
- {...props.backProps}
115
- id="back"
116
- text="Back"
117
- />
118
- )}
119
- <Choose>
120
- <When condition={props.continuous && !props.isLastStep}>
121
- <Button
122
- {...props.primaryProps}
123
- id="next"
124
- text="Next"
125
- />
126
- </When>
127
- <When condition={!props.continuous}>
128
- <Button
129
- {...props.closeProps}
130
- id="close"
131
- text="Close"
132
- />
133
- </When>
134
- <Otherwise>
135
- <Button
136
- {...props.closeProps}
137
- id="close"
138
- text="Close"
139
- />
140
- </Otherwise>
141
- </Choose>
142
- </Flex>
143
- </div>
144
- ))
145
-
146
- const Walkthrough = (props: WalkthroughProps) => {
147
- const {
148
- aria = {},
149
- callback,
150
- className,
151
- continuous = false,
152
- data = {},
153
- disableOverlay,
154
- floaterProps = {
155
- offset: 50,
156
- },
157
- id,
158
- run = false,
159
- steps,
160
- styles = {
161
- options: {
162
- zIndex: 20000,
163
- },
164
- },
165
- showSkipButton,
166
- } = props
167
-
168
- const ariaProps = buildAriaProps(aria)
169
- const dataProps = buildDataProps(data)
170
- const classes = classnames(buildCss('pb_walkthrough'), globalProps(props), className)
171
-
172
- return (
173
- <div
174
- {...ariaProps}
175
- {...dataProps}
176
- className={classes}
177
- id={id}
178
- >
179
- <Joyride
180
- callback={callback}
181
- continuous={continuous}
182
- disableOverlay={disableOverlay}
183
- disableScrolling
184
- floaterProps={floaterProps}
185
- run={run}
186
- showSkipButton={showSkipButton}
187
- steps={steps}
188
- styles={styles}
189
- tooltipComponent={Tooltip}
190
- {...props}
191
- />
192
- </div>
193
-
194
- )
195
- }
196
-
197
- export default Walkthrough