@openedx/paragon 23.14.0 → 23.14.1
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/Alert/index.d.ts +20 -0
- package/dist/Alert/index.js +21 -80
- package/dist/Alert/index.js.map +1 -1
- package/dist/ProductTour/index.js +8 -2
- package/dist/ProductTour/index.js.map +1 -1
- package/dist/theme-urls.json +6 -6
- package/package.json +1 -1
- package/src/Alert/Alert.test.tsx +14 -1
- package/src/Alert/index.tsx +42 -93
- package/src/ProductTour/ProductTour.test.jsx +40 -1
- package/src/ProductTour/index.jsx +8 -2
package/dist/Alert/index.d.ts
CHANGED
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
import React, { ReactNode, ElementType, FC, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
2
|
import { AlertProps as BaseAlertProps } from 'react-bootstrap';
|
|
3
|
+
import { type TransitionComponent } from 'react-bootstrap/helpers';
|
|
3
4
|
import { IconProps } from '../Icon';
|
|
4
5
|
export declare const ALERT_CLOSE_LABEL_TEXT = "Dismiss";
|
|
5
6
|
export type AlertVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light';
|
|
6
7
|
export type BaseProps = Omit<BaseAlertProps, 'children' | 'variant' | 'closeLabel'>;
|
|
7
8
|
export interface AlertProps extends BaseProps {
|
|
9
|
+
/** Specifies class name to append to the base element */
|
|
8
10
|
className?: string;
|
|
11
|
+
/** Overrides underlying component base CSS class name */
|
|
9
12
|
bsPrefix?: string;
|
|
13
|
+
/** Specifies variant to use. */
|
|
10
14
|
variant?: AlertVariant;
|
|
15
|
+
/**
|
|
16
|
+
* Animate the entering and exiting of the Alert. `true` will use the `<Fade>` transition,
|
|
17
|
+
* more detailed customization is also provided.
|
|
18
|
+
*/
|
|
19
|
+
transition?: boolean | TransitionComponent;
|
|
11
20
|
children?: ReactNode;
|
|
21
|
+
/** Icon that will be shown in the alert */
|
|
12
22
|
icon?: React.ComponentType<IconProps>;
|
|
23
|
+
/** Whether the alert is shown. */
|
|
13
24
|
show?: boolean;
|
|
25
|
+
/** Whether the alert is dismissible. Defaults to false. */
|
|
14
26
|
dismissible?: boolean;
|
|
27
|
+
/** Optional callback function for when the alert it dismissed. */
|
|
15
28
|
onClose?: () => void;
|
|
29
|
+
/** Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true. */
|
|
16
30
|
actions?: React.ReactElement[];
|
|
31
|
+
/** Position of the dismiss and call-to-action buttons. Defaults to `false`. */
|
|
17
32
|
stacked?: boolean;
|
|
33
|
+
/** Sets the text for alert close button, defaults to 'Dismiss'. */
|
|
18
34
|
closeLabel?: string | ReactNode;
|
|
19
35
|
}
|
|
20
36
|
export interface AlertHeadingProps {
|
|
37
|
+
/** Specifies the base element */
|
|
21
38
|
as?: ElementType;
|
|
39
|
+
/** Overrides underlying component base CSS class name */
|
|
22
40
|
bsPrefix?: string;
|
|
23
41
|
children?: ReactNode;
|
|
24
42
|
}
|
|
25
43
|
export interface AlertLinkProps {
|
|
44
|
+
/** Specifies the base element */
|
|
26
45
|
as?: ElementType;
|
|
46
|
+
/** Overrides underlying component base CSS class name */
|
|
27
47
|
bsPrefix?: string;
|
|
28
48
|
children?: ReactNode;
|
|
29
49
|
href?: string;
|
package/dist/Alert/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/require-default-props */
|
|
2
2
|
import React, { useCallback, useEffect, useState, forwardRef, cloneElement } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import classNames from 'classnames';
|
|
5
4
|
import { Alert as BaseAlert } from 'react-bootstrap';
|
|
6
5
|
import divWithClassName from 'react-bootstrap/divWithClassName';
|
|
@@ -17,10 +16,11 @@ const Alert = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
17
16
|
children,
|
|
18
17
|
icon,
|
|
19
18
|
actions,
|
|
20
|
-
dismissible,
|
|
21
|
-
onClose,
|
|
19
|
+
dismissible = false,
|
|
20
|
+
onClose = () => {},
|
|
22
21
|
closeLabel,
|
|
23
|
-
stacked,
|
|
22
|
+
stacked = false,
|
|
23
|
+
show = true,
|
|
24
24
|
...props
|
|
25
25
|
} = _ref;
|
|
26
26
|
const [isStacked, setIsStacked] = useState(stacked);
|
|
@@ -45,6 +45,7 @@ const Alert = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
45
45
|
return /*#__PURE__*/React.createElement(BaseAlert, {
|
|
46
46
|
...props,
|
|
47
47
|
className: classNames('alert-content', props.className),
|
|
48
|
+
show: show,
|
|
48
49
|
ref: ref
|
|
49
50
|
}, icon && /*#__PURE__*/React.createElement(Icon, {
|
|
50
51
|
src: icon,
|
|
@@ -74,90 +75,30 @@ const Alert = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
74
75
|
// so there seems to be no other way of providing correct default prop for base element
|
|
75
76
|
const DivStyledAsH4 = divWithClassName('h4');
|
|
76
77
|
DivStyledAsH4.displayName = 'DivStyledAsH4';
|
|
77
|
-
function AlertHeading(
|
|
78
|
+
function AlertHeading(_ref2) {
|
|
79
|
+
let {
|
|
80
|
+
as = DivStyledAsH4,
|
|
81
|
+
bsPrefix = 'alert-heading',
|
|
82
|
+
...props
|
|
83
|
+
} = _ref2;
|
|
78
84
|
return /*#__PURE__*/React.createElement(BaseAlert.Heading, {
|
|
85
|
+
as,
|
|
86
|
+
bsPrefix,
|
|
79
87
|
...props
|
|
80
88
|
});
|
|
81
89
|
}
|
|
82
|
-
function AlertLink(
|
|
90
|
+
function AlertLink(_ref3) {
|
|
91
|
+
let {
|
|
92
|
+
as = 'a',
|
|
93
|
+
bsPrefix = 'alert-link',
|
|
94
|
+
...props
|
|
95
|
+
} = _ref3;
|
|
83
96
|
return /*#__PURE__*/React.createElement(BaseAlert.Link, {
|
|
97
|
+
as,
|
|
98
|
+
bsPrefix,
|
|
84
99
|
...props
|
|
85
100
|
});
|
|
86
101
|
}
|
|
87
|
-
AlertLink.propTypes = {
|
|
88
|
-
/** Specifies the base element */
|
|
89
|
-
as: PropTypes.elementType,
|
|
90
|
-
/** Overrides underlying component base CSS class name */
|
|
91
|
-
bsPrefix: PropTypes.string
|
|
92
|
-
};
|
|
93
|
-
AlertHeading.propTypes = {
|
|
94
|
-
/** Specifies the base element */
|
|
95
|
-
as: PropTypes.elementType,
|
|
96
|
-
/** Overrides underlying component base CSS class name */
|
|
97
|
-
bsPrefix: PropTypes.string
|
|
98
|
-
};
|
|
99
|
-
AlertLink.defaultProps = {
|
|
100
|
-
as: 'a',
|
|
101
|
-
bsPrefix: 'alert-link'
|
|
102
|
-
};
|
|
103
|
-
AlertHeading.defaultProps = {
|
|
104
|
-
as: DivStyledAsH4,
|
|
105
|
-
bsPrefix: 'alert-heading'
|
|
106
|
-
};
|
|
107
|
-
Alert.propTypes = {
|
|
108
|
-
...BaseAlert.propTypes,
|
|
109
|
-
/** Specifies class name to append to the base element */
|
|
110
|
-
className: PropTypes.string,
|
|
111
|
-
/** Overrides underlying component base CSS class name */
|
|
112
|
-
bsPrefix: PropTypes.string,
|
|
113
|
-
/** Specifies variant to use. */
|
|
114
|
-
variant: PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light']),
|
|
115
|
-
/**
|
|
116
|
-
* Animate the entering and exiting of the Alert. `true` will use the `<Fade>` transition,
|
|
117
|
-
* more detailed customization is also provided.
|
|
118
|
-
*/
|
|
119
|
-
transition: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
|
|
120
|
-
in: PropTypes.bool,
|
|
121
|
-
appear: PropTypes.bool,
|
|
122
|
-
children: PropTypes.node,
|
|
123
|
-
onEnter: PropTypes.func,
|
|
124
|
-
onEntered: PropTypes.func,
|
|
125
|
-
onEntering: PropTypes.func,
|
|
126
|
-
onExit: PropTypes.func,
|
|
127
|
-
onExited: PropTypes.func,
|
|
128
|
-
onExiting: PropTypes.func
|
|
129
|
-
})]),
|
|
130
|
-
/** Docstring for the children prop */
|
|
131
|
-
children: PropTypes.node,
|
|
132
|
-
/** Docstring for the icon prop... Icon that will be shown in the alert */
|
|
133
|
-
icon: PropTypes.func,
|
|
134
|
-
/** Whether the alert is shown. */
|
|
135
|
-
show: PropTypes.bool,
|
|
136
|
-
/** Whether the alert is dismissible. Defaults to true. */
|
|
137
|
-
dismissible: PropTypes.bool,
|
|
138
|
-
/** Optional callback function for when the alert it dismissed. */
|
|
139
|
-
onClose: PropTypes.func,
|
|
140
|
-
/** Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true. */
|
|
141
|
-
actions: PropTypes.arrayOf(PropTypes.element),
|
|
142
|
-
/** Position of the dismiss and call-to-action buttons. Defaults to ``false``. */
|
|
143
|
-
stacked: PropTypes.bool,
|
|
144
|
-
/** Sets the text for alert close button, defaults to 'Dismiss'. */
|
|
145
|
-
closeLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
|
|
146
|
-
};
|
|
147
|
-
Alert.defaultProps = {
|
|
148
|
-
...BaseAlert.defaultProps,
|
|
149
|
-
children: undefined,
|
|
150
|
-
icon: undefined,
|
|
151
|
-
actions: undefined,
|
|
152
|
-
dismissible: false,
|
|
153
|
-
onClose: () => {},
|
|
154
|
-
closeLabel: undefined,
|
|
155
|
-
show: true,
|
|
156
|
-
stacked: false,
|
|
157
|
-
className: undefined,
|
|
158
|
-
bsPrefix: undefined,
|
|
159
|
-
variant: undefined
|
|
160
|
-
};
|
|
161
102
|
Alert.Heading = AlertHeading;
|
|
162
103
|
Alert.Link = AlertLink;
|
|
163
104
|
export default Alert;
|
package/dist/Alert/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","forwardRef","cloneElement","PropTypes","classNames","Alert","BaseAlert","divWithClassName","FormattedMessage","useMediaQuery","Icon","breakpoints","Button","ActionRow","ALERT_CLOSE_LABEL_TEXT","_ref","ref","children","icon","actions","dismissible","onClose","closeLabel","stacked","props","isStacked","setIsStacked","isExtraSmall","maxWidth","extraSmall","actionButtonSize","cloneActionElement","Action","addtlActionProps","size","key","createElement","className","src","length","Spacer","variant","onClick","id","defaultMessage","description","map","DivStyledAsH4","displayName","AlertHeading","Heading","AlertLink","Link","propTypes","as","elementType","bsPrefix","string","defaultProps","oneOf","transition","oneOfType","bool","shape","in","appear","node","onEnter","func","onEntered","onEntering","onExit","onExited","onExiting","show","arrayOf","element","undefined"],"sources":["../../src/Alert/index.tsx"],"sourcesContent":["/* eslint-disable react/require-default-props */\nimport React, {\n useCallback,\n useEffect,\n useState,\n ReactNode,\n ElementType,\n forwardRef,\n FC,\n ForwardRefExoticComponent,\n RefAttributes,\n cloneElement,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport {\n Alert as BaseAlert,\n AlertProps as BaseAlertProps,\n} from 'react-bootstrap';\nimport divWithClassName from 'react-bootstrap/divWithClassName';\nimport { FormattedMessage } from 'react-intl';\nimport { useMediaQuery } from 'react-responsive';\nimport Icon, { IconProps } from '../Icon';\nimport breakpoints from '../utils/breakpoints';\nimport Button from '../Button';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ActionRow from '../ActionRow';\n\nexport const ALERT_CLOSE_LABEL_TEXT = 'Dismiss';\n\nexport type AlertVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light';\n\nexport type BaseProps = Omit<BaseAlertProps, 'children' | 'variant' | 'closeLabel'>;\n\nexport interface AlertProps extends BaseProps {\n className?: string;\n bsPrefix?: string;\n variant?: AlertVariant;\n children?: ReactNode;\n icon?: React.ComponentType<IconProps>;\n show?: boolean;\n dismissible?: boolean;\n onClose?: () => void;\n actions?: React.ReactElement[];\n stacked?: boolean;\n closeLabel?: string | ReactNode;\n}\n\nexport interface AlertHeadingProps {\n as?: ElementType;\n bsPrefix?: string;\n children?: ReactNode;\n}\n\nexport interface AlertLinkProps {\n as?: ElementType;\n bsPrefix?: string;\n children?: ReactNode;\n href?: string;\n}\n\nexport interface AlertComponent extends ForwardRefExoticComponent<AlertProps & RefAttributes<HTMLDivElement>> {\n Heading: FC<AlertHeadingProps>;\n Link: FC<AlertLinkProps>;\n}\n\nconst Alert = forwardRef<HTMLDivElement, AlertProps>(({\n children,\n icon,\n actions,\n dismissible,\n onClose,\n closeLabel,\n stacked,\n ...props\n}, ref) => {\n const [isStacked, setIsStacked] = useState(stacked);\n const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });\n const actionButtonSize = 'sm';\n\n useEffect(() => {\n if (isExtraSmall) {\n setIsStacked(true);\n } else {\n setIsStacked(stacked);\n }\n }, [isExtraSmall, stacked]);\n\n const cloneActionElement = useCallback(\n (Action: React.ReactElement) => {\n const addtlActionProps = { size: actionButtonSize, key: Action.props.children };\n return cloneElement(Action, addtlActionProps);\n },\n [],\n );\n\n return (\n <BaseAlert\n {...props}\n className={classNames('alert-content', props.className)}\n ref={ref}\n >\n {icon && <Icon src={icon} className=\"alert-icon\" />}\n <div\n className={classNames({\n 'pgn__alert-message-wrapper': !isStacked,\n 'pgn__alert-message-wrapper-stacked': isStacked,\n })}\n >\n <div className=\"alert-message-content\">\n {children}\n </div>\n {(dismissible || (actions && actions.length > 0)) && (\n <ActionRow className=\"pgn__alert-actions\">\n <ActionRow.Spacer />\n {dismissible && (\n <Button\n size={actionButtonSize}\n variant=\"tertiary\"\n onClick={onClose}\n >\n {closeLabel || (\n <FormattedMessage\n id=\"pgn.Alert.closeLabel\"\n defaultMessage=\"Dismiss\"\n description=\"Label of a close button on Alert component\"\n />\n )}\n </Button>\n )}\n {actions && actions.map(cloneActionElement)}\n </ActionRow>\n )}\n </div>\n </BaseAlert>\n );\n}) as AlertComponent;\n\n// This is needed to display a default prop for Alert.Heading element\n// Copied from react-bootstrap since BaseAlert.Heading component doesn't have defaultProps,\n// so there seems to be no other way of providing correct default prop for base element\nconst DivStyledAsH4 = divWithClassName('h4');\nDivStyledAsH4.displayName = 'DivStyledAsH4';\n\nfunction AlertHeading(props: AlertHeadingProps): JSX.Element {\n return <BaseAlert.Heading {...props} />;\n}\n\nfunction AlertLink(props: AlertLinkProps): JSX.Element {\n return <BaseAlert.Link {...props} />;\n}\n\nAlertLink.propTypes = {\n /** Specifies the base element */\n as: PropTypes.elementType as PropTypes.Validator<ElementType>,\n /** Overrides underlying component base CSS class name */\n bsPrefix: PropTypes.string,\n};\n\nAlertHeading.propTypes = {\n /** Specifies the base element */\n as: PropTypes.elementType as PropTypes.Validator<ElementType>,\n /** Overrides underlying component base CSS class name */\n bsPrefix: PropTypes.string,\n};\n\nAlertLink.defaultProps = {\n as: 'a' as ElementType,\n bsPrefix: 'alert-link',\n};\n\nAlertHeading.defaultProps = {\n as: DivStyledAsH4,\n bsPrefix: 'alert-heading',\n};\n\nAlert.propTypes = {\n ...BaseAlert.propTypes,\n /** Specifies class name to append to the base element */\n className: PropTypes.string,\n /** Overrides underlying component base CSS class name */\n bsPrefix: PropTypes.string,\n /** Specifies variant to use. */\n variant: PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'] as AlertVariant[]),\n /**\n * Animate the entering and exiting of the Alert. `true` will use the `<Fade>` transition,\n * more detailed customization is also provided.\n */\n transition: PropTypes.oneOfType([\n PropTypes.bool,\n PropTypes.shape({\n in: PropTypes.bool,\n appear: PropTypes.bool,\n children: PropTypes.node,\n onEnter: PropTypes.func,\n onEntered: PropTypes.func,\n onEntering: PropTypes.func,\n onExit: PropTypes.func,\n onExited: PropTypes.func,\n onExiting: PropTypes.func,\n }),\n ]) as PropTypes.Validator<BaseAlertProps['transition']>,\n /** Docstring for the children prop */\n children: PropTypes.node as PropTypes.Validator<ReactNode>,\n /** Docstring for the icon prop... Icon that will be shown in the alert */\n icon: PropTypes.func,\n /** Whether the alert is shown. */\n show: PropTypes.bool,\n /** Whether the alert is dismissible. Defaults to true. */\n dismissible: PropTypes.bool,\n /** Optional callback function for when the alert it dismissed. */\n onClose: PropTypes.func,\n /** Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true. */\n actions: PropTypes.arrayOf(PropTypes.element) as PropTypes.Validator<React.ReactElement[]>,\n /** Position of the dismiss and call-to-action buttons. Defaults to ``false``. */\n stacked: PropTypes.bool,\n /** Sets the text for alert close button, defaults to 'Dismiss'. */\n closeLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n};\n\nAlert.defaultProps = {\n ...BaseAlert.defaultProps,\n children: undefined,\n icon: undefined,\n actions: undefined,\n dismissible: false,\n onClose: () => {},\n closeLabel: undefined,\n show: true,\n stacked: false,\n className: undefined,\n bsPrefix: undefined,\n variant: undefined,\n};\n\nAlert.Heading = AlertHeading;\nAlert.Link = AlertLink;\n\nexport default Alert;\n"],"mappings":"AAAA;AACA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,QAAQ,EAGRC,UAAU,EAIVC,YAAY,QACP,OAAO;AACd,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SACEC,KAAK,IAAIC,SAAS,QAEb,iBAAiB;AACxB,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,IAAI,MAAqB,SAAS;AACzC,OAAOC,WAAW,MAAM,sBAAsB;AAC9C,OAAOC,MAAM,MAAM,WAAW;AAC9B;AACA,OAAOC,SAAS,MAAM,cAAc;AAEpC,OAAO,MAAMC,sBAAsB,GAAG,SAAS;AAsC/C,MAAMT,KAAK,gBAAGJ,UAAU,CAA6B,CAAAc,IAAA,EASlDC,GAAG,KAAK;EAAA,IAT2C;IACpDC,QAAQ;IACRC,IAAI;IACJC,OAAO;IACPC,WAAW;IACXC,OAAO;IACPC,UAAU;IACVC,OAAO;IACP,GAAGC;EACL,CAAC,GAAAT,IAAA;EACC,MAAM,CAACU,SAAS,EAAEC,YAAY,CAAC,GAAG1B,QAAQ,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AACwE,OAAO,CAACxE,SAAS,CAACyE,OAAO,CAA8C;EAC1F;EACArD,OAAO,EAAEpB,SAAS,CAAC2D,IAAI;EACvB;EACAxC,UAAU,EAAEnB,SAAS,CAAC0D,SAAS,CAAC,CAAC1D,SAAS,CAACsD,MAAM,EAAEtD,SAAS,CAACyE,OAAO,CAAC;AACvE,CAAC;AAEDvE,KAAK,CAACqD,YAAY,GAAG;EACnB,GAAGpD,SAAS,CAACoD,YAAY;EACzBzC,QAAQ,EAAE4D,SAAS;EACnB3D,IAAI,EAAE2D,SAAS;EACf1D,OAAO,EAAE0D,SAAS;EAClBzD,WAAW,EAAE,KAAK;EAClBC,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjBC,UAAU,EAAEuD,SAAS;EACrBH,IAAI,EAAE,IAAI;EACVnD,OAAO,EAAE,KAAK;EACdc,SAAS,EAAEwC,SAAS;EACpBrB,QAAQ,EAAEqB,SAAS;EACnBpC,OAAO,EAAEoC;AACX,CAAC;AAEDxE,KAAK,CAAC6C,OAAO,GAAGD,YAAY;AAC5B5C,KAAK,CAAC+C,IAAI,GAAGD,SAAS;AAEtB,eAAe9C,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","forwardRef","cloneElement","classNames","Alert","BaseAlert","divWithClassName","FormattedMessage","useMediaQuery","Icon","breakpoints","Button","ActionRow","ALERT_CLOSE_LABEL_TEXT","_ref","ref","children","icon","actions","dismissible","onClose","closeLabel","stacked","show","props","isStacked","setIsStacked","isExtraSmall","maxWidth","extraSmall","actionButtonSize","cloneActionElement","Action","addtlActionProps","size","key","createElement","className","src","length","Spacer","variant","onClick","id","defaultMessage","description","map","DivStyledAsH4","displayName","AlertHeading","_ref2","as","bsPrefix","Heading","AlertLink","_ref3","Link"],"sources":["../../src/Alert/index.tsx"],"sourcesContent":["/* eslint-disable react/require-default-props */\nimport React, {\n useCallback,\n useEffect,\n useState,\n ReactNode,\n ElementType,\n forwardRef,\n FC,\n ForwardRefExoticComponent,\n RefAttributes,\n cloneElement,\n} from 'react';\nimport classNames from 'classnames';\nimport {\n Alert as BaseAlert,\n AlertProps as BaseAlertProps,\n} from 'react-bootstrap';\nimport { type TransitionComponent } from 'react-bootstrap/helpers';\nimport divWithClassName from 'react-bootstrap/divWithClassName';\nimport { FormattedMessage } from 'react-intl';\nimport { useMediaQuery } from 'react-responsive';\nimport Icon, { IconProps } from '../Icon';\nimport breakpoints from '../utils/breakpoints';\nimport Button from '../Button';\n// @ts-ignore for now - this needs to be converted to TypeScript\nimport ActionRow from '../ActionRow';\n\nexport const ALERT_CLOSE_LABEL_TEXT = 'Dismiss';\n\nexport type AlertVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light';\n\nexport type BaseProps = Omit<BaseAlertProps, 'children' | 'variant' | 'closeLabel'>;\n\nexport interface AlertProps extends BaseProps {\n /** Specifies class name to append to the base element */\n className?: string;\n /** Overrides underlying component base CSS class name */\n bsPrefix?: string;\n /** Specifies variant to use. */\n variant?: AlertVariant;\n /**\n * Animate the entering and exiting of the Alert. `true` will use the `<Fade>` transition,\n * more detailed customization is also provided.\n */\n transition?: boolean | TransitionComponent;\n children?: ReactNode;\n /** Icon that will be shown in the alert */\n icon?: React.ComponentType<IconProps>;\n /** Whether the alert is shown. */\n show?: boolean;\n /** Whether the alert is dismissible. Defaults to false. */\n dismissible?: boolean;\n /** Optional callback function for when the alert it dismissed. */\n onClose?: () => void;\n /** Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true. */\n actions?: React.ReactElement[];\n /** Position of the dismiss and call-to-action buttons. Defaults to `false`. */\n stacked?: boolean;\n /** Sets the text for alert close button, defaults to 'Dismiss'. */\n closeLabel?: string | ReactNode;\n}\n\nexport interface AlertHeadingProps {\n /** Specifies the base element */\n as?: ElementType;\n /** Overrides underlying component base CSS class name */\n bsPrefix?: string;\n // eslint-disable-next-line react/no-unused-prop-types\n children?: ReactNode;\n}\n\nexport interface AlertLinkProps {\n /** Specifies the base element */\n as?: ElementType;\n /** Overrides underlying component base CSS class name */\n bsPrefix?: string;\n // eslint-disable-next-line react/no-unused-prop-types\n children?: ReactNode;\n // eslint-disable-next-line react/no-unused-prop-types\n href?: string;\n}\n\nexport interface AlertComponent extends ForwardRefExoticComponent<AlertProps & RefAttributes<HTMLDivElement>> {\n Heading: FC<AlertHeadingProps>;\n Link: FC<AlertLinkProps>;\n}\n\nconst Alert = forwardRef(({\n children,\n icon,\n actions,\n dismissible = false,\n onClose = () => {},\n closeLabel,\n stacked = false,\n show = true,\n ...props\n}: AlertProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const [isStacked, setIsStacked] = useState(stacked);\n const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });\n const actionButtonSize = 'sm';\n\n useEffect(() => {\n if (isExtraSmall) {\n setIsStacked(true);\n } else {\n setIsStacked(stacked);\n }\n }, [isExtraSmall, stacked]);\n\n const cloneActionElement = useCallback(\n (Action: React.ReactElement) => {\n const addtlActionProps = { size: actionButtonSize, key: Action.props.children };\n return cloneElement(Action, addtlActionProps);\n },\n [],\n );\n\n return (\n <BaseAlert\n {...props}\n className={classNames('alert-content', props.className)}\n show={show}\n ref={ref}\n >\n {icon && <Icon src={icon} className=\"alert-icon\" />}\n <div\n className={classNames({\n 'pgn__alert-message-wrapper': !isStacked,\n 'pgn__alert-message-wrapper-stacked': isStacked,\n })}\n >\n <div className=\"alert-message-content\">\n {children}\n </div>\n {(dismissible || (actions && actions.length > 0)) && (\n <ActionRow className=\"pgn__alert-actions\">\n <ActionRow.Spacer />\n {dismissible && (\n <Button\n size={actionButtonSize}\n variant=\"tertiary\"\n onClick={onClose}\n >\n {closeLabel || (\n <FormattedMessage\n id=\"pgn.Alert.closeLabel\"\n defaultMessage=\"Dismiss\"\n description=\"Label of a close button on Alert component\"\n />\n )}\n </Button>\n )}\n {actions && actions.map(cloneActionElement)}\n </ActionRow>\n )}\n </div>\n </BaseAlert>\n );\n}) as AlertComponent;\n\n// This is needed to display a default prop for Alert.Heading element\n// Copied from react-bootstrap since BaseAlert.Heading component doesn't have defaultProps,\n// so there seems to be no other way of providing correct default prop for base element\nconst DivStyledAsH4 = divWithClassName('h4');\nDivStyledAsH4.displayName = 'DivStyledAsH4';\n\nfunction AlertHeading({\n as = DivStyledAsH4,\n bsPrefix = 'alert-heading',\n ...props\n}: AlertHeadingProps): JSX.Element {\n return <BaseAlert.Heading {...{ as, bsPrefix, ...props }} />;\n}\n\nfunction AlertLink({\n as = 'a',\n bsPrefix = 'alert-link',\n ...props\n}: AlertLinkProps): JSX.Element {\n return <BaseAlert.Link {...{ as, bsPrefix, ...props }} />;\n}\n\nAlert.Heading = AlertHeading;\nAlert.Link = AlertLink;\n\nexport default Alert;\n"],"mappings":"AAAA;AACA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,QAAQ,EAGRC,UAAU,EAIVC,YAAY,QACP,OAAO;AACd,OAAOC,UAAU,MAAM,YAAY;AACnC,SACEC,KAAK,IAAIC,SAAS,QAEb,iBAAiB;AAExB,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,IAAI,MAAqB,SAAS;AACzC,OAAOC,WAAW,MAAM,sBAAsB;AAC9C,OAAOC,MAAM,MAAM,WAAW;AAC9B;AACA,OAAOC,SAAS,MAAM,cAAc;AAEpC,OAAO,MAAMC,sBAAsB,GAAG,SAAS;AA4D/C,MAAMT,KAAK,gBAAGH,UAAU,CAAC,CAAAa,IAAA,EAUVC,GAAuC,KAAK;EAAA,IAVjC;IACxBC,QAAQ;IACRC,IAAI;IACJC,OAAO;IACPC,WAAW,GAAG,KAAK;IACnBC,OAAO,GAAGA,CAAA,KAAM,CAAC,CAAC;IAClBC,UAAU;IACVC,OAAO,GAAG,KAAK;IACfC,IAAI,GAAG,IAAI;IACX,GAAG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,CAAK,CAAC;AAC3D;AAEApB,KAAK,CAACiD,OAAO,GAAGJ,YAAY;AAC5B7C,KAAK,CAACoD,IAAI,GAAGF,SAAS;AAEtB,eAAelD,KAAK","ignoreList":[]}
|
|
@@ -13,7 +13,8 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
13
13
|
startingIndex,
|
|
14
14
|
onEscape,
|
|
15
15
|
onEnd,
|
|
16
|
-
|
|
16
|
+
onAdvance: tourOnAdvance,
|
|
17
|
+
onBack: tourOnBack,
|
|
17
18
|
onDismiss: tourOnDismiss,
|
|
18
19
|
advanceButtonText: tourAdvanceButtonText,
|
|
19
20
|
dismissAltText: tourDismissAltText,
|
|
@@ -28,6 +29,7 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
28
29
|
title,
|
|
29
30
|
body,
|
|
30
31
|
onAdvance,
|
|
32
|
+
onBack,
|
|
31
33
|
onDismiss,
|
|
32
34
|
advanceButtonText,
|
|
33
35
|
dismissAltText,
|
|
@@ -78,12 +80,16 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
78
80
|
setIndex(index + 1);
|
|
79
81
|
if (onAdvance) {
|
|
80
82
|
onAdvance();
|
|
83
|
+
} else if (tourOnAdvance) {
|
|
84
|
+
tourOnAdvance();
|
|
81
85
|
}
|
|
82
86
|
};
|
|
83
87
|
const handleBack = () => {
|
|
84
88
|
setIndex(index - 1);
|
|
85
89
|
if (onBack) {
|
|
86
90
|
onBack();
|
|
91
|
+
} else if (tourOnBack) {
|
|
92
|
+
tourOnBack();
|
|
87
93
|
}
|
|
88
94
|
};
|
|
89
95
|
const handleDismiss = () => {
|
|
@@ -91,7 +97,7 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
91
97
|
setIsTourEnabled(false);
|
|
92
98
|
if (onDismiss) {
|
|
93
99
|
onDismiss();
|
|
94
|
-
} else {
|
|
100
|
+
} else if (tourOnDismiss) {
|
|
95
101
|
tourOnDismiss();
|
|
96
102
|
}
|
|
97
103
|
setCurrentCheckpointData(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useEffect","useState","PropTypes","withDeprecatedProps","DeprTypes","Checkpoint","ProductTour","forwardRef","_ref","ref","tours","tourValue","find","tour","enabled","checkpoints","startingIndex","onEscape","onEnd","onBack","onDismiss","tourOnDismiss","advanceButtonText","tourAdvanceButtonText","dismissAltText","tourDismissAltText","endButtonText","tourEndButtonText","backButtonText","tourBackButtonText","currentCheckpointData","setCurrentCheckpointData","index","setIndex","isTourEnabled","setIsTourEnabled","prunedCheckpoints","setPrunedCheckpoints","title","body","onAdvance","placement","target","pruneCheckpoints","checkpointList","checkpointsWithRenderedTargets","filter","checkpoint","document","querySelector","length","handleEsc","event","key","global","addEventListener","removeEventListener","handleAdvance","handleBack","handleDismiss","handleEnd","checkpointIndex","createElement","totalCheckpoints","defaultProps","propTypes","arrayOf","shape","node","string","func","oneOf","isRequired","bool","number","tourId","hasDismissButtonText","obj","dismissButtonText","deprType","FORMAT","message","expect","propValue","Array","isArray","some","transform","map","updatedTour","warningMessage","console","warn","rest"],"sources":["../../src/ProductTour/index.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\nimport Checkpoint from './Checkpoint';\n\nconst ProductTour = React.forwardRef(({ tours }, ref) => {\n const tourValue = tours.find((tour) => tour.enabled);\n const {\n enabled,\n checkpoints = [],\n startingIndex,\n onEscape,\n onEnd,\n onBack,\n onDismiss: tourOnDismiss,\n advanceButtonText: tourAdvanceButtonText,\n dismissAltText: tourDismissAltText,\n endButtonText: tourEndButtonText,\n backButtonText: tourBackButtonText,\n } = tourValue || {};\n const [currentCheckpointData, setCurrentCheckpointData] = useState(null);\n const [index, setIndex] = useState(0);\n const [isTourEnabled, setIsTourEnabled] = useState(false);\n const [prunedCheckpoints, setPrunedCheckpoints] = useState([]);\n const {\n title,\n body,\n onAdvance,\n onDismiss,\n advanceButtonText,\n dismissAltText,\n endButtonText,\n backButtonText,\n placement,\n target,\n } = currentCheckpointData || {};\n\n /**\n * Takes a list of checkpoints and verifies that each target string provided is\n * an element in the DOM.\n */\n const pruneCheckpoints = (checkpointList) => {\n const checkpointsWithRenderedTargets = checkpointList.filter(\n (checkpoint) => !!document.querySelector(checkpoint.target),\n );\n setPrunedCheckpoints(checkpointsWithRenderedTargets);\n };\n\n useEffect(() => {\n if (enabled && checkpoints) {\n setIsTourEnabled(enabled);\n pruneCheckpoints(checkpoints);\n setIndex(startingIndex || 0);\n }\n }, [enabled, checkpoints, startingIndex]);\n\n useEffect(() => {\n if (isTourEnabled && prunedCheckpoints.length) {\n setCurrentCheckpointData(prunedCheckpoints[index]);\n }\n }, [index, isTourEnabled, prunedCheckpoints]);\n\n useEffect(() => {\n const handleEsc = (event) => {\n if (event.key === 'Escape') {\n setIsTourEnabled(false);\n if (onEscape) {\n onEscape();\n }\n }\n };\n global.addEventListener('keydown', handleEsc);\n\n return () => {\n global.removeEventListener('keydown', handleEsc);\n };\n }, [onEscape]);\n\n if (!tourValue || !currentCheckpointData || !isTourEnabled) {\n return null;\n }\n\n const handleAdvance = () => {\n setIndex(index + 1);\n if (onAdvance) {\n onAdvance();\n }\n };\n\n const handleBack = () => {\n setIndex(index - 1);\n if (onBack) {\n onBack();\n }\n };\n\n const handleDismiss = () => {\n setIndex(0);\n setIsTourEnabled(false);\n if (onDismiss) {\n onDismiss();\n } else {\n tourOnDismiss();\n }\n setCurrentCheckpointData(null);\n };\n /* eslint-disable */\n /**\n * Takes the final checkpoint array index value and looks for an existing onEnd callback.\n * \n * If an onEnd callback exist on checkpointIndex value and it is the final checkpoint \n * in the array, the onEnd callback will be called for the parent, and individual onEnd object. \n * \n * @param {Integer} checkpointIndex \n */\n /* eslint-enable */\n const handleEnd = (checkpointIndex) => {\n setIndex(0);\n setIsTourEnabled(false);\n if (prunedCheckpoints[checkpointIndex].onEnd) {\n prunedCheckpoints[checkpointIndex].onEnd();\n } else if (onEnd) {\n onEnd(prunedCheckpoints[checkpointIndex]);\n }\n setCurrentCheckpointData(null);\n };\n return (\n <Checkpoint\n advanceButtonText={advanceButtonText || tourAdvanceButtonText}\n body={body}\n currentCheckpointData={currentCheckpointData}\n dismissAltText={dismissAltText || tourDismissAltText}\n endButtonText={endButtonText || tourEndButtonText}\n backButtonText={backButtonText || tourBackButtonText}\n index={index}\n onBack={handleBack}\n onAdvance={handleAdvance}\n onDismiss={handleDismiss}\n onEnd={handleEnd}\n placement={placement}\n target={target}\n title={title}\n totalCheckpoints={prunedCheckpoints.length}\n ref={ref}\n />\n );\n});\n\nProductTour.defaultProps = {\n tours: {\n advanceButtonText: '',\n backButtonText: '',\n checkpoints: {\n advanceButtonText: '',\n backButtonText: '',\n body: '',\n dismissAltText: '',\n endButtonText: '',\n onAdvance: () => {},\n onDismiss: () => {},\n onBack: () => {},\n placement: 'top',\n title: '',\n },\n dismissAltText: '',\n endButtonText: '',\n onBack: () => {},\n onDismiss: () => {},\n onEnd: () => {},\n onEscape: () => {},\n startingIndex: 0,\n },\n};\n\nProductTour.propTypes = {\n tours: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on all buttons used to advance the tour. */\n advanceButtonText: PropTypes.node,\n /** The text displayed on all buttons used to go back in the tour */\n backButtonText: PropTypes.string,\n /** An array comprised of checkpoint objects supporting the following values: */\n checkpoints: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on the button used to advance the tour for the given Checkpoint\n * (overrides the* `advanceButtonText` defined in the parent tour object). */\n advanceButtonText: PropTypes.node,\n /** The text displayed on the button used to go back in the tour for the given Checkpoint\n * (overrides the* `backButtonText` defined in the parent tour object). */\n backButtonText: PropTypes.string,\n /** The text displayed in the body of the Checkpoint */\n body: PropTypes.node,\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** The text displayed on the button used to end the tour for the given Checkpoint\n * (overrides the `endButtonText` defined in the parent tour object). */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onClick` event of the advance\n * button for the given Checkpoint. */\n onAdvance: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint (overrides the `onDismiss` function defined in the parent tour object). */\n onDismiss: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the advance\n * button if the given Checkpoint is the only or last Checkpoint in a tour. */\n onEnd: PropTypes.func,\n /** A string that dictates the alignment of the Checkpoint around its target. */\n placement: PropTypes.oneOf([\n 'top', 'top-start', 'top-end', 'right-start', 'right', 'right-end',\n 'left-start', 'left', 'left-end', 'bottom', 'bottom-start', 'bottom-end',\n ]),\n /** The CSS selector for the Checkpoint's desired target. */\n target: PropTypes.string.isRequired,\n /** The text displayed in the title of the Checkpoint */\n title: PropTypes.node,\n })),\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** Whether the tour is enabled. If there are multiple tours defined, only one should be enabled at a time. */\n enabled: PropTypes.bool.isRequired,\n /** The text displayed on the button used to end the tour. */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onBack` event of the back button. */\n onBack: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss button. */\n onDismiss: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the end button. */\n onEnd: PropTypes.func,\n /** A function that runs when pressing the Escape key. */\n onEscape: PropTypes.func,\n /** The index of the desired `Checkpoint` to render when the tour starts. */\n startingIndex: PropTypes.number,\n /** The ID of the tour */\n tourId: PropTypes.string.isRequired,\n })),\n};\n\n/**\n * Checks if the given object has a deprecated/legacy `dismissButtonText` property.\n * @param {Object} obj - The object to check\n * @returns {boolean} - True if the object has a deprecated/legacy `dismissButtonText` property, false otherwise\n */\nconst hasDismissButtonText = (obj) => {\n if ('dismissButtonText' in obj && !!obj.dismissButtonText) {\n return true;\n }\n return false;\n};\n\nexport default withDeprecatedProps(ProductTour, 'ProductTour', {\n tours: {\n deprType: DeprTypes.FORMAT,\n message: \"The dismissButtonText options in the 'tours' prop have been moved to 'dismissAltText'.\",\n /**\n * Determines whether the given prop value contains the deprecated/legacy `dismissButtonText` property.\n * @param {Object[]} propValue - The tours prop value to check\n * @returns {boolean} True if the prop value contains the deprecated/legacy `dismissButtonText`\n * property, false otherwise\n */\n expect: (propValue) => {\n if (!Array.isArray(propValue)) {\n return true;\n }\n return !propValue.some((tour) => {\n if (hasDismissButtonText(tour)) {\n return true;\n }\n return Array.isArray(tour.checkpoints)\n && tour.checkpoints.some(hasDismissButtonText);\n });\n },\n /**\n * Transforms the given prop value by updating the\n * deprecated/legacy `dismissButtonText` property to\n * `dismissAltText`, if the prop value is a string. Otherwise,\n * the original `dismissButtonText` property is ignored.\n * @param {Object[]} propValue - The tours prop value to transform\n * @returns {Object[]} The transformed prop value\n */\n transform: (propValue) => {\n const tours = propValue.map((tour) => {\n const updatedTour = { ...tour };\n\n // Replace tour level dismissButtonText with dismissAltText\n if (hasDismissButtonText(tour)) {\n if (typeof tour.dismissButtonText === 'string') {\n updatedTour.dismissAltText = tour.dismissButtonText;\n } else {\n const warningMessage = \"[Deprecated] ProductTour: The 'dismissButtonText' options within the 'tours' prop now expects a string\";\n // eslint-disable-next-line no-console\n console.warn(warningMessage);\n }\n }\n\n // Replace checkpoint level dismissButtonText with dismissAltText\n if (Array.isArray(tour.checkpoints)) {\n updatedTour.checkpoints = tour.checkpoints.map((checkpoint) => {\n if (hasDismissButtonText(checkpoint)) {\n const { dismissButtonText, ...rest } = checkpoint;\n if (typeof dismissButtonText === 'string') {\n return { ...rest, dismissAltText: dismissButtonText };\n }\n }\n return checkpoint;\n });\n }\n return updatedTour;\n });\n\n // Return the transformed tours\n return tours;\n },\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,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C,EAAE;UACnC0E,WAAW,CAAC1E,WAAW,GAAGF,IAAI,CAACE,WAAW,CAACyE,GAAG,CAAEzC,UAAU,IAAK;YAC7D,IAAI6B,oBAAoB,CAAC7B,UAAU,CAAC,EAAE;cACpC,MAAM;gBAAE+B,iBAAiB;gBAAE,GAAGe;cAAK,CAAC,GAAG9C,UAAU;cACjD,IAAI,OAAO+B,iBAAiB,KAAK,QAAQ,EAAE;gBACzC,OAAO;kBAAE,GAAGe,IAAI;kBAAErE,cAAc,EAAEsD;gBAAkB,CAAC;cACvD;YACF;YACA,OAAO/B,UAAU;UACnB,CAAC,CAAC;QACJ;QACA,OAAO0C,WAAW;MACpB,CAAC,CAAC;;MAEF;MACA,OAAO/E,KAAK;IACd;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useEffect","useState","PropTypes","withDeprecatedProps","DeprTypes","Checkpoint","ProductTour","forwardRef","_ref","ref","tours","tourValue","find","tour","enabled","checkpoints","startingIndex","onEscape","onEnd","onAdvance","tourOnAdvance","onBack","tourOnBack","onDismiss","tourOnDismiss","advanceButtonText","tourAdvanceButtonText","dismissAltText","tourDismissAltText","endButtonText","tourEndButtonText","backButtonText","tourBackButtonText","currentCheckpointData","setCurrentCheckpointData","index","setIndex","isTourEnabled","setIsTourEnabled","prunedCheckpoints","setPrunedCheckpoints","title","body","placement","target","pruneCheckpoints","checkpointList","checkpointsWithRenderedTargets","filter","checkpoint","document","querySelector","length","handleEsc","event","key","global","addEventListener","removeEventListener","handleAdvance","handleBack","handleDismiss","handleEnd","checkpointIndex","createElement","totalCheckpoints","defaultProps","propTypes","arrayOf","shape","node","string","func","oneOf","isRequired","bool","number","tourId","hasDismissButtonText","obj","dismissButtonText","deprType","FORMAT","message","expect","propValue","Array","isArray","some","transform","map","updatedTour","warningMessage","console","warn","rest"],"sources":["../../src/ProductTour/index.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';\n\nimport Checkpoint from './Checkpoint';\n\nconst ProductTour = React.forwardRef(({ tours }, ref) => {\n const tourValue = tours.find((tour) => tour.enabled);\n const {\n enabled,\n checkpoints = [],\n startingIndex,\n onEscape,\n onEnd,\n onAdvance: tourOnAdvance,\n onBack: tourOnBack,\n onDismiss: tourOnDismiss,\n advanceButtonText: tourAdvanceButtonText,\n dismissAltText: tourDismissAltText,\n endButtonText: tourEndButtonText,\n backButtonText: tourBackButtonText,\n } = tourValue || {};\n const [currentCheckpointData, setCurrentCheckpointData] = useState(null);\n const [index, setIndex] = useState(0);\n const [isTourEnabled, setIsTourEnabled] = useState(false);\n const [prunedCheckpoints, setPrunedCheckpoints] = useState([]);\n const {\n title,\n body,\n onAdvance,\n onBack,\n onDismiss,\n advanceButtonText,\n dismissAltText,\n endButtonText,\n backButtonText,\n placement,\n target,\n } = currentCheckpointData || {};\n\n /**\n * Takes a list of checkpoints and verifies that each target string provided is\n * an element in the DOM.\n */\n const pruneCheckpoints = (checkpointList) => {\n const checkpointsWithRenderedTargets = checkpointList.filter(\n (checkpoint) => !!document.querySelector(checkpoint.target),\n );\n setPrunedCheckpoints(checkpointsWithRenderedTargets);\n };\n\n useEffect(() => {\n if (enabled && checkpoints) {\n setIsTourEnabled(enabled);\n pruneCheckpoints(checkpoints);\n setIndex(startingIndex || 0);\n }\n }, [enabled, checkpoints, startingIndex]);\n\n useEffect(() => {\n if (isTourEnabled && prunedCheckpoints.length) {\n setCurrentCheckpointData(prunedCheckpoints[index]);\n }\n }, [index, isTourEnabled, prunedCheckpoints]);\n\n useEffect(() => {\n const handleEsc = (event) => {\n if (event.key === 'Escape') {\n setIsTourEnabled(false);\n if (onEscape) {\n onEscape();\n }\n }\n };\n global.addEventListener('keydown', handleEsc);\n\n return () => {\n global.removeEventListener('keydown', handleEsc);\n };\n }, [onEscape]);\n\n if (!tourValue || !currentCheckpointData || !isTourEnabled) {\n return null;\n }\n\n const handleAdvance = () => {\n setIndex(index + 1);\n if (onAdvance) {\n onAdvance();\n } else if (tourOnAdvance) {\n tourOnAdvance();\n }\n };\n\n const handleBack = () => {\n setIndex(index - 1);\n if (onBack) {\n onBack();\n } else if (tourOnBack) {\n tourOnBack();\n }\n };\n\n const handleDismiss = () => {\n setIndex(0);\n setIsTourEnabled(false);\n if (onDismiss) {\n onDismiss();\n } else if (tourOnDismiss) {\n tourOnDismiss();\n }\n setCurrentCheckpointData(null);\n };\n /* eslint-disable */\n /**\n * Takes the final checkpoint array index value and looks for an existing onEnd callback.\n * \n * If an onEnd callback exist on checkpointIndex value and it is the final checkpoint \n * in the array, the onEnd callback will be called for the parent, and individual onEnd object. \n * \n * @param {Integer} checkpointIndex \n */\n /* eslint-enable */\n const handleEnd = (checkpointIndex) => {\n setIndex(0);\n setIsTourEnabled(false);\n if (prunedCheckpoints[checkpointIndex].onEnd) {\n prunedCheckpoints[checkpointIndex].onEnd();\n } else if (onEnd) {\n onEnd(prunedCheckpoints[checkpointIndex]);\n }\n setCurrentCheckpointData(null);\n };\n return (\n <Checkpoint\n advanceButtonText={advanceButtonText || tourAdvanceButtonText}\n body={body}\n currentCheckpointData={currentCheckpointData}\n dismissAltText={dismissAltText || tourDismissAltText}\n endButtonText={endButtonText || tourEndButtonText}\n backButtonText={backButtonText || tourBackButtonText}\n index={index}\n onBack={handleBack}\n onAdvance={handleAdvance}\n onDismiss={handleDismiss}\n onEnd={handleEnd}\n placement={placement}\n target={target}\n title={title}\n totalCheckpoints={prunedCheckpoints.length}\n ref={ref}\n />\n );\n});\n\nProductTour.defaultProps = {\n tours: {\n advanceButtonText: '',\n backButtonText: '',\n checkpoints: {\n advanceButtonText: '',\n backButtonText: '',\n body: '',\n dismissAltText: '',\n endButtonText: '',\n onAdvance: () => {},\n onDismiss: () => {},\n onBack: () => {},\n placement: 'top',\n title: '',\n },\n dismissAltText: '',\n endButtonText: '',\n onBack: () => {},\n onDismiss: () => {},\n onEnd: () => {},\n onEscape: () => {},\n startingIndex: 0,\n },\n};\n\nProductTour.propTypes = {\n tours: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on all buttons used to advance the tour. */\n advanceButtonText: PropTypes.node,\n /** The text displayed on all buttons used to go back in the tour */\n backButtonText: PropTypes.string,\n /** An array comprised of checkpoint objects supporting the following values: */\n checkpoints: PropTypes.arrayOf(PropTypes.shape({\n /** The text displayed on the button used to advance the tour for the given Checkpoint\n * (overrides the* `advanceButtonText` defined in the parent tour object). */\n advanceButtonText: PropTypes.node,\n /** The text displayed on the button used to go back in the tour for the given Checkpoint\n * (overrides the* `backButtonText` defined in the parent tour object). */\n backButtonText: PropTypes.string,\n /** The text displayed in the body of the Checkpoint */\n body: PropTypes.node,\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** The text displayed on the button used to end the tour for the given Checkpoint\n * (overrides the `endButtonText` defined in the parent tour object). */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onClick` event of the advance\n * button for the given Checkpoint. */\n onAdvance: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint (overrides the `onDismiss` function defined in the parent tour object). */\n onDismiss: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the advance\n * button if the given Checkpoint is the only or last Checkpoint in a tour. */\n onEnd: PropTypes.func,\n /** A string that dictates the alignment of the Checkpoint around its target. */\n placement: PropTypes.oneOf([\n 'top', 'top-start', 'top-end', 'right-start', 'right', 'right-end',\n 'left-start', 'left', 'left-end', 'bottom', 'bottom-start', 'bottom-end',\n ]),\n /** The CSS selector for the Checkpoint's desired target. */\n target: PropTypes.string.isRequired,\n /** The text displayed in the title of the Checkpoint */\n title: PropTypes.node,\n })),\n /** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */\n dismissAltText: PropTypes.string,\n /** Whether the tour is enabled. If there are multiple tours defined, only one should be enabled at a time. */\n enabled: PropTypes.bool.isRequired,\n /** The text displayed on the button used to end the tour. */\n endButtonText: PropTypes.node,\n /** A function that runs when triggering the `onBack` event of the back button. */\n onBack: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the dismiss button. */\n onDismiss: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the end button. */\n onEnd: PropTypes.func,\n /** A function that runs when pressing the Escape key. */\n onEscape: PropTypes.func,\n /** The index of the desired `Checkpoint` to render when the tour starts. */\n startingIndex: PropTypes.number,\n /** The ID of the tour */\n tourId: PropTypes.string.isRequired,\n })),\n};\n\n/**\n * Checks if the given object has a deprecated/legacy `dismissButtonText` property.\n * @param {Object} obj - The object to check\n * @returns {boolean} - True if the object has a deprecated/legacy `dismissButtonText` property, false otherwise\n */\nconst hasDismissButtonText = (obj) => {\n if ('dismissButtonText' in obj && !!obj.dismissButtonText) {\n return true;\n }\n return false;\n};\n\nexport default withDeprecatedProps(ProductTour, 'ProductTour', {\n tours: {\n deprType: DeprTypes.FORMAT,\n message: \"The dismissButtonText options in the 'tours' prop have been moved to 'dismissAltText'.\",\n /**\n * Determines whether the given prop value contains the deprecated/legacy `dismissButtonText` property.\n * @param {Object[]} propValue - The tours prop value to check\n * @returns {boolean} True if the prop value contains the deprecated/legacy `dismissButtonText`\n * property, false otherwise\n */\n expect: (propValue) => {\n if (!Array.isArray(propValue)) {\n return true;\n }\n return !propValue.some((tour) => {\n if (hasDismissButtonText(tour)) {\n return true;\n }\n return Array.isArray(tour.checkpoints)\n && tour.checkpoints.some(hasDismissButtonText);\n });\n },\n /**\n * Transforms the given prop value by updating the\n * deprecated/legacy `dismissButtonText` property to\n * `dismissAltText`, if the prop value is a string. Otherwise,\n * the original `dismissButtonText` property is ignored.\n * @param {Object[]} propValue - The tours prop value to transform\n * @returns {Object[]} The transformed prop value\n */\n transform: (propValue) => {\n const tours = propValue.map((tour) => {\n const updatedTour = { ...tour };\n\n // Replace tour level dismissButtonText with dismissAltText\n if (hasDismissButtonText(tour)) {\n if (typeof tour.dismissButtonText === 'string') {\n updatedTour.dismissAltText = tour.dismissButtonText;\n } else {\n const warningMessage = \"[Deprecated] ProductTour: The 'dismissButtonText' options within the 'tours' prop now expects a string\";\n // eslint-disable-next-line no-console\n console.warn(warningMessage);\n }\n }\n\n // Replace checkpoint level dismissButtonText with dismissAltText\n if (Array.isArray(tour.checkpoints)) {\n updatedTour.checkpoints = tour.checkpoints.map((checkpoint) => {\n if (hasDismissButtonText(checkpoint)) {\n const { dismissButtonText, ...rest } = checkpoint;\n if (typeof dismissButtonText === 'string') {\n return { ...rest, dismissAltText: dismissButtonText };\n }\n }\n return checkpoint;\n });\n }\n return updatedTour;\n });\n\n // Return the transformed tours\n return tours;\n },\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,mBAAmB,IAAIC,SAAS,QAAQ,wBAAwB;AAEvE,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAMC,WAAW,gBAAGP,KAAK,CAACQ,UAAU,CAAC,CAAAC,IAAA,EAAYC,GAAG,KAAK;EAAA,IAAnB;IAAEC;EAAM,CAAC,GAAAF,IAAA;EAC7C,MAAMG,SAAS,GAAGD,KAAK,CAACE,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,OAAO,CAAC;EACpD,MAAM;IACJA,OAAO;IACPC,WAAW,GAAG,EAAE;IAChBC,aAAa;IACbC,QAAQ;IACRC,KAAK;IACLC,SAAS,EAAEC,aAAa;IACxBC,MAAM,EAAEC,UAAU;IAClBC,SAAS,EAAEC,aAAa;IACxBC,iBAAiB,EAAEC,qBAAqB;IACxCC,cAAc,EAAEC,kBAAkB;IAClCC,aAAa,EAAEC,iBAAiB;IAChCC,cAAc,EAAEC;EAClB,CAAC,GAAGrB,SAAS,IAAI,CAAC,CAAC;EACnB,MAAM,CAACsB,qBAAqB,EAAEC,wBAAwB,CAAC,GAAGjC,QAAQ,CAAC,IAAI,CAAC;EACxE,MA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urls.json
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"themeUrls": {
|
|
3
|
+
"core": {
|
|
4
|
+
"paths": {
|
|
5
|
+
"default": "./core.css",
|
|
6
|
+
"minified": "./core.min.css"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
3
9
|
"defaults": {
|
|
4
10
|
"light": "light"
|
|
5
11
|
},
|
|
@@ -10,12 +16,6 @@
|
|
|
10
16
|
"minified": "./light.min.css"
|
|
11
17
|
}
|
|
12
18
|
}
|
|
13
|
-
},
|
|
14
|
-
"core": {
|
|
15
|
-
"paths": {
|
|
16
|
-
"default": "./core.css",
|
|
17
|
-
"minified": "./core.min.css"
|
|
18
|
-
}
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/Alert/Alert.test.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IntlProvider } from 'react-intl';
|
|
3
3
|
import renderer, { act } from 'react-test-renderer';
|
|
4
|
-
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { render, screen, within } from '@testing-library/react';
|
|
5
5
|
import userEvent from '@testing-library/user-event';
|
|
6
6
|
import { Context as ResponsiveContext } from 'react-responsive';
|
|
7
7
|
import { Info } from '../../icons';
|
|
@@ -112,4 +112,17 @@ describe('<Alert />', () => {
|
|
|
112
112
|
});
|
|
113
113
|
expect(tree).toMatchSnapshot();
|
|
114
114
|
});
|
|
115
|
+
it('renders with headings and links', async () => {
|
|
116
|
+
render(
|
|
117
|
+
<AlertWrapper>
|
|
118
|
+
<Alert.Heading>This is the heading</Alert.Heading>
|
|
119
|
+
And <Alert.Link href="#">here is a link</Alert.Link>.
|
|
120
|
+
</AlertWrapper>,
|
|
121
|
+
);
|
|
122
|
+
const alertDiv = screen.getByRole('alert');
|
|
123
|
+
const heading = within(alertDiv).getByText(/This is the heading/);
|
|
124
|
+
expect(heading).toHaveClass('alert-heading', 'h4');
|
|
125
|
+
const link = within(alertDiv).getByRole('link', { name: 'here is a link' });
|
|
126
|
+
expect(link).toHaveClass('alert-link');
|
|
127
|
+
});
|
|
115
128
|
});
|
package/src/Alert/index.tsx
CHANGED
|
@@ -11,12 +11,12 @@ import React, {
|
|
|
11
11
|
RefAttributes,
|
|
12
12
|
cloneElement,
|
|
13
13
|
} from 'react';
|
|
14
|
-
import PropTypes from 'prop-types';
|
|
15
14
|
import classNames from 'classnames';
|
|
16
15
|
import {
|
|
17
16
|
Alert as BaseAlert,
|
|
18
17
|
AlertProps as BaseAlertProps,
|
|
19
18
|
} from 'react-bootstrap';
|
|
19
|
+
import { type TransitionComponent } from 'react-bootstrap/helpers';
|
|
20
20
|
import divWithClassName from 'react-bootstrap/divWithClassName';
|
|
21
21
|
import { FormattedMessage } from 'react-intl';
|
|
22
22
|
import { useMediaQuery } from 'react-responsive';
|
|
@@ -33,29 +33,51 @@ export type AlertVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'war
|
|
|
33
33
|
export type BaseProps = Omit<BaseAlertProps, 'children' | 'variant' | 'closeLabel'>;
|
|
34
34
|
|
|
35
35
|
export interface AlertProps extends BaseProps {
|
|
36
|
+
/** Specifies class name to append to the base element */
|
|
36
37
|
className?: string;
|
|
38
|
+
/** Overrides underlying component base CSS class name */
|
|
37
39
|
bsPrefix?: string;
|
|
40
|
+
/** Specifies variant to use. */
|
|
38
41
|
variant?: AlertVariant;
|
|
42
|
+
/**
|
|
43
|
+
* Animate the entering and exiting of the Alert. `true` will use the `<Fade>` transition,
|
|
44
|
+
* more detailed customization is also provided.
|
|
45
|
+
*/
|
|
46
|
+
transition?: boolean | TransitionComponent;
|
|
39
47
|
children?: ReactNode;
|
|
48
|
+
/** Icon that will be shown in the alert */
|
|
40
49
|
icon?: React.ComponentType<IconProps>;
|
|
50
|
+
/** Whether the alert is shown. */
|
|
41
51
|
show?: boolean;
|
|
52
|
+
/** Whether the alert is dismissible. Defaults to false. */
|
|
42
53
|
dismissible?: boolean;
|
|
54
|
+
/** Optional callback function for when the alert it dismissed. */
|
|
43
55
|
onClose?: () => void;
|
|
56
|
+
/** Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true. */
|
|
44
57
|
actions?: React.ReactElement[];
|
|
58
|
+
/** Position of the dismiss and call-to-action buttons. Defaults to `false`. */
|
|
45
59
|
stacked?: boolean;
|
|
60
|
+
/** Sets the text for alert close button, defaults to 'Dismiss'. */
|
|
46
61
|
closeLabel?: string | ReactNode;
|
|
47
62
|
}
|
|
48
63
|
|
|
49
64
|
export interface AlertHeadingProps {
|
|
65
|
+
/** Specifies the base element */
|
|
50
66
|
as?: ElementType;
|
|
67
|
+
/** Overrides underlying component base CSS class name */
|
|
51
68
|
bsPrefix?: string;
|
|
69
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
52
70
|
children?: ReactNode;
|
|
53
71
|
}
|
|
54
72
|
|
|
55
73
|
export interface AlertLinkProps {
|
|
74
|
+
/** Specifies the base element */
|
|
56
75
|
as?: ElementType;
|
|
76
|
+
/** Overrides underlying component base CSS class name */
|
|
57
77
|
bsPrefix?: string;
|
|
78
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
58
79
|
children?: ReactNode;
|
|
80
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
59
81
|
href?: string;
|
|
60
82
|
}
|
|
61
83
|
|
|
@@ -64,16 +86,17 @@ export interface AlertComponent extends ForwardRefExoticComponent<AlertProps & R
|
|
|
64
86
|
Link: FC<AlertLinkProps>;
|
|
65
87
|
}
|
|
66
88
|
|
|
67
|
-
const Alert = forwardRef
|
|
89
|
+
const Alert = forwardRef(({
|
|
68
90
|
children,
|
|
69
91
|
icon,
|
|
70
92
|
actions,
|
|
71
|
-
dismissible,
|
|
72
|
-
onClose,
|
|
93
|
+
dismissible = false,
|
|
94
|
+
onClose = () => {},
|
|
73
95
|
closeLabel,
|
|
74
|
-
stacked,
|
|
96
|
+
stacked = false,
|
|
97
|
+
show = true,
|
|
75
98
|
...props
|
|
76
|
-
}, ref) => {
|
|
99
|
+
}: AlertProps, ref: React.ForwardedRef<HTMLDivElement>) => {
|
|
77
100
|
const [isStacked, setIsStacked] = useState(stacked);
|
|
78
101
|
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });
|
|
79
102
|
const actionButtonSize = 'sm';
|
|
@@ -98,6 +121,7 @@ const Alert = forwardRef<HTMLDivElement, AlertProps>(({
|
|
|
98
121
|
<BaseAlert
|
|
99
122
|
{...props}
|
|
100
123
|
className={classNames('alert-content', props.className)}
|
|
124
|
+
show={show}
|
|
101
125
|
ref={ref}
|
|
102
126
|
>
|
|
103
127
|
{icon && <Icon src={icon} className="alert-icon" />}
|
|
@@ -142,97 +166,22 @@ const Alert = forwardRef<HTMLDivElement, AlertProps>(({
|
|
|
142
166
|
const DivStyledAsH4 = divWithClassName('h4');
|
|
143
167
|
DivStyledAsH4.displayName = 'DivStyledAsH4';
|
|
144
168
|
|
|
145
|
-
function AlertHeading(
|
|
146
|
-
|
|
169
|
+
function AlertHeading({
|
|
170
|
+
as = DivStyledAsH4,
|
|
171
|
+
bsPrefix = 'alert-heading',
|
|
172
|
+
...props
|
|
173
|
+
}: AlertHeadingProps): JSX.Element {
|
|
174
|
+
return <BaseAlert.Heading {...{ as, bsPrefix, ...props }} />;
|
|
147
175
|
}
|
|
148
176
|
|
|
149
|
-
function AlertLink(
|
|
150
|
-
|
|
177
|
+
function AlertLink({
|
|
178
|
+
as = 'a',
|
|
179
|
+
bsPrefix = 'alert-link',
|
|
180
|
+
...props
|
|
181
|
+
}: AlertLinkProps): JSX.Element {
|
|
182
|
+
return <BaseAlert.Link {...{ as, bsPrefix, ...props }} />;
|
|
151
183
|
}
|
|
152
184
|
|
|
153
|
-
AlertLink.propTypes = {
|
|
154
|
-
/** Specifies the base element */
|
|
155
|
-
as: PropTypes.elementType as PropTypes.Validator<ElementType>,
|
|
156
|
-
/** Overrides underlying component base CSS class name */
|
|
157
|
-
bsPrefix: PropTypes.string,
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
AlertHeading.propTypes = {
|
|
161
|
-
/** Specifies the base element */
|
|
162
|
-
as: PropTypes.elementType as PropTypes.Validator<ElementType>,
|
|
163
|
-
/** Overrides underlying component base CSS class name */
|
|
164
|
-
bsPrefix: PropTypes.string,
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
AlertLink.defaultProps = {
|
|
168
|
-
as: 'a' as ElementType,
|
|
169
|
-
bsPrefix: 'alert-link',
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
AlertHeading.defaultProps = {
|
|
173
|
-
as: DivStyledAsH4,
|
|
174
|
-
bsPrefix: 'alert-heading',
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
Alert.propTypes = {
|
|
178
|
-
...BaseAlert.propTypes,
|
|
179
|
-
/** Specifies class name to append to the base element */
|
|
180
|
-
className: PropTypes.string,
|
|
181
|
-
/** Overrides underlying component base CSS class name */
|
|
182
|
-
bsPrefix: PropTypes.string,
|
|
183
|
-
/** Specifies variant to use. */
|
|
184
|
-
variant: PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'] as AlertVariant[]),
|
|
185
|
-
/**
|
|
186
|
-
* Animate the entering and exiting of the Alert. `true` will use the `<Fade>` transition,
|
|
187
|
-
* more detailed customization is also provided.
|
|
188
|
-
*/
|
|
189
|
-
transition: PropTypes.oneOfType([
|
|
190
|
-
PropTypes.bool,
|
|
191
|
-
PropTypes.shape({
|
|
192
|
-
in: PropTypes.bool,
|
|
193
|
-
appear: PropTypes.bool,
|
|
194
|
-
children: PropTypes.node,
|
|
195
|
-
onEnter: PropTypes.func,
|
|
196
|
-
onEntered: PropTypes.func,
|
|
197
|
-
onEntering: PropTypes.func,
|
|
198
|
-
onExit: PropTypes.func,
|
|
199
|
-
onExited: PropTypes.func,
|
|
200
|
-
onExiting: PropTypes.func,
|
|
201
|
-
}),
|
|
202
|
-
]) as PropTypes.Validator<BaseAlertProps['transition']>,
|
|
203
|
-
/** Docstring for the children prop */
|
|
204
|
-
children: PropTypes.node as PropTypes.Validator<ReactNode>,
|
|
205
|
-
/** Docstring for the icon prop... Icon that will be shown in the alert */
|
|
206
|
-
icon: PropTypes.func,
|
|
207
|
-
/** Whether the alert is shown. */
|
|
208
|
-
show: PropTypes.bool,
|
|
209
|
-
/** Whether the alert is dismissible. Defaults to true. */
|
|
210
|
-
dismissible: PropTypes.bool,
|
|
211
|
-
/** Optional callback function for when the alert it dismissed. */
|
|
212
|
-
onClose: PropTypes.func,
|
|
213
|
-
/** Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true. */
|
|
214
|
-
actions: PropTypes.arrayOf(PropTypes.element) as PropTypes.Validator<React.ReactElement[]>,
|
|
215
|
-
/** Position of the dismiss and call-to-action buttons. Defaults to ``false``. */
|
|
216
|
-
stacked: PropTypes.bool,
|
|
217
|
-
/** Sets the text for alert close button, defaults to 'Dismiss'. */
|
|
218
|
-
closeLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
Alert.defaultProps = {
|
|
222
|
-
...BaseAlert.defaultProps,
|
|
223
|
-
children: undefined,
|
|
224
|
-
icon: undefined,
|
|
225
|
-
actions: undefined,
|
|
226
|
-
dismissible: false,
|
|
227
|
-
onClose: () => {},
|
|
228
|
-
closeLabel: undefined,
|
|
229
|
-
show: true,
|
|
230
|
-
stacked: false,
|
|
231
|
-
className: undefined,
|
|
232
|
-
bsPrefix: undefined,
|
|
233
|
-
variant: undefined,
|
|
234
|
-
};
|
|
235
|
-
|
|
236
185
|
Alert.Heading = AlertHeading;
|
|
237
186
|
Alert.Link = AlertLink;
|
|
238
187
|
|
|
@@ -19,6 +19,8 @@ describe('<ProductTour />', () => {
|
|
|
19
19
|
<div id="target-4">...</div>
|
|
20
20
|
</>
|
|
21
21
|
);
|
|
22
|
+
const handleAdvance = jest.fn();
|
|
23
|
+
const handleBack = jest.fn();
|
|
22
24
|
const handleDismiss = jest.fn();
|
|
23
25
|
const handleEnd = jest.fn();
|
|
24
26
|
const handleEscape = jest.fn();
|
|
@@ -31,6 +33,8 @@ describe('<ProductTour />', () => {
|
|
|
31
33
|
advanceButtonText: 'Next',
|
|
32
34
|
enabled: false,
|
|
33
35
|
endButtonText: 'Okay',
|
|
36
|
+
onAdvance: handleAdvance,
|
|
37
|
+
onBack: handleBack,
|
|
34
38
|
onDismiss: handleDismiss,
|
|
35
39
|
onEnd: handleEnd,
|
|
36
40
|
tourId: 'disabledTour',
|
|
@@ -48,6 +52,8 @@ describe('<ProductTour />', () => {
|
|
|
48
52
|
backButtonText: 'Back',
|
|
49
53
|
enabled: true,
|
|
50
54
|
endButtonText: 'Okay',
|
|
55
|
+
onAdvance: handleAdvance,
|
|
56
|
+
onBack: handleBack,
|
|
51
57
|
onDismiss: handleDismiss,
|
|
52
58
|
onEnd: handleEnd,
|
|
53
59
|
tourId: 'enabledTour',
|
|
@@ -60,6 +66,7 @@ describe('<ProductTour />', () => {
|
|
|
60
66
|
{
|
|
61
67
|
body: 'Checkpoint 2',
|
|
62
68
|
target: '#target-2',
|
|
69
|
+
onAdvance: customOnAdvance,
|
|
63
70
|
},
|
|
64
71
|
{
|
|
65
72
|
body: 'Checkpoint 3',
|
|
@@ -82,6 +89,7 @@ describe('<ProductTour />', () => {
|
|
|
82
89
|
|
|
83
90
|
afterEach(() => {
|
|
84
91
|
popperMock.mockReset();
|
|
92
|
+
jest.resetAllMocks();
|
|
85
93
|
});
|
|
86
94
|
|
|
87
95
|
// eslint-disable-next-line react/prop-types
|
|
@@ -115,6 +123,38 @@ describe('<ProductTour />', () => {
|
|
|
115
123
|
|
|
116
124
|
// Verify the second Checkpoint has rendered
|
|
117
125
|
expect(screen.getByText('Checkpoint 2')).toBeInTheDocument();
|
|
126
|
+
expect(handleAdvance).toHaveBeenCalled();
|
|
127
|
+
|
|
128
|
+
await userEvent.click(advanceButton);
|
|
129
|
+
expect(screen.getByText('Checkpoint 3')).toBeInTheDocument();
|
|
130
|
+
expect(customOnAdvance).toHaveBeenCalled();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('onClick of back button rewinds to last checkpoint', async () => {
|
|
134
|
+
render(<ProductTourWrapper tours={[tourData]} />);
|
|
135
|
+
// Verify the first Checkpoint has rendered
|
|
136
|
+
expect(screen.getByRole('heading', { name: 'Checkpoint 1' })).toBeInTheDocument();
|
|
137
|
+
|
|
138
|
+
// Click the advance button
|
|
139
|
+
const advanceButton = screen.getByRole('button', { name: 'Next' });
|
|
140
|
+
await userEvent.click(advanceButton);
|
|
141
|
+
|
|
142
|
+
// go forward to the 3rd checkpoint
|
|
143
|
+
expect(screen.getByText('Checkpoint 2')).toBeInTheDocument();
|
|
144
|
+
await userEvent.click(advanceButton);
|
|
145
|
+
expect(screen.getByText('Checkpoint 3')).toBeInTheDocument();
|
|
146
|
+
|
|
147
|
+
// First back button should use custom on back function
|
|
148
|
+
let backButton = screen.getByRole('button', { name: 'Override back' });
|
|
149
|
+
await userEvent.click(backButton);
|
|
150
|
+
expect(screen.getByText('Checkpoint 2')).toBeInTheDocument();
|
|
151
|
+
expect(customOnBack).toHaveBeenCalled();
|
|
152
|
+
|
|
153
|
+
// Second back button should use the tour's default back function
|
|
154
|
+
backButton = screen.getByRole('button', { name: 'Back' });
|
|
155
|
+
await userEvent.click(backButton);
|
|
156
|
+
expect(screen.getByText('Checkpoint 1')).toBeInTheDocument();
|
|
157
|
+
expect(handleBack).toHaveBeenCalled();
|
|
118
158
|
});
|
|
119
159
|
|
|
120
160
|
it('onClick of dismiss button disables tour', async () => {
|
|
@@ -284,7 +324,6 @@ describe('<ProductTour />', () => {
|
|
|
284
324
|
expect(screen.getByText('Checkpoint 4')).toBeInTheDocument();
|
|
285
325
|
const endButton = screen.getByRole('button', { name: 'Override end' });
|
|
286
326
|
await user.click(endButton);
|
|
287
|
-
expect(handleEnd).toBeCalledTimes(1);
|
|
288
327
|
expect(customOnEnd).toHaveBeenCalledTimes(1);
|
|
289
328
|
expect(screen.queryByText('Checkpoint 4')).not.toBeInTheDocument();
|
|
290
329
|
});
|
|
@@ -12,7 +12,8 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
|
|
|
12
12
|
startingIndex,
|
|
13
13
|
onEscape,
|
|
14
14
|
onEnd,
|
|
15
|
-
|
|
15
|
+
onAdvance: tourOnAdvance,
|
|
16
|
+
onBack: tourOnBack,
|
|
16
17
|
onDismiss: tourOnDismiss,
|
|
17
18
|
advanceButtonText: tourAdvanceButtonText,
|
|
18
19
|
dismissAltText: tourDismissAltText,
|
|
@@ -27,6 +28,7 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
|
|
|
27
28
|
title,
|
|
28
29
|
body,
|
|
29
30
|
onAdvance,
|
|
31
|
+
onBack,
|
|
30
32
|
onDismiss,
|
|
31
33
|
advanceButtonText,
|
|
32
34
|
dismissAltText,
|
|
@@ -85,6 +87,8 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
|
|
|
85
87
|
setIndex(index + 1);
|
|
86
88
|
if (onAdvance) {
|
|
87
89
|
onAdvance();
|
|
90
|
+
} else if (tourOnAdvance) {
|
|
91
|
+
tourOnAdvance();
|
|
88
92
|
}
|
|
89
93
|
};
|
|
90
94
|
|
|
@@ -92,6 +96,8 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
|
|
|
92
96
|
setIndex(index - 1);
|
|
93
97
|
if (onBack) {
|
|
94
98
|
onBack();
|
|
99
|
+
} else if (tourOnBack) {
|
|
100
|
+
tourOnBack();
|
|
95
101
|
}
|
|
96
102
|
};
|
|
97
103
|
|
|
@@ -100,7 +106,7 @@ const ProductTour = React.forwardRef(({ tours }, ref) => {
|
|
|
100
106
|
setIsTourEnabled(false);
|
|
101
107
|
if (onDismiss) {
|
|
102
108
|
onDismiss();
|
|
103
|
-
} else {
|
|
109
|
+
} else if (tourOnDismiss) {
|
|
104
110
|
tourOnDismiss();
|
|
105
111
|
}
|
|
106
112
|
setCurrentCheckpointData(null);
|