diff --git a/src/lib/boarding-types.ts b/src/lib/boarding-types.ts index 9eeea74..7b9be87 100644 --- a/src/lib/boarding-types.ts +++ b/src/lib/boarding-types.ts @@ -1,7 +1,4 @@ -import { - HighlightElementStepLevelOptions, - HighlightElementTopLevelOptions, -} from "./core/highlight-element"; +import { HighlightElementHybridOptions } from "./core/highlight-element"; import { OverlayTopLevelOptions } from "./core/overlay"; import { PopoverHybridOptions, @@ -33,7 +30,7 @@ export interface BoardingOptions OverlayTopLevelOptions, PopoverHybridOptions, PopoverTopLevelOptions, - HighlightElementTopLevelOptions { + HighlightElementHybridOptions { /** * Whether to allow controlling steps through keyboard * @default true @@ -60,8 +57,7 @@ export interface BoardingOptions className?: string; } -export interface BoardingStepDefinition - extends HighlightElementStepLevelOptions { +export interface BoardingStepDefinition extends HighlightElementHybridOptions { /** * Query selector representing the DOM Element */ diff --git a/src/lib/boarding.ts b/src/lib/boarding.ts index 25e4eeb..b5f8c5f 100644 --- a/src/lib/boarding.ts +++ b/src/lib/boarding.ts @@ -454,12 +454,13 @@ class Boarding { highlightDomElement: domElement, options: { scrollIntoViewOptions: this.options.scrollIntoViewOptions, - onHighlightStarted: this.options.onHighlightStarted, - onHighlighted: this.options.onHighlighted, - onDeselected: this.options.onDeselected, - onNext: currentStep.onNext, - onPrevious: currentStep.onPrevious, - padding: currentStep.padding, + onHighlightStarted: + currentStep.onHighlightStarted || this.options.onHighlightStarted, + onHighlighted: currentStep.onHighlighted || this.options.onHighlighted, + onDeselected: currentStep.onDeselected || this.options.onDeselected, + onNext: currentStep.onNext || this.options.onNext, + onPrevious: currentStep.onPrevious || this.options.onPrevious, + padding: currentStep.padding, // note this is ONLY the stepLvl padding, the "custom padding", so we can later check if it exists using getCustomPadding }, popover, }); diff --git a/src/lib/core/highlight-element.ts b/src/lib/core/highlight-element.ts index b315f34..8afcf56 100644 --- a/src/lib/core/highlight-element.ts +++ b/src/lib/core/highlight-element.ts @@ -8,8 +8,9 @@ type HighlightElementSupportedSharedOptions = Pick< "scrollIntoViewOptions" >; -/** The options of highlight-element that will come from the top-level */ -export interface HighlightElementTopLevelOptions { +/** The options of popover that will come from the top-level but can also be overwritten */ +export interface HighlightElementHybridOptions + extends Partial> { /** * Callback to be called when element is about to be highlighted */ @@ -22,11 +23,6 @@ export interface HighlightElementTopLevelOptions { * Callback to be called when element has been deselected */ onDeselected?: (element: HighlightElement) => void; -} - -/** The options of highlight-element that will be defined on a step-level */ -export interface HighlightElementStepLevelOptions - extends Partial> { /** * Is called when the next element is about to be highlighted */ @@ -36,10 +32,8 @@ export interface HighlightElementStepLevelOptions */ onPrevious?: (element: HighlightElement) => void; } - interface HighlightElementOptions - extends HighlightElementTopLevelOptions, - HighlightElementStepLevelOptions, + extends HighlightElementHybridOptions, HighlightElementSupportedSharedOptions {} /**