@tent-official/react-walkthrough 1.3.5 → 1.4.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 +17 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ Lightweight React walkthrough/tour component with auto-positioning, dependency c
|
|
|
6
6
|
|
|
7
7
|
- SVG-based spotlight overlay with smooth animated transitions
|
|
8
8
|
- Auto-positioning popover (top/bottom/left/right) with viewport detection
|
|
9
|
+
- Inner positions (`inner-top`, `inner-bottom`, `inner-left`, `inner-right`) — place the popover inside the highlight area
|
|
9
10
|
- Dependency chains — start a walkthrough only after another completes
|
|
10
11
|
- Conditional start — `startWhenCondition` prop to gate walkthrough on custom logic (e.g. data loaded)
|
|
11
12
|
- Auto-cleanup on navigation — highlight is automatically removed when the component unmounts (e.g. browser back/forward)
|
|
@@ -104,7 +105,7 @@ Hook to register a walkthrough tour.
|
|
|
104
105
|
| `el` | `string` | **required** | DOM element ID to highlight (with or without `#` prefix) |
|
|
105
106
|
| `title` | `string` | — | Popover title |
|
|
106
107
|
| `description` | `IStepDescription[]` | **required** | Description blocks |
|
|
107
|
-
| `position` | `"top" \| "bottom" \| "left" \| "right"` | auto | Preferred popover position |
|
|
108
|
+
| `position` | `"top" \| "bottom" \| "left" \| "right" \| "inner-top" \| "inner-bottom" \| "inner-left" \| "inner-right"` | auto | Preferred popover position. `inner-*` positions place the popover inside the highlight area (12 px inset) |
|
|
108
109
|
| `padding` | `number` | `8` | Padding around highlighted element (px) |
|
|
109
110
|
| `borderRadius` | `number` | `10` | Border radius of highlight cutout (px) |
|
|
110
111
|
| `width` | `number \| string` | `"auto"` | Popover width |
|
|
@@ -259,6 +260,21 @@ The popover automatically positions itself to stay within the viewport:
|
|
|
259
260
|
|
|
260
261
|
The popover also waits for the target element to be scrolled into view before appearing.
|
|
261
262
|
|
|
263
|
+
### Inner Positions
|
|
264
|
+
|
|
265
|
+
Use `inner-top`, `inner-bottom`, `inner-left`, or `inner-right` to place the popover **inside** the highlight area, inset 12 px from the corresponding edge. Inner positions never auto-fallback — they always stay exactly where specified.
|
|
266
|
+
|
|
267
|
+
This is useful when the highlighted area is large (e.g. a table or a panel) and you want the popover to appear within it rather than outside.
|
|
268
|
+
|
|
269
|
+
```jsx
|
|
270
|
+
{
|
|
271
|
+
el: "large-table",
|
|
272
|
+
title: "Table Overview",
|
|
273
|
+
description: [{ description: "Here is your data table." }],
|
|
274
|
+
position: "inner-bottom", // popover sits inside the highlight, near the bottom-right corner
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
262
278
|
## Instant Dismiss
|
|
263
279
|
|
|
264
280
|
When the user clicks **Done** on the last step (or **Skip** at any step), the highlight and popover vanish **instantly** in the same render frame — no lingering overlay or flash.
|
package/dist/index.d.mts
CHANGED
|
@@ -3,8 +3,11 @@ import { ReactNode, ReactPortal } from 'react';
|
|
|
3
3
|
/**
|
|
4
4
|
* Position of the popover relative to the target element.
|
|
5
5
|
* If the preferred position doesn't fit in the viewport, it will auto-fallback.
|
|
6
|
+
*
|
|
7
|
+
* "inner-*" positions place the popover **inside** the highlight area,
|
|
8
|
+
* inset 12 px from the corresponding edge. These never auto-fallback.
|
|
6
9
|
*/
|
|
7
|
-
type TPopoverPosition = "top" | "bottom" | "left" | "right";
|
|
10
|
+
type TPopoverPosition = "top" | "bottom" | "left" | "right" | "inner-top" | "inner-bottom" | "inner-left" | "inner-right";
|
|
8
11
|
/**
|
|
9
12
|
* Direction for description block layout.
|
|
10
13
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,11 @@ import { ReactNode, ReactPortal } from 'react';
|
|
|
3
3
|
/**
|
|
4
4
|
* Position of the popover relative to the target element.
|
|
5
5
|
* If the preferred position doesn't fit in the viewport, it will auto-fallback.
|
|
6
|
+
*
|
|
7
|
+
* "inner-*" positions place the popover **inside** the highlight area,
|
|
8
|
+
* inset 12 px from the corresponding edge. These never auto-fallback.
|
|
6
9
|
*/
|
|
7
|
-
type TPopoverPosition = "top" | "bottom" | "left" | "right";
|
|
10
|
+
type TPopoverPosition = "top" | "bottom" | "left" | "right" | "inner-top" | "inner-bottom" | "inner-left" | "inner-right";
|
|
8
11
|
/**
|
|
9
12
|
* Direction for description block layout.
|
|
10
13
|
*/
|
package/dist/index.js
CHANGED
|
@@ -531,7 +531,11 @@ var clampSize = (value, max) => {
|
|
|
531
531
|
return clamped;
|
|
532
532
|
};
|
|
533
533
|
var EDGE_MARGIN = 8;
|
|
534
|
+
var INNER_INSET = 12;
|
|
534
535
|
var choosePopoverDir = (rect, popoverW, popoverH, gap, preferred) => {
|
|
536
|
+
if (preferred && preferred.startsWith("inner-")) {
|
|
537
|
+
return { dir: preferred, align: "start", offsetX: 0, offsetY: 0 };
|
|
538
|
+
}
|
|
535
539
|
const vw = window.innerWidth;
|
|
536
540
|
const vh = window.innerHeight;
|
|
537
541
|
const space = {
|
|
@@ -1143,7 +1147,12 @@ var WalkthroughOverlay = ({
|
|
|
1143
1147
|
bottom: { top: `calc(100% + ${$popoverGap}px)`, ...hAlign },
|
|
1144
1148
|
top: { bottom: `calc(100% + ${$popoverGap}px)`, ...hAlign },
|
|
1145
1149
|
right: { left: `calc(100% + ${$popoverGap}px)`, ...vAlign },
|
|
1146
|
-
left: { right: `calc(100% + ${$popoverGap}px)`, ...vAlign }
|
|
1150
|
+
left: { right: `calc(100% + ${$popoverGap}px)`, ...vAlign },
|
|
1151
|
+
// inner-* : popover sits INSIDE the highlight rect, inset 12px from the edge
|
|
1152
|
+
"inner-bottom": { bottom: INNER_INSET, right: INNER_INSET },
|
|
1153
|
+
"inner-top": { top: INNER_INSET, right: INNER_INSET },
|
|
1154
|
+
"inner-left": { left: INNER_INSET, bottom: INNER_INSET },
|
|
1155
|
+
"inner-right": { right: INNER_INSET, bottom: INNER_INSET }
|
|
1147
1156
|
};
|
|
1148
1157
|
const maxHeightStyle = (popoverPos == null ? void 0 : popoverPos.maxHeight) != null ? { maxHeight: popoverPos.maxHeight, overflowY: "auto" } : {};
|
|
1149
1158
|
const popoverStyle = popoverReady ? {
|