From 2c2282140ed42624b71d3e84e186ef44a4fd0cd9 Mon Sep 17 00:00:00 2001 From: Frederic Bahr Date: Wed, 22 Jan 2025 21:19:06 +0100 Subject: [PATCH] feat: add 'data' property to DriveStep for custom logic support Before it was not possible to pass custom data to the `DriveStep` interface. This limits the possiblities within a hook to execute custom logic based on the current step. Fixes #539 --- docs/src/content/guides/configuration.mdx | 5 ++++- src/driver.ts | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/src/content/guides/configuration.mdx b/docs/src/content/guides/configuration.mdx index b598e408..0bfc2fbf 100644 --- a/docs/src/content/guides/configuration.mdx +++ b/docs/src/content/guides/configuration.mdx @@ -201,6 +201,9 @@ type DriveStep = { // Whether to disable interaction with the highlighted element. (default: false) disableActiveInteraction?: boolean; + // Arbitrary data that you can pass to the step in order to support complex custom logic in hooks. + data?: Record; + // Callback when the current step is deselected, // about to be highlighted or highlighted. // Each callback receives the following parameters: @@ -241,4 +244,4 @@ type State = { // container, title, description, buttons etc. popover?: PopoverDOM; } -``` \ No newline at end of file +``` diff --git a/src/driver.ts b/src/driver.ts index 1951c0c1..068fe3a3 100644 --- a/src/driver.ts +++ b/src/driver.ts @@ -14,6 +14,7 @@ export type DriveStep = { onDeselected?: DriverHook; popover?: Popover; disableActiveInteraction?: boolean; + data?: Record; }; export function driver(options: Config = {}) {