@openedx/paragon 23.6.1 → 23.7.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/Alert/index.scss +5 -0
- package/dist/ProductTour/Checkpoint.js +23 -16
- package/dist/ProductTour/Checkpoint.js.map +1 -1
- package/dist/ProductTour/Checkpoint.scss +8 -36
- package/dist/ProductTour/CheckpointActionRow.js +17 -21
- package/dist/ProductTour/CheckpointActionRow.js.map +1 -1
- package/dist/ProductTour/CheckpointHeader.js +57 -0
- package/dist/ProductTour/CheckpointHeader.js.map +1 -0
- package/dist/ProductTour/index.js +120 -20
- package/dist/ProductTour/index.js.map +1 -1
- package/dist/ProductTour/messages.js +10 -0
- package/dist/core.css +11 -29
- package/dist/core.css.map +1 -1
- package/dist/core.min.css +1 -1
- package/dist/withDeprecatedProps.js +11 -3
- package/dist/withDeprecatedProps.js.map +1 -1
- package/lib/build-scss.js +1 -1
- package/package.json +1 -1
- package/src/Alert/index.scss +5 -0
- package/src/ProductTour/Checkpoint.jsx +22 -16
- package/src/ProductTour/Checkpoint.scss +8 -36
- package/src/ProductTour/Checkpoint.test.jsx +20 -53
- package/src/ProductTour/CheckpointActionRow.jsx +32 -32
- package/src/ProductTour/CheckpointHeader.jsx +60 -0
- package/src/ProductTour/ProductTour.test.jsx +69 -60
- package/src/ProductTour/README.md +11 -3
- package/src/ProductTour/index.jsx +125 -17
- package/src/ProductTour/messages.js +10 -0
- package/src/withDeprecatedProps.tsx +10 -3
- package/dist/ProductTour/CheckpointBreadcrumbs.js +0 -37
- package/dist/ProductTour/CheckpointBreadcrumbs.js.map +0 -1
- package/dist/TransitionReplace/DemoTransitionReplace.js +0 -32
- package/dist/TransitionReplace/DemoTransitionReplace.js.map +0 -1
- package/src/ProductTour/CheckpointBreadcrumbs.jsx +0 -45
- package/src/TransitionReplace/DemoTransitionReplace.jsx +0 -57
package/dist/Alert/index.scss
CHANGED
|
@@ -15,10 +15,15 @@
|
|
|
15
15
|
border: var(--pgn-size-alert-border-width) solid var(--pgn-alert-border-color, transparent);
|
|
16
16
|
color: inherit;
|
|
17
17
|
background-color: var(--pgn-alert-bg, transparent);
|
|
18
|
+
align-items: center;
|
|
18
19
|
|
|
19
20
|
@include border-radius(var(--pgn-size-alert-border-radius));
|
|
20
21
|
@include pgn-box-shadow(1, "down");
|
|
21
22
|
|
|
23
|
+
&:has(.alert-heading:not(:only-child)) {
|
|
24
|
+
align-items: start;
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
.alert-message-content > :last-child {
|
|
23
28
|
margin-bottom: 0;
|
|
24
29
|
}
|
|
@@ -6,13 +6,15 @@ import { FormattedMessage } from 'react-intl';
|
|
|
6
6
|
import breakpoints from '../utils/breakpoints';
|
|
7
7
|
import CheckpointActionRow from './CheckpointActionRow';
|
|
8
8
|
import CheckpointBody from './CheckpointBody';
|
|
9
|
-
import
|
|
10
|
-
import CheckpointTitle from './CheckpointTitle';
|
|
9
|
+
import CheckpointHeader from './CheckpointHeader';
|
|
11
10
|
import messages from './messages';
|
|
12
11
|
const Checkpoint = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
13
12
|
let {
|
|
14
13
|
body,
|
|
14
|
+
dismissAltText,
|
|
15
15
|
index,
|
|
16
|
+
onBack,
|
|
17
|
+
onDismiss,
|
|
16
18
|
placement,
|
|
17
19
|
target,
|
|
18
20
|
title,
|
|
@@ -79,7 +81,6 @@ const Checkpoint = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
79
81
|
}
|
|
80
82
|
}, [target, checkpointVisible, placement]);
|
|
81
83
|
const isLastCheckpoint = index + 1 === totalCheckpoints;
|
|
82
|
-
const isOnlyCheckpoint = totalCheckpoints === 1;
|
|
83
84
|
return /*#__PURE__*/React.createElement("div", {
|
|
84
85
|
id: "pgn__checkpoint",
|
|
85
86
|
className: "pgn__checkpoint",
|
|
@@ -97,12 +98,15 @@ const Checkpoint = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
97
98
|
values: {
|
|
98
99
|
step: index + 1
|
|
99
100
|
}
|
|
100
|
-
})),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
})), /*#__PURE__*/React.createElement(CheckpointHeader, {
|
|
102
|
+
dismissAltText: dismissAltText,
|
|
103
|
+
index: index,
|
|
104
|
+
onDismiss: onDismiss,
|
|
105
|
+
title: title,
|
|
104
106
|
totalCheckpoints: totalCheckpoints
|
|
105
|
-
})
|
|
107
|
+
}), /*#__PURE__*/React.createElement(CheckpointBody, null, body), /*#__PURE__*/React.createElement(CheckpointActionRow, {
|
|
108
|
+
onBack: onBack,
|
|
109
|
+
onDismiss: onDismiss,
|
|
106
110
|
isLastCheckpoint: isLastCheckpoint,
|
|
107
111
|
index: index,
|
|
108
112
|
...props
|
|
@@ -120,20 +124,22 @@ const Checkpoint = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
120
124
|
});
|
|
121
125
|
Checkpoint.defaultProps = {
|
|
122
126
|
advanceButtonText: null,
|
|
127
|
+
backButtonText: null,
|
|
123
128
|
body: null,
|
|
124
|
-
|
|
129
|
+
dismissAltText: null,
|
|
125
130
|
endButtonText: null,
|
|
126
131
|
placement: 'top',
|
|
127
|
-
title: null
|
|
128
|
-
showDismissButton: undefined
|
|
132
|
+
title: null
|
|
129
133
|
};
|
|
130
134
|
Checkpoint.propTypes = {
|
|
131
135
|
/** The text displayed on the button used to advance the tour for the given Checkpoint. */
|
|
132
136
|
advanceButtonText: PropTypes.node,
|
|
137
|
+
/** The text displayed on the button used go back in the tour for the given Checkpoint. */
|
|
138
|
+
backButtonText: PropTypes.string,
|
|
133
139
|
/** The text displayed in the body of the Checkpoint */
|
|
134
140
|
body: PropTypes.node,
|
|
135
|
-
/** The text
|
|
136
|
-
|
|
141
|
+
/** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */
|
|
142
|
+
dismissAltText: PropTypes.string,
|
|
137
143
|
/** The text displayed on the button used to end the tour for the given Checkpoint. */
|
|
138
144
|
endButtonText: PropTypes.node,
|
|
139
145
|
/** The current index of the given Checkpoint */
|
|
@@ -141,6 +147,9 @@ Checkpoint.propTypes = {
|
|
|
141
147
|
/** A function that runs when triggering the `onClick` event of the advance
|
|
142
148
|
* button for the given Checkpoint. */
|
|
143
149
|
onAdvance: PropTypes.func.isRequired,
|
|
150
|
+
/** A function that runs when triggering the `onBack` event of the back
|
|
151
|
+
* button for the given Checkpoint. */
|
|
152
|
+
onBack: PropTypes.func.isRequired,
|
|
144
153
|
/** A function that runs when triggering the `onClick` event of the dismiss
|
|
145
154
|
* button for the given Checkpoint. */
|
|
146
155
|
onDismiss: PropTypes.func.isRequired,
|
|
@@ -154,9 +163,7 @@ Checkpoint.propTypes = {
|
|
|
154
163
|
/** The text displayed in the title of the Checkpoint */
|
|
155
164
|
title: PropTypes.node,
|
|
156
165
|
/** The total number of Checkpoints in a tour */
|
|
157
|
-
totalCheckpoints: PropTypes.number.isRequired
|
|
158
|
-
/** Enforces visibility of the dismiss button under all circumstances */
|
|
159
|
-
showDismissButton: PropTypes.bool
|
|
166
|
+
totalCheckpoints: PropTypes.number.isRequired
|
|
160
167
|
};
|
|
161
168
|
export default Checkpoint;
|
|
162
169
|
//# sourceMappingURL=Checkpoint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkpoint.js","names":["React","useEffect","useState","useMediaQuery","PropTypes","createPopper","FormattedMessage","breakpoints","CheckpointActionRow","CheckpointBody","CheckpointBreadcrumbs","CheckpointTitle","messages","Checkpoint","forwardRef","_ref","ref","body","index","placement","target","title","totalCheckpoints","props","checkpointVisible","setCheckpointVisible","isMobile","maxWidth","small","targetElement","document","querySelector","checkpoint","checkpointPopper","strategy","modifiers","name","options","padding","offset","tetherOffset","forceUpdate","targetOffset","getBoundingClientRect","top","bottom","global","innerHeight","includes","scrollTo","behavior","button","focus","isLastCheckpoint","isOnlyCheckpoint","createElement","id","className","role","style","visibility","pointerEvents","topPositionText","values","step","currentIndex","bottomPositionText","defaultProps","advanceButtonText","dismissButtonText","endButtonText","showDismissButton","undefined","propTypes","node","number","isRequired","onAdvance","func","onDismiss","onEnd","oneOf","string","bool"],"sources":["../../src/ProductTour/Checkpoint.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { useMediaQuery } from 'react-responsive';\nimport PropTypes from 'prop-types';\nimport { createPopper } from '@popperjs/core';\nimport { FormattedMessage } from 'react-intl';\n\nimport breakpoints from '../utils/breakpoints';\n\nimport CheckpointActionRow from './CheckpointActionRow';\nimport CheckpointBody from './CheckpointBody';\nimport CheckpointBreadcrumbs from './CheckpointBreadcrumbs';\nimport CheckpointTitle from './CheckpointTitle';\nimport messages from './messages';\n\nconst Checkpoint = React.forwardRef(({\n body,\n index,\n placement,\n target,\n title,\n totalCheckpoints,\n ...props\n}, ref) => {\n const [checkpointVisible, setCheckpointVisible] = useState(false);\n const isMobile = useMediaQuery({ maxWidth: breakpoints.small.maxWidth });\n\n useEffect(() => {\n const targetElement = document.querySelector(target);\n const checkpoint = document.querySelector('#pgn__checkpoint');\n if (targetElement && checkpoint) {\n // Use the Popper library to translate the Checkpoint to its target's coordinates\n const checkpointPopper = createPopper(targetElement, checkpoint, {\n placement: isMobile ? 'top' : placement,\n strategy: 'fixed',\n modifiers: [\n {\n name: 'arrow',\n options: {\n padding: 25,\n },\n },\n {\n name: 'offset',\n options: {\n offset: [0, 20],\n },\n },\n {\n name: 'preventOverflow',\n options: {\n padding: 20,\n tetherOffset: 35,\n },\n },\n ],\n });\n setCheckpointVisible(true);\n if (checkpointPopper) {\n checkpointPopper.forceUpdate();\n }\n }\n }, [target, isMobile, placement]);\n\n useEffect(() => {\n if (checkpointVisible) {\n // Scroll the Checkpoint into view once its rendered\n const targetElement = document.querySelector(target);\n let targetOffset = targetElement.getBoundingClientRect().top;\n if ((targetOffset < 0) || (targetElement.getBoundingClientRect().bottom > global.innerHeight)) {\n if (placement.includes('top')) {\n if (targetOffset < 0) {\n targetOffset *= -1;\n }\n targetOffset -= 280;\n } else {\n targetOffset -= 80;\n }\n\n global.scrollTo({\n top: targetOffset, behavior: 'smooth',\n });\n }\n\n const button = document.querySelector('.pgn__checkpoint-button_advance');\n button.focus();\n }\n }, [target, checkpointVisible, placement]);\n\n const isLastCheckpoint = index + 1 === totalCheckpoints;\n const isOnlyCheckpoint = totalCheckpoints === 1;\n\n return (\n <div\n id=\"pgn__checkpoint\"\n className=\"pgn__checkpoint\"\n aria-labelledby=\"pgn__checkpoint-title\"\n ref={ref}\n role=\"dialog\"\n style={{ visibility: checkpointVisible ? 'visible' : 'hidden', pointerEvents: checkpointVisible ? 'auto' : 'none' }}\n >\n <span className=\"sr-only\">\n <FormattedMessage\n {...messages.topPositionText}\n values={{ step: index + 1 }}\n />\n </span>\n {(title || !isOnlyCheckpoint) && (\n <div className=\"pgn__checkpoint-header\">\n <CheckpointTitle>{title}</CheckpointTitle>\n <CheckpointBreadcrumbs currentIndex={index} totalCheckpoints={totalCheckpoints} />\n </div>\n )}\n <CheckpointBody>{body}</CheckpointBody>\n <CheckpointActionRow\n isLastCheckpoint={isLastCheckpoint}\n index={index}\n {...props}\n />\n <div id=\"pgn__checkpoint-arrow\" data-popper-arrow />\n <span className=\"sr-only\">\n <FormattedMessage\n {...messages.bottomPositionText}\n values={{ step: index + 1 }}\n />\n </span>\n </div>\n );\n});\n\nCheckpoint.defaultProps = {\n advanceButtonText: null,\n body: null,\n dismissButtonText: null,\n endButtonText: null,\n placement: 'top',\n title: null,\n showDismissButton: undefined,\n};\n\nCheckpoint.propTypes = {\n /** The text displayed on the button used to advance the tour for the given Checkpoint. */\n advanceButtonText: PropTypes.node,\n /** The text displayed in the body of the Checkpoint */\n body: PropTypes.node,\n /** The text displayed on the button used to dismiss the tour for the given Checkpoint. */\n dismissButtonText: PropTypes.node,\n /** The text displayed on the button used to end the tour for the given Checkpoint. */\n endButtonText: PropTypes.node,\n /** The current index of the given Checkpoint */\n index: PropTypes.number.isRequired,\n /** A function that runs when triggering the `onClick` event of the advance\n * button for the given Checkpoint. */\n onAdvance: PropTypes.func.isRequired,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint. */\n onDismiss: PropTypes.func.isRequired,\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.isRequired,\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 /** The total number of Checkpoints in a tour */\n totalCheckpoints: PropTypes.number.isRequired,\n /** Enforces visibility of the dismiss button under all circumstances */\n showDismissButton: PropTypes.bool,\n};\n\nexport default Checkpoint;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,OAAOC,WAAW,MAAM,sBAAsB;AAE9C,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,qBAAqB,MAAM,yBAAyB;AAC3D,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,QAAQ,MAAM,YAAY;AAEjC,MAAMC,UAAU,gBAAGb,KAAK,CAACc,UAAU,CAAC,CAAAC,IAAA,EAQjCC,GAAG,KAAK;EAAA,IAR0B;IACnCC,IAAI;IACJC,KAAK;IACLC,SAAS;IACTC,MAAM;IACNC,KAAK;IACLC,gBAAgB;IAChB,GAAGC;EACL,CAAC,GAAAR,IAAA;EACC,MAAM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AI;EACjC;EACAJ,aAAa,EAAElE,SAAS,CAACsE,IAAI;EAC7B;EACAxD,KAAK,EAAEd,SAAS,CAACuE,MAAM,CAACC,UAAU;EAClC;AACF;EACEC,SAAS,EAAEzE,SAAS,CAAC0E,IAAI,CAACF,UAAU;EACpC;AACF;EACEG,SAAS,EAAE3E,SAAS,CAAC0E,IAAI,CAACF,UAAU;EACpC;AACF;EACEI,KAAK,EAAE5E,SAAS,CAAC0E,IAAI,CAACF,UAAU;EAChC;EACAzD,SAAS,EAAEf,SAAS,CAAC6E,KAAK,CAAC,CACzB,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAClE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,CACzE,CAAC;EACF;EACA7D,MAAM,EAAEhB,SAAS,CAAC8E,MAAM,CAACN,UAAU;EACnC;EACAvD,KAAK,EAAEjB,SAAS,CAACsE,IAAI;EACrB;EACApD,gBAAgB,EAAElB,SAAS,CAACuE,MAAM,CAACC,UAAU;EAC7C;EACAL,iBAAiB,EAAEnE,SAAS,CAAC+E;AAC/B,CAAC;AAED,eAAetE,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Checkpoint.js","names":["React","useEffect","useState","useMediaQuery","PropTypes","createPopper","FormattedMessage","breakpoints","CheckpointActionRow","CheckpointBody","CheckpointHeader","messages","Checkpoint","forwardRef","_ref","ref","body","dismissAltText","index","onBack","onDismiss","placement","target","title","totalCheckpoints","props","checkpointVisible","setCheckpointVisible","isMobile","maxWidth","small","targetElement","document","querySelector","checkpoint","checkpointPopper","strategy","modifiers","name","options","padding","offset","tetherOffset","forceUpdate","targetOffset","getBoundingClientRect","top","bottom","global","innerHeight","includes","scrollTo","behavior","button","focus","isLastCheckpoint","createElement","id","className","role","style","visibility","pointerEvents","topPositionText","values","step","bottomPositionText","defaultProps","advanceButtonText","backButtonText","endButtonText","propTypes","node","string","number","isRequired","onAdvance","func","onEnd","oneOf"],"sources":["../../src/ProductTour/Checkpoint.jsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { useMediaQuery } from 'react-responsive';\nimport PropTypes from 'prop-types';\nimport { createPopper } from '@popperjs/core';\nimport { FormattedMessage } from 'react-intl';\n\nimport breakpoints from '../utils/breakpoints';\nimport CheckpointActionRow from './CheckpointActionRow';\nimport CheckpointBody from './CheckpointBody';\nimport CheckpointHeader from './CheckpointHeader';\nimport messages from './messages';\n\nconst Checkpoint = React.forwardRef(({\n body,\n dismissAltText,\n index,\n onBack,\n onDismiss,\n placement,\n target,\n title,\n totalCheckpoints,\n ...props\n}, ref) => {\n const [checkpointVisible, setCheckpointVisible] = useState(false);\n const isMobile = useMediaQuery({ maxWidth: breakpoints.small.maxWidth });\n\n useEffect(() => {\n const targetElement = document.querySelector(target);\n const checkpoint = document.querySelector('#pgn__checkpoint');\n if (targetElement && checkpoint) {\n // Use the Popper library to translate the Checkpoint to its target's coordinates\n const checkpointPopper = createPopper(targetElement, checkpoint, {\n placement: isMobile ? 'top' : placement,\n strategy: 'fixed',\n modifiers: [\n {\n name: 'arrow',\n options: {\n padding: 25,\n },\n },\n {\n name: 'offset',\n options: {\n offset: [0, 20],\n },\n },\n {\n name: 'preventOverflow',\n options: {\n padding: 20,\n tetherOffset: 35,\n },\n },\n ],\n });\n setCheckpointVisible(true);\n if (checkpointPopper) {\n checkpointPopper.forceUpdate();\n }\n }\n }, [target, isMobile, placement]);\n\n useEffect(() => {\n if (checkpointVisible) {\n // Scroll the Checkpoint into view once its rendered\n const targetElement = document.querySelector(target);\n let targetOffset = targetElement.getBoundingClientRect().top;\n if ((targetOffset < 0) || (targetElement.getBoundingClientRect().bottom > global.innerHeight)) {\n if (placement.includes('top')) {\n if (targetOffset < 0) {\n targetOffset *= -1;\n }\n targetOffset -= 280;\n } else {\n targetOffset -= 80;\n }\n\n global.scrollTo({\n top: targetOffset, behavior: 'smooth',\n });\n }\n\n const button = document.querySelector('.pgn__checkpoint-button_advance');\n button.focus();\n }\n }, [target, checkpointVisible, placement]);\n\n const isLastCheckpoint = index + 1 === totalCheckpoints;\n\n return (\n <div\n id=\"pgn__checkpoint\"\n className=\"pgn__checkpoint\"\n aria-labelledby=\"pgn__checkpoint-title\"\n ref={ref}\n role=\"dialog\"\n style={{ visibility: checkpointVisible ? 'visible' : 'hidden', pointerEvents: checkpointVisible ? 'auto' : 'none' }}\n >\n <span className=\"sr-only\">\n <FormattedMessage\n {...messages.topPositionText}\n values={{ step: index + 1 }}\n />\n </span>\n <CheckpointHeader\n dismissAltText={dismissAltText}\n index={index}\n onDismiss={onDismiss}\n title={title}\n totalCheckpoints={totalCheckpoints}\n />\n <CheckpointBody>{body}</CheckpointBody>\n <CheckpointActionRow\n onBack={onBack}\n onDismiss={onDismiss}\n isLastCheckpoint={isLastCheckpoint}\n index={index}\n {...props}\n />\n <div id=\"pgn__checkpoint-arrow\" data-popper-arrow />\n <span className=\"sr-only\">\n <FormattedMessage\n {...messages.bottomPositionText}\n values={{ step: index + 1 }}\n />\n </span>\n </div>\n );\n});\n\nCheckpoint.defaultProps = {\n advanceButtonText: null,\n backButtonText: null,\n body: null,\n dismissAltText: null,\n endButtonText: null,\n placement: 'top',\n title: null,\n};\n\nCheckpoint.propTypes = {\n /** The text displayed on the button used to advance the tour for the given Checkpoint. */\n advanceButtonText: PropTypes.node,\n /** The text displayed on the button used go back in the tour for the given Checkpoint. */\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 endButtonText: PropTypes.node,\n /** The current index of the given Checkpoint */\n index: PropTypes.number.isRequired,\n /** A function that runs when triggering the `onClick` event of the advance\n * button for the given Checkpoint. */\n onAdvance: PropTypes.func.isRequired,\n /** A function that runs when triggering the `onBack` event of the back\n * button for the given Checkpoint. */\n onBack: PropTypes.func.isRequired,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint. */\n onDismiss: PropTypes.func.isRequired,\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.isRequired,\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 /** The total number of Checkpoints in a tour */\n totalCheckpoints: PropTypes.number.isRequired,\n};\n\nexport default Checkpoint;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,OAAOC,WAAW,MAAM,sBAAsB;AAC9C,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,QAAQ,MAAM,YAAY;AAEjC,MAAMC,UAAU,gBAAGZ,KAAK,CAACa,UAAU,CAAC,CAAAC,IAAA,EAWjCC,GAAG,KAAK;EAAA,IAX0B;IACnCC,IAAI;IACJC,cAAc;IACdC,KAAK;IACLC,MAAM;IACNC,SAAS;IACTC,SAAS;IACTC,MAAM;IACNC,KAAK;IACLC,gBAAgB;IAChB,GAAGC;EACL,CAAC,GAAAX,IAAA;EACC,MAAM,CAACY,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGzB,QAAQ,CAAC,KAAK,CAAC;EACjE,MAAM0B,QAAQ,GA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AAI,CAACF,UAAU;EACpC;AACF;EACExD,MAAM,EAAEf,SAAS,CAACyE,IAAI,CAACF,UAAU;EACjC;AACF;EACEvD,SAAS,EAAEhB,SAAS,CAACyE,IAAI,CAACF,UAAU;EACpC;AACF;EACEG,KAAK,EAAE1E,SAAS,CAACyE,IAAI,CAACF,UAAU;EAChC;EACAtD,SAAS,EAAEjB,SAAS,CAAC2E,KAAK,CAAC,CACzB,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAClE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,CACzE,CAAC;EACF;EACAzD,MAAM,EAAElB,SAAS,CAACqE,MAAM,CAACE,UAAU;EACnC;EACApD,KAAK,EAAEnB,SAAS,CAACoE,IAAI;EACrB;EACAhD,gBAAgB,EAAEpB,SAAS,CAACsE,MAAM,CAACC;AACrC,CAAC;AAED,eAAe/D,UAAU","ignoreList":[]}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
var(--pgn-size-product-tour-checkpoint-width-border)
|
|
8
8
|
solid var(--pgn-color-product-tour-checkpoint-border);
|
|
9
9
|
border-radius: var(--pgn-size-border-radius-base);
|
|
10
|
-
padding: var(--pgn-spacing-spacer-
|
|
10
|
+
padding: var(--pgn-spacing-spacer-3-5);
|
|
11
11
|
box-shadow: 0 .25rem .5rem var(--pgn-color-product-tour-checkpoint-box-shadow);
|
|
12
12
|
z-index: var(--pgn-elevation-product-tour-checkpoint-zindex);
|
|
13
13
|
max-width: var(--pgn-size-product-tour-checkpoint-width-max);
|
|
@@ -44,39 +44,6 @@
|
|
|
44
44
|
margin-inline-end: var(--pgn-spacing-spacer-2);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.pgn__checkpoint-breadcrumb {
|
|
48
|
-
height: 6px;
|
|
49
|
-
width: 6px;
|
|
50
|
-
border-radius: 50%;
|
|
51
|
-
|
|
52
|
-
&.pgn__checkpoint-breadcrumb_active {
|
|
53
|
-
background: var(--pgn-color-product-tour-checkpoint-breadcrumb);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
&.pgn__checkpoint-breadcrumb_inactive {
|
|
57
|
-
border: 1px solid var(--pgn-color-product-tour-checkpoint-breadcrumb);
|
|
58
|
-
background: transparent;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
&:not(:first-child) {
|
|
62
|
-
margin-left: map.get($spacers, 1\.5);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
[dir="rtl"] & {
|
|
66
|
-
margin-left: map.get($spacers, 1\.5);
|
|
67
|
-
margin-right: 0;
|
|
68
|
-
|
|
69
|
-
&:last-child {
|
|
70
|
-
margin-left: 0;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.pgn__checkpoint-breadcrumb-container {
|
|
76
|
-
display: flex;
|
|
77
|
-
align-items: center;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
47
|
.pgn__checkpoint-body {
|
|
81
48
|
color: var(--pgn-color-product-tour-checkpoint-body);
|
|
82
49
|
margin-bottom: map.get($spacers, 3\.5);
|
|
@@ -86,13 +53,18 @@
|
|
|
86
53
|
.pgn__checkpoint-header {
|
|
87
54
|
display: flex;
|
|
88
55
|
justify-content: space-between;
|
|
89
|
-
margin-bottom: map.get($spacers, 2
|
|
56
|
+
margin-bottom: map.get($spacers, 2);
|
|
57
|
+
align-items: center;
|
|
90
58
|
}
|
|
91
59
|
|
|
92
60
|
#pgn__checkpoint-title {
|
|
93
61
|
font-size: var(--pgn-typography-font-size-h3-base);
|
|
94
62
|
margin-inline-end: map.get($spacers, 2\.5);
|
|
95
|
-
margin-bottom:
|
|
63
|
+
margin-bottom: map.get($spacers, 2);;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.pgn__checkpoint-page-index {
|
|
67
|
+
font-size: $small-font-size;
|
|
96
68
|
}
|
|
97
69
|
}
|
|
98
70
|
|
|
@@ -1,60 +1,56 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import ActionRow from '../ActionRow';
|
|
3
4
|
import Button from '../Button';
|
|
4
|
-
const CheckpointActionRow = /*#__PURE__*/React.forwardRef(
|
|
5
|
+
const CheckpointActionRow = /*#__PURE__*/React.forwardRef(_ref => {
|
|
5
6
|
let {
|
|
6
7
|
advanceButtonText,
|
|
7
|
-
|
|
8
|
+
backButtonText,
|
|
8
9
|
endButtonText,
|
|
9
10
|
isLastCheckpoint,
|
|
10
11
|
onAdvance,
|
|
11
|
-
|
|
12
|
+
onBack,
|
|
12
13
|
onEnd,
|
|
13
|
-
showDismissButton,
|
|
14
14
|
index
|
|
15
15
|
} = _ref;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
16
|
+
const isFirstCheckpoint = index === 0;
|
|
17
|
+
return /*#__PURE__*/React.createElement(ActionRow, {
|
|
18
|
+
className: "pgn__checkpoint-action-row"
|
|
19
|
+
}, !isFirstCheckpoint && /*#__PURE__*/React.createElement(Button, {
|
|
20
|
+
className: "pgn__checkpoint-button-back",
|
|
20
21
|
variant: "tertiary",
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}, dismissButtonText), /*#__PURE__*/React.createElement(Button, {
|
|
22
|
+
onClick: onBack
|
|
23
|
+
}, backButtonText), /*#__PURE__*/React.createElement(Button, {
|
|
24
24
|
autoFocus: true,
|
|
25
25
|
className: "pgn__checkpoint-button_advance",
|
|
26
|
-
variant: "primary",
|
|
27
26
|
onClick: isLastCheckpoint ? () => onEnd(index) : () => onAdvance(index)
|
|
28
27
|
}, isLastCheckpoint ? endButtonText : advanceButtonText));
|
|
29
28
|
});
|
|
30
29
|
CheckpointActionRow.defaultProps = {
|
|
31
30
|
advanceButtonText: '',
|
|
32
|
-
|
|
31
|
+
backButtonText: '',
|
|
33
32
|
endButtonText: '',
|
|
34
33
|
isLastCheckpoint: false,
|
|
35
34
|
onAdvance: () => {},
|
|
36
|
-
|
|
35
|
+
onBack: () => {},
|
|
37
36
|
onEnd: () => {},
|
|
38
|
-
showDismissButton: undefined,
|
|
39
37
|
index: 0
|
|
40
38
|
};
|
|
41
39
|
CheckpointActionRow.propTypes = {
|
|
42
40
|
/** The text displayed on the button used to advance the tour. */
|
|
43
41
|
advanceButtonText: PropTypes.node,
|
|
44
|
-
/** The text displayed on the button used to
|
|
45
|
-
|
|
42
|
+
/** The text displayed on the button used to go back on the tour */
|
|
43
|
+
backButtonText: PropTypes.string,
|
|
46
44
|
/** The text displayed on the button used to end the tour. */
|
|
47
45
|
endButtonText: PropTypes.node,
|
|
48
46
|
/** Whether the parent Checkpoint is the last in the tour. */
|
|
49
47
|
isLastCheckpoint: PropTypes.bool,
|
|
50
48
|
/** A function that runs when triggering the `onClick` event of the advance button. */
|
|
51
49
|
onAdvance: PropTypes.func,
|
|
52
|
-
/** A function that runs when triggering the `onClick` event of the
|
|
53
|
-
|
|
50
|
+
/** A function that runs when triggering the `onClick` event of the back button. */
|
|
51
|
+
onBack: PropTypes.func,
|
|
54
52
|
/** A function that runs when triggering the `onClick` event of the advance button if isLastCheckpoint is true. */
|
|
55
53
|
onEnd: PropTypes.func,
|
|
56
|
-
/** Enforces visibility of the dismiss button under all circumstances */
|
|
57
|
-
showDismissButton: PropTypes.bool,
|
|
58
54
|
/** Allows visibility of last index value for onEnd checkpoint compatibility */
|
|
59
55
|
index: PropTypes.number
|
|
60
56
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckpointActionRow.js","names":["React","PropTypes","Button","CheckpointActionRow","forwardRef","_ref","
|
|
1
|
+
{"version":3,"file":"CheckpointActionRow.js","names":["React","PropTypes","ActionRow","Button","CheckpointActionRow","forwardRef","_ref","advanceButtonText","backButtonText","endButtonText","isLastCheckpoint","onAdvance","onBack","onEnd","index","isFirstCheckpoint","createElement","className","variant","onClick","autoFocus","defaultProps","propTypes","node","string","bool","func","number"],"sources":["../../src/ProductTour/CheckpointActionRow.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport ActionRow from '../ActionRow';\nimport Button from '../Button';\n\nconst CheckpointActionRow = React.forwardRef(({\n advanceButtonText,\n backButtonText,\n endButtonText,\n isLastCheckpoint,\n onAdvance,\n onBack,\n onEnd,\n index,\n}) => {\n const isFirstCheckpoint = index === 0;\n return (\n <ActionRow className=\"pgn__checkpoint-action-row\">\n {!isFirstCheckpoint && (\n <Button\n className=\"pgn__checkpoint-button-back\"\n variant=\"tertiary\"\n onClick={onBack}\n >\n {backButtonText}\n </Button>\n )}\n <Button\n autoFocus\n className=\"pgn__checkpoint-button_advance\"\n onClick={isLastCheckpoint ? () => onEnd(index) : () => onAdvance(index)}\n >\n {isLastCheckpoint ? endButtonText : advanceButtonText}\n </Button>\n </ActionRow>\n );\n});\n\nCheckpointActionRow.defaultProps = {\n advanceButtonText: '',\n backButtonText: '',\n endButtonText: '',\n isLastCheckpoint: false,\n onAdvance: () => { },\n onBack: () => { },\n onEnd: () => { },\n index: 0,\n};\n\nCheckpointActionRow.propTypes = {\n /** The text displayed on the button used to advance the tour. */\n advanceButtonText: PropTypes.node,\n /** The text displayed on the button used to go back on the tour */\n backButtonText: PropTypes.string,\n /** The text displayed on the button used to end the tour. */\n endButtonText: PropTypes.node,\n /** Whether the parent Checkpoint is the last in the tour. */\n isLastCheckpoint: PropTypes.bool,\n /** A function that runs when triggering the `onClick` event of the advance button. */\n onAdvance: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the back button. */\n onBack: PropTypes.func,\n /** A function that runs when triggering the `onClick` event of the advance button if isLastCheckpoint is true. */\n onEnd: PropTypes.func,\n /** Allows visibility of last index value for onEnd checkpoint compatibility */\n index: PropTypes.number,\n};\n\nexport default CheckpointActionRow;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAElC,OAAOC,SAAS,M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AAER,SAAS,CAACsB,IAAI;EAC7B;EACAb,gBAAgB,EAAET,SAAS,CAACwB,IAAI;EAChC;EACAd,SAAS,EAAEV,SAAS,CAACyB,IAAI;EACzB;EACAd,MAAM,EAAEX,SAAS,CAACyB,IAAI;EACtB;EACAb,KAAK,EAAEZ,SAAS,CAACyB,IAAI;EACrB;EACAZ,KAAK,EAAEb,SAAS,CAAC0B;AACnB,CAAC;AAED,eAAevB,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FormattedMessage, useIntl } from 'react-intl';
|
|
4
|
+
import Icon from '../Icon';
|
|
5
|
+
import IconButton from '../IconButton';
|
|
6
|
+
import { Close } from '../../icons';
|
|
7
|
+
import CheckpointTitle from './CheckpointTitle';
|
|
8
|
+
import messages from './messages';
|
|
9
|
+
const CheckpointHeader = /*#__PURE__*/React.forwardRef(_ref => {
|
|
10
|
+
let {
|
|
11
|
+
dismissAltText,
|
|
12
|
+
index,
|
|
13
|
+
onDismiss,
|
|
14
|
+
title,
|
|
15
|
+
totalCheckpoints
|
|
16
|
+
} = _ref;
|
|
17
|
+
const intl = useIntl();
|
|
18
|
+
const oneBasedIndex = index + 1;
|
|
19
|
+
const altText = dismissAltText && typeof dismissAltText === 'string' ? dismissAltText : intl.formatMessage(messages.closeAltText);
|
|
20
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("header", {
|
|
21
|
+
className: "pgn__checkpoint-header"
|
|
22
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
23
|
+
className: "pgn__checkpoint-page-index"
|
|
24
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
25
|
+
...messages.pageIndexText,
|
|
26
|
+
values: {
|
|
27
|
+
step: oneBasedIndex,
|
|
28
|
+
totalSteps: totalCheckpoints
|
|
29
|
+
}
|
|
30
|
+
})), /*#__PURE__*/React.createElement(IconButton, {
|
|
31
|
+
size: "sm",
|
|
32
|
+
iconAs: Icon,
|
|
33
|
+
src: Close,
|
|
34
|
+
alt: altText,
|
|
35
|
+
onClick: onDismiss,
|
|
36
|
+
"data-testid": "dismiss-tour"
|
|
37
|
+
})), title && /*#__PURE__*/React.createElement(CheckpointTitle, null, title));
|
|
38
|
+
});
|
|
39
|
+
CheckpointHeader.defaultProps = {
|
|
40
|
+
dismissAltText: null,
|
|
41
|
+
title: ''
|
|
42
|
+
};
|
|
43
|
+
CheckpointHeader.propTypes = {
|
|
44
|
+
/** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */
|
|
45
|
+
dismissAltText: PropTypes.string,
|
|
46
|
+
/** The current index of the given Checkpoint */
|
|
47
|
+
index: PropTypes.number.isRequired,
|
|
48
|
+
/** A function that runs when triggering the `onClick` event of the dismiss
|
|
49
|
+
* button for the given Checkpoint. */
|
|
50
|
+
onDismiss: PropTypes.func.isRequired,
|
|
51
|
+
/** The text displayed in the title of the Checkpoint */
|
|
52
|
+
title: PropTypes.node,
|
|
53
|
+
/** The total number of Checkpoints in a tour */
|
|
54
|
+
totalCheckpoints: PropTypes.number.isRequired
|
|
55
|
+
};
|
|
56
|
+
export default CheckpointHeader;
|
|
57
|
+
//# sourceMappingURL=CheckpointHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckpointHeader.js","names":["React","PropTypes","FormattedMessage","useIntl","Icon","IconButton","Close","CheckpointTitle","messages","CheckpointHeader","forwardRef","_ref","dismissAltText","index","onDismiss","title","totalCheckpoints","intl","oneBasedIndex","altText","formatMessage","closeAltText","createElement","Fragment","className","pageIndexText","values","step","totalSteps","size","iconAs","src","alt","onClick","defaultProps","propTypes","string","number","isRequired","func","node"],"sources":["../../src/ProductTour/CheckpointHeader.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { FormattedMessage, useIntl } from 'react-intl';\n\nimport Icon from '../Icon';\nimport IconButton from '../IconButton';\nimport { Close } from '../../icons';\nimport CheckpointTitle from './CheckpointTitle';\nimport messages from './messages';\n\nconst CheckpointHeader = React.forwardRef(({\n dismissAltText, index, onDismiss, title, totalCheckpoints,\n}) => {\n const intl = useIntl();\n const oneBasedIndex = index + 1;\n const altText = (dismissAltText && typeof dismissAltText === 'string') ? dismissAltText : intl.formatMessage(messages.closeAltText);\n\n return (\n <>\n <header className=\"pgn__checkpoint-header\">\n <span className=\"pgn__checkpoint-page-index\">\n <FormattedMessage\n {...messages.pageIndexText}\n values={{ step: oneBasedIndex, totalSteps: totalCheckpoints }}\n />\n </span>\n <IconButton\n size=\"sm\"\n iconAs={Icon}\n src={Close}\n alt={altText}\n onClick={onDismiss}\n data-testid=\"dismiss-tour\"\n />\n </header>\n {title && (<CheckpointTitle>{title}</CheckpointTitle>)}\n </>\n );\n});\n\nCheckpointHeader.defaultProps = {\n dismissAltText: null,\n title: '',\n};\n\nCheckpointHeader.propTypes = {\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 current index of the given Checkpoint */\n index: PropTypes.number.isRequired,\n /** A function that runs when triggering the `onClick` event of the dismiss\n * button for the given Checkpoint. */\n onDismiss: PropTypes.func.isRequired,\n /** The text displayed in the title of the Checkpoint */\n title: PropTypes.node,\n /** The total number of Checkpoints in a tour */\n totalCheckpoints: PropTypes.number.isRequired,\n};\n\nexport default CheckpointHeader;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,gBAAgB,EAAEC,OAAO,QAAQ,YAAY;AAEtD,OAAOC,IAAI,MAAM,SAAS;AAC1B,OAAOC,UAAU,MAAM,eAAe;AACtC,SAASC,KAAK,QAAQ,aAAa;AACnC,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,QAAQ,MAAM,YAAY;AAEjC,MAAMC,gBAAgB,gBAAGT,KAAK,CAACU,UAAU,CAACC,IA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EAClC;AACF;EACExB,SAAS,EAAEb,SAAS,CAACsC,IAAI,CAACD,UAAU;EACpC;EACAvB,KAAK,EAAEd,SAAS,CAACuC,IAAI;EACrB;EACAxB,gBAAgB,EAAEf,SAAS,CAACoC,MAAM,CAACC;AACrC,CAAC;AAED,eAAe7B,gBAAgB","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';
|
|
3
4
|
import Checkpoint from './Checkpoint';
|
|
4
5
|
const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
5
6
|
let {
|
|
@@ -12,10 +13,12 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
12
13
|
startingIndex,
|
|
13
14
|
onEscape,
|
|
14
15
|
onEnd,
|
|
16
|
+
onBack,
|
|
15
17
|
onDismiss: tourOnDismiss,
|
|
16
18
|
advanceButtonText: tourAdvanceButtonText,
|
|
17
|
-
|
|
18
|
-
endButtonText: tourEndButtonText
|
|
19
|
+
dismissAltText: tourDismissAltText,
|
|
20
|
+
endButtonText: tourEndButtonText,
|
|
21
|
+
backButtonText: tourBackButtonText
|
|
19
22
|
} = tourValue || {};
|
|
20
23
|
const [currentCheckpointData, setCurrentCheckpointData] = useState(null);
|
|
21
24
|
const [index, setIndex] = useState(0);
|
|
@@ -27,11 +30,11 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
27
30
|
onAdvance,
|
|
28
31
|
onDismiss,
|
|
29
32
|
advanceButtonText,
|
|
30
|
-
|
|
33
|
+
dismissAltText,
|
|
31
34
|
endButtonText,
|
|
35
|
+
backButtonText,
|
|
32
36
|
placement,
|
|
33
|
-
target
|
|
34
|
-
showDismissButton
|
|
37
|
+
target
|
|
35
38
|
} = currentCheckpointData || {};
|
|
36
39
|
|
|
37
40
|
/**
|
|
@@ -77,6 +80,12 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
77
80
|
onAdvance();
|
|
78
81
|
}
|
|
79
82
|
};
|
|
83
|
+
const handleBack = () => {
|
|
84
|
+
setIndex(index - 1);
|
|
85
|
+
if (onBack) {
|
|
86
|
+
onBack();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
80
89
|
const handleDismiss = () => {
|
|
81
90
|
setIndex(0);
|
|
82
91
|
setIsTourEnabled(false);
|
|
@@ -111,9 +120,11 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
111
120
|
advanceButtonText: advanceButtonText || tourAdvanceButtonText,
|
|
112
121
|
body: body,
|
|
113
122
|
currentCheckpointData: currentCheckpointData,
|
|
114
|
-
|
|
123
|
+
dismissAltText: dismissAltText || tourDismissAltText,
|
|
115
124
|
endButtonText: endButtonText || tourEndButtonText,
|
|
125
|
+
backButtonText: backButtonText || tourBackButtonText,
|
|
116
126
|
index: index,
|
|
127
|
+
onBack: handleBack,
|
|
117
128
|
onAdvance: handleAdvance,
|
|
118
129
|
onDismiss: handleDismiss,
|
|
119
130
|
onEnd: handleEnd,
|
|
@@ -121,26 +132,28 @@ const ProductTour = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
121
132
|
target: target,
|
|
122
133
|
title: title,
|
|
123
134
|
totalCheckpoints: prunedCheckpoints.length,
|
|
124
|
-
showDismissButton: showDismissButton,
|
|
125
135
|
ref: ref
|
|
126
136
|
});
|
|
127
137
|
});
|
|
128
138
|
ProductTour.defaultProps = {
|
|
129
139
|
tours: {
|
|
130
140
|
advanceButtonText: '',
|
|
141
|
+
backButtonText: '',
|
|
131
142
|
checkpoints: {
|
|
132
143
|
advanceButtonText: '',
|
|
144
|
+
backButtonText: '',
|
|
133
145
|
body: '',
|
|
134
|
-
|
|
146
|
+
dismissAltText: '',
|
|
135
147
|
endButtonText: '',
|
|
136
148
|
onAdvance: () => {},
|
|
137
149
|
onDismiss: () => {},
|
|
150
|
+
onBack: () => {},
|
|
138
151
|
placement: 'top',
|
|
139
|
-
title: ''
|
|
140
|
-
showDismissButton: undefined
|
|
152
|
+
title: ''
|
|
141
153
|
},
|
|
142
|
-
|
|
154
|
+
dismissAltText: '',
|
|
143
155
|
endButtonText: '',
|
|
156
|
+
onBack: () => {},
|
|
144
157
|
onDismiss: () => {},
|
|
145
158
|
onEnd: () => {},
|
|
146
159
|
onEscape: () => {},
|
|
@@ -151,16 +164,20 @@ ProductTour.propTypes = {
|
|
|
151
164
|
tours: PropTypes.arrayOf(PropTypes.shape({
|
|
152
165
|
/** The text displayed on all buttons used to advance the tour. */
|
|
153
166
|
advanceButtonText: PropTypes.node,
|
|
167
|
+
/** The text displayed on all buttons used to go back in the tour */
|
|
168
|
+
backButtonText: PropTypes.string,
|
|
154
169
|
/** An array comprised of checkpoint objects supporting the following values: */
|
|
155
170
|
checkpoints: PropTypes.arrayOf(PropTypes.shape({
|
|
156
171
|
/** The text displayed on the button used to advance the tour for the given Checkpoint
|
|
157
172
|
* (overrides the* `advanceButtonText` defined in the parent tour object). */
|
|
158
173
|
advanceButtonText: PropTypes.node,
|
|
174
|
+
/** The text displayed on the button used to go back in the tour for the given Checkpoint
|
|
175
|
+
* (overrides the* `backButtonText` defined in the parent tour object). */
|
|
176
|
+
backButtonText: PropTypes.string,
|
|
159
177
|
/** The text displayed in the body of the Checkpoint */
|
|
160
178
|
body: PropTypes.node,
|
|
161
|
-
/** The text
|
|
162
|
-
|
|
163
|
-
dismissButtonText: PropTypes.node,
|
|
179
|
+
/** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */
|
|
180
|
+
dismissAltText: PropTypes.string,
|
|
164
181
|
/** The text displayed on the button used to end the tour for the given Checkpoint
|
|
165
182
|
* (overrides the `endButtonText` defined in the parent tour object). */
|
|
166
183
|
endButtonText: PropTypes.node,
|
|
@@ -178,16 +195,16 @@ ProductTour.propTypes = {
|
|
|
178
195
|
/** The CSS selector for the Checkpoint's desired target. */
|
|
179
196
|
target: PropTypes.string.isRequired,
|
|
180
197
|
/** The text displayed in the title of the Checkpoint */
|
|
181
|
-
title: PropTypes.node
|
|
182
|
-
/** Enforces visibility of the dismiss button under all circumstances */
|
|
183
|
-
showDismissButton: PropTypes.bool
|
|
198
|
+
title: PropTypes.node
|
|
184
199
|
})),
|
|
185
|
-
/** The text
|
|
186
|
-
|
|
200
|
+
/** The text used in the alt for the icon used to dismiss the tour for the given Checkpoint */
|
|
201
|
+
dismissAltText: PropTypes.string,
|
|
187
202
|
/** Whether the tour is enabled. If there are multiple tours defined, only one should be enabled at a time. */
|
|
188
203
|
enabled: PropTypes.bool.isRequired,
|
|
189
204
|
/** The text displayed on the button used to end the tour. */
|
|
190
205
|
endButtonText: PropTypes.node,
|
|
206
|
+
/** A function that runs when triggering the `onBack` event of the back button. */
|
|
207
|
+
onBack: PropTypes.func,
|
|
191
208
|
/** A function that runs when triggering the `onClick` event of the dismiss button. */
|
|
192
209
|
onDismiss: PropTypes.func,
|
|
193
210
|
/** A function that runs when triggering the `onClick` event of the end button. */
|
|
@@ -200,5 +217,88 @@ ProductTour.propTypes = {
|
|
|
200
217
|
tourId: PropTypes.string.isRequired
|
|
201
218
|
}))
|
|
202
219
|
};
|
|
203
|
-
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Checks if the given object has a deprecated/legacy `dismissButtonText` property.
|
|
223
|
+
* @param {Object} obj - The object to check
|
|
224
|
+
* @returns {boolean} - True if the object has a deprecated/legacy `dismissButtonText` property, false otherwise
|
|
225
|
+
*/
|
|
226
|
+
const hasDismissButtonText = obj => {
|
|
227
|
+
if ('dismissButtonText' in obj && !!obj.dismissButtonText) {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
};
|
|
232
|
+
export default withDeprecatedProps(ProductTour, 'ProductTour', {
|
|
233
|
+
tours: {
|
|
234
|
+
deprType: DeprTypes.FORMAT,
|
|
235
|
+
message: "The dismissButtonText options in the 'tours' prop have been moved to 'dismissAltText'.",
|
|
236
|
+
/**
|
|
237
|
+
* Determines whether the given prop value contains the deprecated/legacy `dismissButtonText` property.
|
|
238
|
+
* @param {Object[]} propValue - The tours prop value to check
|
|
239
|
+
* @returns {boolean} True if the prop value contains the deprecated/legacy `dismissButtonText`
|
|
240
|
+
* property, false otherwise
|
|
241
|
+
*/
|
|
242
|
+
expect: propValue => {
|
|
243
|
+
if (!Array.isArray(propValue)) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
return !propValue.some(tour => {
|
|
247
|
+
if (hasDismissButtonText(tour)) {
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
return Array.isArray(tour.checkpoints) && tour.checkpoints.some(hasDismissButtonText);
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
/**
|
|
254
|
+
* Transforms the given prop value by updating the
|
|
255
|
+
* deprecated/legacy `dismissButtonText` property to
|
|
256
|
+
* `dismissAltText`, if the prop value is a string. Otherwise,
|
|
257
|
+
* the original `dismissButtonText` property is ignored.
|
|
258
|
+
* @param {Object[]} propValue - The tours prop value to transform
|
|
259
|
+
* @returns {Object[]} The transformed prop value
|
|
260
|
+
*/
|
|
261
|
+
transform: propValue => {
|
|
262
|
+
const tours = propValue.map(tour => {
|
|
263
|
+
const updatedTour = {
|
|
264
|
+
...tour
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// Replace tour level dismissButtonText with dismissAltText
|
|
268
|
+
if (hasDismissButtonText(tour)) {
|
|
269
|
+
if (typeof tour.dismissButtonText === 'string') {
|
|
270
|
+
updatedTour.dismissAltText = tour.dismissButtonText;
|
|
271
|
+
} else {
|
|
272
|
+
const warningMessage = "[Deprecated] ProductTour: The 'dismissButtonText' options within the 'tours' prop now expects a string";
|
|
273
|
+
// eslint-disable-next-line no-console
|
|
274
|
+
console.warn(warningMessage);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Replace checkpoint level dismissButtonText with dismissAltText
|
|
279
|
+
if (Array.isArray(tour.checkpoints)) {
|
|
280
|
+
updatedTour.checkpoints = tour.checkpoints.map(checkpoint => {
|
|
281
|
+
if (hasDismissButtonText(checkpoint)) {
|
|
282
|
+
const {
|
|
283
|
+
dismissButtonText,
|
|
284
|
+
...rest
|
|
285
|
+
} = checkpoint;
|
|
286
|
+
if (typeof dismissButtonText === 'string') {
|
|
287
|
+
return {
|
|
288
|
+
...rest,
|
|
289
|
+
dismissAltText: dismissButtonText
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return checkpoint;
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
return updatedTour;
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// Return the transformed tours
|
|
300
|
+
return tours;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
});
|
|
204
304
|
//# sourceMappingURL=index.js.map
|