@matthesketh/react-guidetour 1.0.0 → 1.1.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/README.md +3 -3
- package/dist/index.d.mts +1 -20
- package/dist/index.d.ts +1 -20
- package/dist/index.js +170 -174
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +166 -163
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -6
- package/src/__tests__/setup.ts +1 -0
- package/src/components/Step.tsx +161 -68
- package/src/components/__tests__/Beacon.test.tsx +72 -0
- package/src/components/__tests__/Joyride.test.tsx +94 -0
- package/src/components/__tests__/Overlay.test.tsx +87 -0
- package/src/components/__tests__/Portal.test.tsx +71 -0
- package/src/components/__tests__/Tooltip.test.tsx +281 -0
- package/src/components/index.tsx +3 -29
- package/src/defaults.ts +0 -7
- package/src/modules/__tests__/dom.test.ts +102 -0
- package/src/modules/__tests__/helpers.test.ts +187 -0
- package/src/modules/__tests__/store.test.ts +384 -0
- package/src/modules/step.ts +3 -32
- package/src/modules/store.ts +0 -26
- package/src/styles.ts +3 -12
- package/src/types/common.ts +0 -5
- package/src/types/components.ts +0 -10
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @matthesketh/react-guidetour
|
|
2
2
|
|
|
3
3
|
React 19 guided tour component. A modernised fork of [react-joyride](https://github.com/gilbarbara/react-joyride) by Gil Barbara.
|
|
4
4
|
|
|
@@ -14,7 +14,7 @@ react-joyride v2.9.3 uses `ReactDOM.unmountComponentAtNode()` and `ReactDOM.unst
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install @
|
|
17
|
+
npm install @matthesketh/react-guidetour
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Usage
|
|
@@ -22,7 +22,7 @@ npm install @wrxck/react-guidetour
|
|
|
22
22
|
The API is the same as react-joyride. See the [react-joyride documentation](https://docs.react-joyride.com/) for full usage details.
|
|
23
23
|
|
|
24
24
|
```tsx
|
|
25
|
-
import Joyride from '@
|
|
25
|
+
import Joyride from '@matthesketh/react-guidetour';
|
|
26
26
|
|
|
27
27
|
const steps = [
|
|
28
28
|
{
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { CSSProperties, ReactNode, ElementType, MouseEventHandler, RefCallback } from 'react';
|
|
3
|
-
import { Styles as Styles$1, Props as Props$1 } from 'react-floater';
|
|
4
|
-
export { Props as FloaterProps } from 'react-floater';
|
|
5
3
|
import { ValueOf, Simplify, SetRequired, PartialDeep } from 'type-fest';
|
|
6
4
|
|
|
7
5
|
declare const ACTIONS: {
|
|
@@ -119,9 +117,6 @@ interface Styles {
|
|
|
119
117
|
tooltipFooterSpacer: CSSProperties;
|
|
120
118
|
tooltipTitle: CSSProperties;
|
|
121
119
|
}
|
|
122
|
-
interface StylesWithFloaterStyles extends Styles {
|
|
123
|
-
floaterStyles: Styles$1;
|
|
124
|
-
}
|
|
125
120
|
interface StylesOptions {
|
|
126
121
|
arrowColor: string;
|
|
127
122
|
backgroundColor: string;
|
|
@@ -135,10 +130,7 @@ interface StylesOptions {
|
|
|
135
130
|
}
|
|
136
131
|
|
|
137
132
|
type Listener = (state: State) => void;
|
|
138
|
-
type PopperData = any;
|
|
139
133
|
declare class Store {
|
|
140
|
-
private beaconPopper;
|
|
141
|
-
private tooltipPopper;
|
|
142
134
|
private data;
|
|
143
135
|
private listener;
|
|
144
136
|
private store;
|
|
@@ -151,9 +143,6 @@ declare class Store {
|
|
|
151
143
|
addListener: (listener: Listener) => void;
|
|
152
144
|
setSteps: (steps: Array<Step>) => void;
|
|
153
145
|
getHelpers(): StoreHelpers;
|
|
154
|
-
getPopper: (name: "beacon" | "tooltip") => PopperData | null;
|
|
155
|
-
setPopper: (name: "beacon" | "tooltip", popper: PopperData) => void;
|
|
156
|
-
cleanupPoppers: () => void;
|
|
157
146
|
close: (origin?: Origin | null) => void;
|
|
158
147
|
go: (nextIndex: number) => void;
|
|
159
148
|
info: () => State;
|
|
@@ -198,10 +187,6 @@ type BaseProps = {
|
|
|
198
187
|
* @default false
|
|
199
188
|
*/
|
|
200
189
|
disableScrolling?: boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Options to be passed to react-floater
|
|
203
|
-
*/
|
|
204
|
-
floaterProps?: Partial<Props$1>;
|
|
205
190
|
/**
|
|
206
191
|
* Hide the Back button.
|
|
207
192
|
* @default false
|
|
@@ -383,10 +368,6 @@ type Step = Simplify<BaseProps & {
|
|
|
383
368
|
* @default click
|
|
384
369
|
*/
|
|
385
370
|
event?: 'click' | 'hover';
|
|
386
|
-
/**
|
|
387
|
-
* Options to be passed to react-floater
|
|
388
|
-
*/
|
|
389
|
-
floaterProps?: Props$1;
|
|
390
371
|
/**
|
|
391
372
|
* Hide the tooltip's footer.
|
|
392
373
|
* @default false
|
|
@@ -493,4 +474,4 @@ type TooltipRenderProps = Simplify<BeaconRenderProps & {
|
|
|
493
474
|
|
|
494
475
|
declare function Joyride(inputProps: Props): react_jsx_runtime.JSX.Element | null;
|
|
495
476
|
|
|
496
|
-
export { ACTIONS, type Actions, type AnyObject, type BaseProps, type BeaconProps, type BeaconRenderProps, type CallBackProps, type Callback, EVENTS, type Events, LIFECYCLE, type Lifecycle, type Locale, type NarrowPlainObject, ORIGIN, type Origin, type OverlayProps, type Placement, type Props, STATUS, type State, type Status, type Step, type StepMerged, type StepProps, type StoreHelpers, type StoreOptions, type Styles, type StylesOptions, type
|
|
477
|
+
export { ACTIONS, type Actions, type AnyObject, type BaseProps, type BeaconProps, type BeaconRenderProps, type CallBackProps, type Callback, EVENTS, type Events, LIFECYCLE, type Lifecycle, type Locale, type NarrowPlainObject, ORIGIN, type Origin, type OverlayProps, type Placement, type Props, STATUS, type State, type Status, type Step, type StepMerged, type StepProps, type StoreHelpers, type StoreOptions, type Styles, type StylesOptions, type TooltipProps, type TooltipRenderProps, Joyride as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { CSSProperties, ReactNode, ElementType, MouseEventHandler, RefCallback } from 'react';
|
|
3
|
-
import { Styles as Styles$1, Props as Props$1 } from 'react-floater';
|
|
4
|
-
export { Props as FloaterProps } from 'react-floater';
|
|
5
3
|
import { ValueOf, Simplify, SetRequired, PartialDeep } from 'type-fest';
|
|
6
4
|
|
|
7
5
|
declare const ACTIONS: {
|
|
@@ -119,9 +117,6 @@ interface Styles {
|
|
|
119
117
|
tooltipFooterSpacer: CSSProperties;
|
|
120
118
|
tooltipTitle: CSSProperties;
|
|
121
119
|
}
|
|
122
|
-
interface StylesWithFloaterStyles extends Styles {
|
|
123
|
-
floaterStyles: Styles$1;
|
|
124
|
-
}
|
|
125
120
|
interface StylesOptions {
|
|
126
121
|
arrowColor: string;
|
|
127
122
|
backgroundColor: string;
|
|
@@ -135,10 +130,7 @@ interface StylesOptions {
|
|
|
135
130
|
}
|
|
136
131
|
|
|
137
132
|
type Listener = (state: State) => void;
|
|
138
|
-
type PopperData = any;
|
|
139
133
|
declare class Store {
|
|
140
|
-
private beaconPopper;
|
|
141
|
-
private tooltipPopper;
|
|
142
134
|
private data;
|
|
143
135
|
private listener;
|
|
144
136
|
private store;
|
|
@@ -151,9 +143,6 @@ declare class Store {
|
|
|
151
143
|
addListener: (listener: Listener) => void;
|
|
152
144
|
setSteps: (steps: Array<Step>) => void;
|
|
153
145
|
getHelpers(): StoreHelpers;
|
|
154
|
-
getPopper: (name: "beacon" | "tooltip") => PopperData | null;
|
|
155
|
-
setPopper: (name: "beacon" | "tooltip", popper: PopperData) => void;
|
|
156
|
-
cleanupPoppers: () => void;
|
|
157
146
|
close: (origin?: Origin | null) => void;
|
|
158
147
|
go: (nextIndex: number) => void;
|
|
159
148
|
info: () => State;
|
|
@@ -198,10 +187,6 @@ type BaseProps = {
|
|
|
198
187
|
* @default false
|
|
199
188
|
*/
|
|
200
189
|
disableScrolling?: boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Options to be passed to react-floater
|
|
203
|
-
*/
|
|
204
|
-
floaterProps?: Partial<Props$1>;
|
|
205
190
|
/**
|
|
206
191
|
* Hide the Back button.
|
|
207
192
|
* @default false
|
|
@@ -383,10 +368,6 @@ type Step = Simplify<BaseProps & {
|
|
|
383
368
|
* @default click
|
|
384
369
|
*/
|
|
385
370
|
event?: 'click' | 'hover';
|
|
386
|
-
/**
|
|
387
|
-
* Options to be passed to react-floater
|
|
388
|
-
*/
|
|
389
|
-
floaterProps?: Props$1;
|
|
390
371
|
/**
|
|
391
372
|
* Hide the tooltip's footer.
|
|
392
373
|
* @default false
|
|
@@ -493,4 +474,4 @@ type TooltipRenderProps = Simplify<BeaconRenderProps & {
|
|
|
493
474
|
|
|
494
475
|
declare function Joyride(inputProps: Props): react_jsx_runtime.JSX.Element | null;
|
|
495
476
|
|
|
496
|
-
export { ACTIONS, type Actions, type AnyObject, type BaseProps, type BeaconProps, type BeaconRenderProps, type CallBackProps, type Callback, EVENTS, type Events, LIFECYCLE, type Lifecycle, type Locale, type NarrowPlainObject, ORIGIN, type Origin, type OverlayProps, type Placement, type Props, STATUS, type State, type Status, type Step, type StepMerged, type StepProps, type StoreHelpers, type StoreOptions, type Styles, type StylesOptions, type
|
|
477
|
+
export { ACTIONS, type Actions, type AnyObject, type BaseProps, type BeaconProps, type BeaconRenderProps, type CallBackProps, type Callback, EVENTS, type Events, LIFECYCLE, type Lifecycle, type Locale, type NarrowPlainObject, ORIGIN, type Origin, type OverlayProps, type Placement, type Props, STATUS, type State, type Status, type Step, type StepMerged, type StepProps, type StoreHelpers, type StoreOptions, type Styles, type StylesOptions, type TooltipProps, type TooltipRenderProps, Joyride as default };
|
package/dist/index.js
CHANGED
|
@@ -89,7 +89,7 @@ var STATUS = {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
// src/components/index.tsx
|
|
92
|
-
var
|
|
92
|
+
var import_react7 = require("react");
|
|
93
93
|
var import_deep_equal = __toESM(require("@gilbarbara/deep-equal"));
|
|
94
94
|
var import_is_lite6 = __toESM(require("is-lite"));
|
|
95
95
|
var import_tree_changes3 = __toESM(require("tree-changes"));
|
|
@@ -420,12 +420,6 @@ var import_deepmerge2 = __toESM(require("deepmerge"));
|
|
|
420
420
|
var import_is_lite2 = __toESM(require("is-lite"));
|
|
421
421
|
|
|
422
422
|
// src/defaults.ts
|
|
423
|
-
var defaultFloaterProps = {
|
|
424
|
-
wrapperOptions: {
|
|
425
|
-
offset: -18,
|
|
426
|
-
position: true
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
423
|
var defaultLocale = {
|
|
430
424
|
back: "Back",
|
|
431
425
|
close: "Close",
|
|
@@ -505,10 +499,9 @@ var spotlight = {
|
|
|
505
499
|
position: "absolute"
|
|
506
500
|
};
|
|
507
501
|
function getStyles(props, step) {
|
|
508
|
-
var _a
|
|
509
|
-
const {
|
|
510
|
-
const
|
|
511
|
-
const mergedStyles = (0, import_deepmerge.default)(styles != null ? styles : {}, (_b = step.styles) != null ? _b : {});
|
|
502
|
+
var _a;
|
|
503
|
+
const { styles } = props;
|
|
504
|
+
const mergedStyles = (0, import_deepmerge.default)(styles != null ? styles : {}, (_a = step.styles) != null ? _a : {});
|
|
512
505
|
const options = (0, import_deepmerge.default)(defaultOptions, mergedStyles.options || {});
|
|
513
506
|
const hideBeacon2 = step.placement === "center" || step.disableBeacon;
|
|
514
507
|
let { width } = options;
|
|
@@ -642,14 +635,6 @@ function getStyles(props, step) {
|
|
|
642
635
|
...spotlight,
|
|
643
636
|
boxShadow: `0 0 0 9999px ${options.overlayColor}, ${options.spotlightShadow}`
|
|
644
637
|
},
|
|
645
|
-
floaterStyles: {
|
|
646
|
-
arrow: {
|
|
647
|
-
color: (_e = (_d = (_c = mergedFloaterProps == null ? void 0 : mergedFloaterProps.styles) == null ? void 0 : _c.arrow) == null ? void 0 : _d.color) != null ? _e : options.arrowColor
|
|
648
|
-
},
|
|
649
|
-
options: {
|
|
650
|
-
zIndex: options.zIndex + 100
|
|
651
|
-
}
|
|
652
|
-
},
|
|
653
638
|
options
|
|
654
639
|
};
|
|
655
640
|
return (0, import_deepmerge.default)(defaultStyles, mergedStyles);
|
|
@@ -665,7 +650,6 @@ function getTourProps(props) {
|
|
|
665
650
|
"disableOverlayClose",
|
|
666
651
|
"disableScrolling",
|
|
667
652
|
"disableScrollParentFix",
|
|
668
|
-
"floaterProps",
|
|
669
653
|
"hideBackButton",
|
|
670
654
|
"hideCloseButton",
|
|
671
655
|
"locale",
|
|
@@ -678,38 +662,16 @@ function getTourProps(props) {
|
|
|
678
662
|
);
|
|
679
663
|
}
|
|
680
664
|
function getMergedStep(props, currentStep) {
|
|
681
|
-
var _a
|
|
665
|
+
var _a;
|
|
682
666
|
const step = currentStep != null ? currentStep : {};
|
|
683
667
|
const mergedStep = import_deepmerge2.default.all([defaultStep, getTourProps(props), step], {
|
|
684
668
|
isMergeableObject: import_is_lite2.default.plainObject
|
|
685
669
|
});
|
|
686
670
|
const mergedStyles = getStyles(props, mergedStep);
|
|
687
|
-
const scrollParent2 = hasCustomScrollParent(
|
|
688
|
-
getElement(mergedStep.target),
|
|
689
|
-
mergedStep.disableScrollParentFix
|
|
690
|
-
);
|
|
691
|
-
const floaterProps = import_deepmerge2.default.all([
|
|
692
|
-
defaultFloaterProps,
|
|
693
|
-
(_a = props.floaterProps) != null ? _a : {},
|
|
694
|
-
(_b = mergedStep.floaterProps) != null ? _b : {}
|
|
695
|
-
]);
|
|
696
|
-
floaterProps.offset = mergedStep.offset;
|
|
697
|
-
floaterProps.styles = (0, import_deepmerge2.default)((_c = floaterProps.styles) != null ? _c : {}, mergedStyles.floaterStyles);
|
|
698
|
-
floaterProps.offset += (_e = (_d = props.spotlightPadding) != null ? _d : mergedStep.spotlightPadding) != null ? _e : 0;
|
|
699
|
-
if (mergedStep.placementBeacon && floaterProps.wrapperOptions) {
|
|
700
|
-
floaterProps.wrapperOptions.placement = mergedStep.placementBeacon;
|
|
701
|
-
}
|
|
702
|
-
if (scrollParent2 && ((_f = floaterProps.modifiers) == null ? void 0 : _f.preventOverflow)) {
|
|
703
|
-
floaterProps.modifiers.preventOverflow.options = {
|
|
704
|
-
...floaterProps.modifiers.preventOverflow.options,
|
|
705
|
-
boundary: "window"
|
|
706
|
-
};
|
|
707
|
-
}
|
|
708
671
|
return {
|
|
709
672
|
...mergedStep,
|
|
710
|
-
locale: import_deepmerge2.default.all([defaultLocale, (
|
|
711
|
-
|
|
712
|
-
styles: omit(mergedStyles, "floaterStyles")
|
|
673
|
+
locale: import_deepmerge2.default.all([defaultLocale, (_a = props.locale) != null ? _a : {}, mergedStep.locale || {}]),
|
|
674
|
+
styles: mergedStyles
|
|
713
675
|
};
|
|
714
676
|
}
|
|
715
677
|
function validateStep(step, debug = false) {
|
|
@@ -777,23 +739,6 @@ var Store = class {
|
|
|
777
739
|
}
|
|
778
740
|
this.setState(state);
|
|
779
741
|
};
|
|
780
|
-
this.getPopper = (name) => {
|
|
781
|
-
if (name === "beacon") {
|
|
782
|
-
return this.beaconPopper;
|
|
783
|
-
}
|
|
784
|
-
return this.tooltipPopper;
|
|
785
|
-
};
|
|
786
|
-
this.setPopper = (name, popper) => {
|
|
787
|
-
if (name === "beacon") {
|
|
788
|
-
this.beaconPopper = popper;
|
|
789
|
-
} else {
|
|
790
|
-
this.tooltipPopper = popper;
|
|
791
|
-
}
|
|
792
|
-
};
|
|
793
|
-
this.cleanupPoppers = () => {
|
|
794
|
-
this.beaconPopper = null;
|
|
795
|
-
this.tooltipPopper = null;
|
|
796
|
-
};
|
|
797
742
|
this.close = (origin = null) => {
|
|
798
743
|
const { index, status } = this.getState();
|
|
799
744
|
if (status !== STATUS.RUNNING) {
|
|
@@ -914,8 +859,6 @@ var Store = class {
|
|
|
914
859
|
},
|
|
915
860
|
true
|
|
916
861
|
);
|
|
917
|
-
this.beaconPopper = null;
|
|
918
|
-
this.tooltipPopper = null;
|
|
919
862
|
this.listener = null;
|
|
920
863
|
this.setSteps(steps);
|
|
921
864
|
}
|
|
@@ -1224,7 +1167,7 @@ function JoyridePortal({ children, id }) {
|
|
|
1224
1167
|
|
|
1225
1168
|
// src/components/Step.tsx
|
|
1226
1169
|
var import_react5 = require("react");
|
|
1227
|
-
var
|
|
1170
|
+
var import_react6 = require("@floating-ui/react");
|
|
1228
1171
|
var import_is_lite5 = __toESM(require("is-lite"));
|
|
1229
1172
|
var import_tree_changes2 = __toESM(require("tree-changes"));
|
|
1230
1173
|
|
|
@@ -1639,8 +1582,9 @@ function JoyrideTooltip(props) {
|
|
|
1639
1582
|
|
|
1640
1583
|
// src/components/Step.tsx
|
|
1641
1584
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1585
|
+
var ARROW_SIZE = 10;
|
|
1642
1586
|
function JoyrideStep(props) {
|
|
1643
|
-
var _a;
|
|
1587
|
+
var _a, _b, _c, _d, _e;
|
|
1644
1588
|
const {
|
|
1645
1589
|
action,
|
|
1646
1590
|
callback,
|
|
@@ -1660,32 +1604,42 @@ function JoyrideStep(props) {
|
|
|
1660
1604
|
const scopeRef = (0, import_react5.useRef)(null);
|
|
1661
1605
|
const tooltipRef = (0, import_react5.useRef)(null);
|
|
1662
1606
|
const previousPropsRef = (0, import_react5.useRef)(props);
|
|
1607
|
+
const arrowRef = (0, import_react5.useRef)(null);
|
|
1663
1608
|
const setTooltipRef = (0, import_react5.useCallback)((element) => {
|
|
1664
1609
|
tooltipRef.current = element;
|
|
1665
1610
|
}, []);
|
|
1666
|
-
const handleClickHoverBeacon = (0, import_react5.useCallback)(
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1611
|
+
const handleClickHoverBeacon = (0, import_react5.useCallback)(
|
|
1612
|
+
(event) => {
|
|
1613
|
+
if (event.type === "mouseenter" && step.event !== "hover") {
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
store.update({ lifecycle: LIFECYCLE.TOOLTIP });
|
|
1617
|
+
},
|
|
1618
|
+
[step.event, store]
|
|
1619
|
+
);
|
|
1620
|
+
const target = getElement(step.target);
|
|
1621
|
+
const isOpen = hideBeacon(step) || lifecycle === LIFECYCLE.TOOLTIP;
|
|
1622
|
+
const isCentered = step.placement === "center";
|
|
1623
|
+
const floatingPlacement = isCentered || step.placement === "auto" ? "bottom" : step.placement;
|
|
1624
|
+
const totalOffset = isOpen ? step.offset + ((_a = step.spotlightPadding) != null ? _a : 0) : step.offset;
|
|
1625
|
+
const {
|
|
1626
|
+
refs,
|
|
1627
|
+
floatingStyles,
|
|
1628
|
+
middlewareData,
|
|
1629
|
+
placement: computedPlacement
|
|
1630
|
+
} = (0, import_react6.useFloating)({
|
|
1631
|
+
placement: floatingPlacement,
|
|
1632
|
+
elements: {
|
|
1633
|
+
reference: target
|
|
1634
|
+
},
|
|
1635
|
+
middleware: [
|
|
1636
|
+
(0, import_react6.offset)(totalOffset),
|
|
1637
|
+
(0, import_react6.flip)(),
|
|
1638
|
+
(0, import_react6.shift)({ padding: 5 }),
|
|
1639
|
+
(0, import_react6.arrow)({ element: arrowRef })
|
|
1640
|
+
],
|
|
1641
|
+
whileElementsMounted: import_react6.autoUpdate
|
|
1642
|
+
});
|
|
1689
1643
|
(0, import_react5.useEffect)(() => {
|
|
1690
1644
|
log({
|
|
1691
1645
|
title: `step:${index}`,
|
|
@@ -1699,6 +1653,14 @@ function JoyrideStep(props) {
|
|
|
1699
1653
|
(_a2 = scopeRef.current) == null ? void 0 : _a2.removeScope();
|
|
1700
1654
|
};
|
|
1701
1655
|
}, []);
|
|
1656
|
+
(0, import_react5.useEffect)(() => {
|
|
1657
|
+
if (target && lifecycle === LIFECYCLE.INIT) {
|
|
1658
|
+
store.update({
|
|
1659
|
+
action,
|
|
1660
|
+
lifecycle: LIFECYCLE.READY
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
}, [target, lifecycle, action, store]);
|
|
1702
1664
|
(0, import_react5.useEffect)(() => {
|
|
1703
1665
|
var _a2;
|
|
1704
1666
|
const previousProps = previousPropsRef.current;
|
|
@@ -1782,57 +1744,116 @@ function JoyrideStep(props) {
|
|
|
1782
1744
|
}
|
|
1783
1745
|
if (changedFrom("lifecycle", [LIFECYCLE.TOOLTIP, LIFECYCLE.INIT], LIFECYCLE.INIT)) {
|
|
1784
1746
|
(_a2 = scopeRef.current) == null ? void 0 : _a2.removeScope();
|
|
1785
|
-
store.cleanupPoppers();
|
|
1786
1747
|
}
|
|
1787
1748
|
previousPropsRef.current = props;
|
|
1788
1749
|
});
|
|
1789
|
-
const target = getElement(step.target);
|
|
1790
1750
|
if (!validateStep(step) || !import_is_lite5.default.domElement(target)) {
|
|
1791
1751
|
return null;
|
|
1792
1752
|
}
|
|
1793
|
-
const
|
|
1794
|
-
const
|
|
1795
|
-
|
|
1796
|
-
{
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1753
|
+
const zIndex = ((_b = step.styles.options.zIndex) != null ? _b : 100) + 100;
|
|
1754
|
+
const arrowColor = (_c = step.styles.options.arrowColor) != null ? _c : "#fff";
|
|
1755
|
+
if (isCentered && isOpen) {
|
|
1756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "react-joyride__step", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1757
|
+
"div",
|
|
1758
|
+
{
|
|
1759
|
+
style: {
|
|
1760
|
+
position: "fixed",
|
|
1761
|
+
top: "50%",
|
|
1762
|
+
left: "50%",
|
|
1763
|
+
transform: "translate(-50%, -50%)",
|
|
1764
|
+
zIndex
|
|
1765
|
+
},
|
|
1766
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1767
|
+
JoyrideTooltip,
|
|
1768
|
+
{
|
|
1769
|
+
continuous,
|
|
1770
|
+
helpers,
|
|
1771
|
+
index,
|
|
1772
|
+
isLastStep: index + 1 === size,
|
|
1773
|
+
setTooltipRef,
|
|
1774
|
+
size,
|
|
1775
|
+
step
|
|
1776
|
+
}
|
|
1777
|
+
)
|
|
1778
|
+
}
|
|
1779
|
+
) }, `JoyrideStep-${index}`);
|
|
1780
|
+
}
|
|
1781
|
+
if (isCentered) {
|
|
1782
|
+
return null;
|
|
1783
|
+
}
|
|
1784
|
+
const arrowSide = computedPlacement.split("-")[0];
|
|
1785
|
+
const staticSide = { top: "bottom", right: "left", bottom: "top", left: "right" }[arrowSide];
|
|
1786
|
+
const arrowStyles = {
|
|
1787
|
+
position: "absolute",
|
|
1788
|
+
width: 0,
|
|
1789
|
+
height: 0,
|
|
1790
|
+
borderStyle: "solid",
|
|
1791
|
+
pointerEvents: "none",
|
|
1792
|
+
...((_d = middlewareData.arrow) == null ? void 0 : _d.x) != null ? { left: middlewareData.arrow.x } : {},
|
|
1793
|
+
...((_e = middlewareData.arrow) == null ? void 0 : _e.y) != null ? { top: middlewareData.arrow.y } : {},
|
|
1794
|
+
[staticSide]: -ARROW_SIZE
|
|
1795
|
+
};
|
|
1796
|
+
switch (arrowSide) {
|
|
1797
|
+
case "top":
|
|
1798
|
+
arrowStyles.borderWidth = `${ARROW_SIZE}px ${ARROW_SIZE}px 0`;
|
|
1799
|
+
arrowStyles.borderColor = `${arrowColor} transparent transparent`;
|
|
1800
|
+
break;
|
|
1801
|
+
case "bottom":
|
|
1802
|
+
arrowStyles.borderWidth = `0 ${ARROW_SIZE}px ${ARROW_SIZE}px`;
|
|
1803
|
+
arrowStyles.borderColor = `transparent transparent ${arrowColor}`;
|
|
1804
|
+
break;
|
|
1805
|
+
case "left":
|
|
1806
|
+
arrowStyles.borderWidth = `${ARROW_SIZE}px 0 ${ARROW_SIZE}px ${ARROW_SIZE}px`;
|
|
1807
|
+
arrowStyles.borderColor = `transparent transparent transparent ${arrowColor}`;
|
|
1808
|
+
break;
|
|
1809
|
+
case "right":
|
|
1810
|
+
arrowStyles.borderWidth = `${ARROW_SIZE}px ${ARROW_SIZE}px ${ARROW_SIZE}px 0`;
|
|
1811
|
+
arrowStyles.borderColor = `transparent ${arrowColor} transparent transparent`;
|
|
1812
|
+
break;
|
|
1813
|
+
}
|
|
1814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "react-joyride__step", children: [
|
|
1815
|
+
!isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: refs.setFloating, style: floatingStyles, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1816
|
+
JoyrideBeacon,
|
|
1817
|
+
{
|
|
1818
|
+
beaconComponent: step.beaconComponent,
|
|
1819
|
+
continuous,
|
|
1820
|
+
index,
|
|
1821
|
+
isLastStep: index + 1 === size,
|
|
1822
|
+
locale: step.locale,
|
|
1823
|
+
nonce,
|
|
1824
|
+
onClickOrHover: handleClickHoverBeacon,
|
|
1825
|
+
shouldFocus: shouldScroll2,
|
|
1826
|
+
size,
|
|
1827
|
+
step,
|
|
1828
|
+
styles: step.styles
|
|
1829
|
+
}
|
|
1830
|
+
) }),
|
|
1831
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1832
|
+
"div",
|
|
1833
|
+
{
|
|
1834
|
+
ref: refs.setFloating,
|
|
1835
|
+
style: {
|
|
1836
|
+
...floatingStyles,
|
|
1837
|
+
zIndex
|
|
1838
|
+
},
|
|
1839
|
+
children: [
|
|
1840
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1841
|
+
JoyrideTooltip,
|
|
1842
|
+
{
|
|
1843
|
+
continuous,
|
|
1844
|
+
helpers,
|
|
1845
|
+
index,
|
|
1846
|
+
isLastStep: index + 1 === size,
|
|
1847
|
+
setTooltipRef,
|
|
1848
|
+
size,
|
|
1849
|
+
step
|
|
1850
|
+
}
|
|
1851
|
+
),
|
|
1852
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: arrowRef, style: arrowStyles })
|
|
1853
|
+
]
|
|
1854
|
+
}
|
|
1855
|
+
)
|
|
1856
|
+
] }, `JoyrideStep-${index}`);
|
|
1836
1857
|
}
|
|
1837
1858
|
|
|
1838
1859
|
// src/components/index.tsx
|
|
@@ -1872,20 +1893,20 @@ function Joyride(inputProps) {
|
|
|
1872
1893
|
stepIndex,
|
|
1873
1894
|
steps
|
|
1874
1895
|
} = props;
|
|
1875
|
-
const storeRef = (0,
|
|
1896
|
+
const storeRef = (0, import_react7.useRef)(
|
|
1876
1897
|
createStore({
|
|
1877
1898
|
...props,
|
|
1878
1899
|
controlled: run && import_is_lite6.default.number(stepIndex)
|
|
1879
1900
|
})
|
|
1880
1901
|
);
|
|
1881
|
-
const helpersRef = (0,
|
|
1882
|
-
const [state, setState] = (0,
|
|
1883
|
-
const previousStateRef = (0,
|
|
1884
|
-
const previousPropsRef = (0,
|
|
1885
|
-
const mountedRef = (0,
|
|
1902
|
+
const helpersRef = (0, import_react7.useRef)(storeRef.current.getHelpers());
|
|
1903
|
+
const [state, setState] = (0, import_react7.useState)(storeRef.current.getState());
|
|
1904
|
+
const previousStateRef = (0, import_react7.useRef)(state);
|
|
1905
|
+
const previousPropsRef = (0, import_react7.useRef)(props);
|
|
1906
|
+
const mountedRef = (0, import_react7.useRef)(false);
|
|
1886
1907
|
const store = storeRef.current;
|
|
1887
1908
|
const helpers = helpersRef.current;
|
|
1888
|
-
const triggerCallback = (0,
|
|
1909
|
+
const triggerCallback = (0, import_react7.useCallback)(
|
|
1889
1910
|
(data) => {
|
|
1890
1911
|
if (import_is_lite6.default.function(callbackProp)) {
|
|
1891
1912
|
callbackProp(data);
|
|
@@ -1893,7 +1914,7 @@ function Joyride(inputProps) {
|
|
|
1893
1914
|
},
|
|
1894
1915
|
[callbackProp]
|
|
1895
1916
|
);
|
|
1896
|
-
const handleKeyboard = (0,
|
|
1917
|
+
const handleKeyboard = (0, import_react7.useCallback)(
|
|
1897
1918
|
(event) => {
|
|
1898
1919
|
const { index: currentIndex, lifecycle: lifecycle2 } = storeRef.current.getState();
|
|
1899
1920
|
const currentSteps = props.steps;
|
|
@@ -1906,14 +1927,14 @@ function Joyride(inputProps) {
|
|
|
1906
1927
|
},
|
|
1907
1928
|
[props.steps]
|
|
1908
1929
|
);
|
|
1909
|
-
const handleClickOverlay = (0,
|
|
1930
|
+
const handleClickOverlay = (0, import_react7.useCallback)(() => {
|
|
1910
1931
|
const currentState = storeRef.current.getState();
|
|
1911
1932
|
const step = getMergedStep(props, steps[currentState.index]);
|
|
1912
1933
|
if (!step.disableOverlayClose) {
|
|
1913
1934
|
helpers.close("overlay");
|
|
1914
1935
|
}
|
|
1915
1936
|
}, [props, steps, helpers]);
|
|
1916
|
-
(0,
|
|
1937
|
+
(0, import_react7.useEffect)(() => {
|
|
1917
1938
|
store.addListener(setState);
|
|
1918
1939
|
log({
|
|
1919
1940
|
title: "init",
|
|
@@ -1927,7 +1948,7 @@ function Joyride(inputProps) {
|
|
|
1927
1948
|
getHelpers(helpers);
|
|
1928
1949
|
}
|
|
1929
1950
|
}, []);
|
|
1930
|
-
(0,
|
|
1951
|
+
(0, import_react7.useEffect)(() => {
|
|
1931
1952
|
if (!canUseDOM()) {
|
|
1932
1953
|
return;
|
|
1933
1954
|
}
|
|
@@ -1944,7 +1965,7 @@ function Joyride(inputProps) {
|
|
|
1944
1965
|
}
|
|
1945
1966
|
};
|
|
1946
1967
|
}, []);
|
|
1947
|
-
(0,
|
|
1968
|
+
(0, import_react7.useEffect)(() => {
|
|
1948
1969
|
if (!mountedRef.current || !canUseDOM()) {
|
|
1949
1970
|
return;
|
|
1950
1971
|
}
|
|
@@ -1987,7 +2008,7 @@ function Joyride(inputProps) {
|
|
|
1987
2008
|
}
|
|
1988
2009
|
previousPropsRef.current = props;
|
|
1989
2010
|
});
|
|
1990
|
-
(0,
|
|
2011
|
+
(0, import_react7.useEffect)(() => {
|
|
1991
2012
|
if (!mountedRef.current || !canUseDOM()) {
|
|
1992
2013
|
return;
|
|
1993
2014
|
}
|
|
@@ -2059,7 +2080,6 @@ function Joyride(inputProps) {
|
|
|
2059
2080
|
previousStateRef.current = state;
|
|
2060
2081
|
});
|
|
2061
2082
|
function scrollToStep(previousState) {
|
|
2062
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
2063
2083
|
const { index: index2, lifecycle: lifecycle2, status: status2 } = state;
|
|
2064
2084
|
const {
|
|
2065
2085
|
disableScrollParentFix = false
|
|
@@ -2087,34 +2107,10 @@ function Joyride(inputProps) {
|
|
|
2087
2107
|
],
|
|
2088
2108
|
debug
|
|
2089
2109
|
});
|
|
2090
|
-
|
|
2091
|
-
const tooltipPopper = store.getPopper("tooltip");
|
|
2092
|
-
if (lifecycle2 === LIFECYCLE.BEACON && beaconPopper) {
|
|
2093
|
-
const placement = (_b = (_a = beaconPopper.state) == null ? void 0 : _a.placement) != null ? _b : "";
|
|
2094
|
-
const popperTop = (_f = (_e = (_d = (_c = beaconPopper.state) == null ? void 0 : _c.rects) == null ? void 0 : _d.popper) == null ? void 0 : _e.y) != null ? _f : 0;
|
|
2095
|
-
if (!["bottom"].includes(placement) && !hasCustomScroll) {
|
|
2096
|
-
scrollY = Math.floor(popperTop - scrollOffset);
|
|
2097
|
-
}
|
|
2098
|
-
} else if (lifecycle2 === LIFECYCLE.TOOLTIP && tooltipPopper) {
|
|
2099
|
-
const placement = (_h = (_g = tooltipPopper.state) == null ? void 0 : _g.placement) != null ? _h : "";
|
|
2100
|
-
const popperTop = (_l = (_k = (_j = (_i = tooltipPopper.state) == null ? void 0 : _i.rects) == null ? void 0 : _j.popper) == null ? void 0 : _k.y) != null ? _l : 0;
|
|
2101
|
-
const flipped = ((_o = (_n = (_m = tooltipPopper.state) == null ? void 0 : _m.modifiersData) == null ? void 0 : _n.flip) == null ? void 0 : _o.overflows) != null;
|
|
2102
|
-
if (["top", "right", "left"].includes(placement) && !flipped && !hasCustomScroll) {
|
|
2103
|
-
scrollY = Math.floor(popperTop - scrollOffset);
|
|
2104
|
-
} else {
|
|
2105
|
-
scrollY -= step.spotlightPadding;
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2110
|
+
scrollY -= step.spotlightPadding;
|
|
2108
2111
|
scrollY = scrollY >= 0 ? scrollY : 0;
|
|
2109
2112
|
if (status2 === STATUS.RUNNING) {
|
|
2110
|
-
scrollTo(scrollY, { element: scrollParent2, duration: scrollDuration })
|
|
2111
|
-
() => {
|
|
2112
|
-
setTimeout(() => {
|
|
2113
|
-
var _a2;
|
|
2114
|
-
(_a2 = store.getPopper("tooltip")) == null ? void 0 : _a2.update();
|
|
2115
|
-
}, 10);
|
|
2116
|
-
}
|
|
2117
|
-
);
|
|
2113
|
+
scrollTo(scrollY, { element: scrollParent2, duration: scrollDuration });
|
|
2118
2114
|
}
|
|
2119
2115
|
}
|
|
2120
2116
|
}
|