Skip to content

Commit fdf324c

Browse files
committed
fix: expose renderTooltip option in createTour DSL
The Tour type already defined renderTooltip?: TooltipRenderer but createTour() did not accept or propagate it, making the global custom tooltip renderer inaccessible via the DSL. - Add renderTooltip to createTour opts parameter - Import TooltipRenderer type in createTour.ts - Add test coverage for the new option Closes #25
1 parent ee916de commit fdf324c

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

.changeset/wacky-singers-glow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@edwardloopez/react-native-coachmark': patch
3+
---
4+
5+
fix: expose `renderTooltip` option in `createTour` DSL

src/__tests__/createTour.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,13 @@ describe('createTour', () => {
7979
expect(tour.key).toBe('test-tour');
8080
expect(tour.steps).toEqual(mockSteps);
8181
});
82+
83+
it('should create a tour with renderTooltip option', () => {
84+
const mockRenderer = jest.fn();
85+
const tour = createTour('test-tour', mockSteps, {
86+
renderTooltip: mockRenderer,
87+
});
88+
89+
expect(tour.renderTooltip).toBe(mockRenderer);
90+
});
8291
});

src/core/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export type TourStep = {
4545
onBeforeEnter?: () => Promise<boolean | void>;
4646
onEnter?: () => void;
4747
onExit?: () => void;
48-
// Custom tooltip renderer
4948
renderTooltip?: TooltipRenderer;
5049
};
5150

src/dsl/createTour.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Tour, TourStep } from '../core/types';
1+
import type { Tour, TourStep, TooltipRenderer } from '../core/types';
22

33
/**
44
* Creates a tour configuration object with the specified steps and options.
@@ -8,6 +8,7 @@ import type { Tour, TourStep } from '../core/types';
88
* @param opts - Optional configuration options for the tour
99
* @param opts.showOnce - If true, the tour will only be shown once to the user
1010
* @param opts.delay - Delay in milliseconds before the tour starts
11+
* @param opts.renderTooltip - Global custom tooltip renderer for all steps
1112
* @returns A Tour object containing the key, steps, and optional configuration
1213
*
1314
* @example
@@ -22,7 +23,13 @@ import type { Tour, TourStep } from '../core/types';
2223
export function createTour(
2324
key: string,
2425
steps: TourStep[],
25-
opts?: { showOnce?: boolean; delay?: number }
26+
opts?: { showOnce?: boolean; delay?: number; renderTooltip?: TooltipRenderer }
2627
): Tour {
27-
return { key, steps, showOnce: opts?.showOnce, delay: opts?.delay };
28+
return {
29+
key,
30+
steps,
31+
showOnce: opts?.showOnce,
32+
delay: opts?.delay,
33+
renderTooltip: opts?.renderTooltip,
34+
};
2835
}

0 commit comments

Comments
 (0)