@dloizides/ui-tour 1.1.2 → 1.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.1
4
+
5
+ - `toTourTheme` no longer trusts tokens to be contrast-safe: `onAccent` is white or the background, whichever contrasts more with the accent fill; the new optional `accentText` slot (step label, note, picker item) is the first primary shade reaching 4.5:1 on the caption surface (lighter first in dark, darker first in light), else the text colour. Fixes kefi dark (Next 3.05:1, label 2.75:1).
6
+
7
+ ## 1.2.0
8
+
9
+ - `vars` placeholders are filled in a step's `route` too (`/t/{tenantSlug}/register`). `expectValidTours(tours, translations, vars)` reports a route placeholder that `vars` does not fill.
10
+ - The engine counts the optional steps it skipped in a run: the caption carries `data-tour-skipped`, and `tour_finish` carries `skipped` (a number, no PII).
11
+ - `playAllToursInAuto` reads that count into `TourRunResult.skipped`; `expectAllToursPlay` fails a tour that skipped more than `maxSkippedRatio` x steps (default 0.25).
12
+
3
13
  ## 1.1.2
4
14
 
5
15
  - `expectAllToursPlay` fails when the picker lists no tours (app not mounted before F2) and when `ids` names a tour the picker does not list.
package/README.md CHANGED
@@ -59,13 +59,13 @@ Open the picker from a Help menu with `useTour().openPicker()`; F2 opens it anyw
59
59
  | `findTarget`, `isForbiddenClick` | The element finder and the write-control rule used by the engine |
60
60
  | `defaultTourLabels`, `formatLabel` | English defaults; pass translated `labels` (placeholders `{{p1}}`, `{{p2}}`) |
61
61
 
62
- A step target is a testID string (`data-testid`) or `{ role, name, nth?, exact?, within? }` with role `button`, `heading`, `group`, `field` or `text`. `{name}` placeholders in a step are filled from `vars`.
62
+ A step target is a testID string (`data-testid`) or `{ role, name, nth?, exact?, within? }` with role `button`, `heading`, `group`, `field` or `text`. `{name}` placeholders in a step's `text`, `value` and `route` are filled from `vars`.
63
63
 
64
64
  ### Theme
65
65
 
66
66
  Every colour comes from the `theme` prop; map it from your design tokens or tenant theme:
67
67
 
68
- `accent`, `onAccent`, `surface`, `onSurface`, `muted`, `scrim`, `divider`, `radius`, `fontFamily`. The font always falls back to `sans-serif` (`fontStack`).
68
+ `accent`, `onAccent`, `accentText` (optional; accent-coloured text on the caption, defaults to `accent`), `surface`, `onSurface`, `muted`, `scrim`, `divider`, `radius`, `fontFamily`. The font always falls back to `sans-serif` (`fontStack`). `toTourTheme` (`/expo`) measures contrast instead of trusting tokens: `onAccent` is white or the background, whichever contrasts more with the accent; `accentText` is the first primary shade reaching 4.5:1 on the caption (lighter first in dark), else the text colour.
69
69
 
70
70
  ### Events
71
71
 
@@ -114,7 +114,7 @@ import { TOURS } from '../tours';
114
114
  | `target` | A testID (`open-payees`) or `{ role, name, nth?, exact?, within? }` |
115
115
  | `text` | Translation key of the caption text; `{name}` placeholders come from `vars` |
116
116
  | `action` | `StepAction.Click`, `Type` (needs `value`) or `None` |
117
- | `route?` | Navigates there first |
117
+ | `route?` | Navigates there first; `{name}` placeholders come from `vars` (`/t/{tenantSlug}/register`) |
118
118
  | `optional?` | Skipped when the target is absent |
119
119
  | `wait?` | Extra wait in ms before the step |
120
120
 
@@ -131,7 +131,7 @@ import en from '../localization/locales/en.json';
131
131
  it('every tour is valid', () => expectValidTours(TOURS, en));
132
132
  ```
133
133
 
134
- It fails on a missing text key, a malformed target, a repeated id, a tour without steps or a click on a write control.
134
+ It fails on a missing text key, a malformed target, a repeated id, a tour without steps, a click on a write control or a route placeholder that `vars` does not fill. Pass the vars your routes use: `expectValidTours(TOURS, en, { tenantSlug: 'demo' })`.
135
135
 
136
136
  ```ts
137
137
  import { expectAllToursPlay } from '@dloizides/ui-tour/playwright';
@@ -139,7 +139,7 @@ import { expectAllToursPlay } from '@dloizides/ui-tour/playwright';
139
139
  test('every tour plays to the end in Auto', async ({ page }) => expectAllToursPlay(page));
140
140
  ```
141
141
 
142
- It plays every tour in the picker in Auto and fails with `tour <id> step <n>/<m>: <reason>` (target missing, stuck, closed early, never started). The caption carries `data-tour-id`, `data-tour-step` and `data-tour-steps` for runners. `expo-router` and `@playwright/test` are optional peers.
142
+ It plays every tour in the picker in Auto and fails with `tour <id> step <n>/<m>: <reason>` (target missing, stuck, closed early, never started). The caption carries `data-tour-id`, `data-tour-step`, `data-tour-steps` and `data-tour-skipped` (optional steps the engine skipped this run) for runners; `tour_finish` events carry the same `skipped` count. A tour that skipped more than `maxSkippedRatio` x its steps (default 0.25) fails: `expectAllToursPlay(page, { maxSkippedRatio: 0.5 })`. `expo-router` and `@playwright/test` are optional peers.
143
143
 
144
144
  ## License
145
145
 
@@ -39,6 +39,72 @@ function localizeTours(tours, translate) {
39
39
  steps: tour.steps.map((step) => ({ ...step, text: text(step.text) }))
40
40
  }));
41
41
  }
42
+
43
+ // src/expo/contrast.ts
44
+ var CHANNEL_MAX = 255;
45
+ var HEX_SHORT = 3;
46
+ var HEX_RADIX = 16;
47
+ var LINEAR_KNEE = 0.03928;
48
+ var LINEAR_SLOPE = 12.92;
49
+ var GAMMA_OFFSET = 0.055;
50
+ var GAMMA_SCALE = 1.055;
51
+ var GAMMA = 2.4;
52
+ var RED_WEIGHT = 0.2126;
53
+ var GREEN_WEIGHT = 0.7152;
54
+ var BLUE_WEIGHT = 0.0722;
55
+ var FLARE = 0.05;
56
+ var WHITE_KEYWORD = "white";
57
+ var RGB_PATTERN = /^rgba?\(\s*(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)/i;
58
+ var HEX_PATTERN = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
59
+ var MIN_TEXT_CONTRAST = 4.5;
60
+ function hexChannels(hex) {
61
+ const digits = hex.length === HEX_SHORT ? hex.split("").map((digit) => digit + digit).join("") : hex;
62
+ const read = (start) => parseInt(digits.slice(start, start + 2), HEX_RADIX);
63
+ return [read(0), read(2), read(4)];
64
+ }
65
+ function channels(color) {
66
+ const value = color.trim();
67
+ if (value.toLowerCase() === WHITE_KEYWORD) return [CHANNEL_MAX, CHANNEL_MAX, CHANNEL_MAX];
68
+ const hex = HEX_PATTERN.exec(value)?.[1];
69
+ if (hex !== void 0) return hexChannels(hex);
70
+ const rgb = RGB_PATTERN.exec(value);
71
+ return rgb === null ? void 0 : [Number(rgb[1] ?? 0), Number(rgb[2] ?? 0), Number(rgb[3] ?? 0)];
72
+ }
73
+ function linear(channel) {
74
+ const unit = channel / CHANNEL_MAX;
75
+ return unit <= LINEAR_KNEE ? unit / LINEAR_SLOPE : ((unit + GAMMA_OFFSET) / GAMMA_SCALE) ** GAMMA;
76
+ }
77
+ function luminance(color) {
78
+ const rgb = channels(color);
79
+ if (rgb === void 0) return void 0;
80
+ const [red, green, blue] = rgb;
81
+ return RED_WEIGHT * linear(red) + GREEN_WEIGHT * linear(green) + BLUE_WEIGHT * linear(blue);
82
+ }
83
+ function contrastRatio(first, second) {
84
+ const a = luminance(first);
85
+ const b = luminance(second);
86
+ if (a === void 0 || b === void 0) return 0;
87
+ return (Math.max(a, b) + FLARE) / (Math.min(a, b) + FLARE);
88
+ }
89
+
90
+ // src/expo/accentInk.ts
91
+ var WHITE = "white";
92
+ var WHITE_LUMINANCE = 1;
93
+ var LIGHT_FIRST = ["300", "500", "600", "700"];
94
+ var DARK_FIRST = ["700", "600", "500", "300"];
95
+ function pickOnAccent(accent, background, surface, fallback) {
96
+ if (luminance(accent) === void 0) return fallback;
97
+ const white = luminance(surface) === WHITE_LUMINANCE ? surface : WHITE;
98
+ return contrastRatio(white, accent) >= contrastRatio(background, accent) ? white : background;
99
+ }
100
+ function pickAccentText(shades, captionSurface, text, isDark, fallback) {
101
+ if (luminance(captionSurface) === void 0) return fallback;
102
+ const order = isDark ? LIGHT_FIRST : DARK_FIRST;
103
+ const passing = order.map((key) => shades[key]).find((shade) => shade !== void 0 && contrastRatio(shade, captionSurface) >= MIN_TEXT_CONTRAST);
104
+ return passing ?? text;
105
+ }
106
+
107
+ // src/expo/toTourTheme.ts
42
108
  var DARK_MODE = "dark";
43
109
  var TOUR_RADIUS = 12;
44
110
  var SCRIM_STRENGTH = "62%";
@@ -48,10 +114,12 @@ function toTourTheme(theme, dark) {
48
114
  const lightAccent = palette.primary["700"] ?? palette.primary["600"] ?? palette.primary["500"] ?? colors.text;
49
115
  const accent = isDark ? palette.primary["300"] ?? colors.text : lightAccent;
50
116
  const shade = isDark ? colors.background : colors.text;
117
+ const surface = colors.surfaceElevated ?? colors.surface;
51
118
  return {
52
119
  accent,
53
- onAccent: isDark ? colors.background : colors.surface,
54
- surface: colors.surfaceElevated ?? colors.surface,
120
+ onAccent: pickOnAccent(accent, colors.background, colors.surface, isDark ? colors.background : colors.surface),
121
+ accentText: pickAccentText(palette.primary, surface, colors.text, isDark, accent),
122
+ surface,
55
123
  onSurface: colors.text,
56
124
  muted: colors.textSecondary,
57
125
  scrim: `color-mix(in srgb, ${shade} ${SCRIM_STRENGTH}, transparent)`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/expo/AppToursContext.ts","../../src/expo/labels.ts","../../src/expo/toTourTheme.ts","../../src/expo/trackTourEvent.ts","../../src/expo/AppTours.tsx","../../src/expo/TourButton.tsx"],"names":["createContext","useContext","defaultTourLabels","fontStack","useRouter","useMemo","useCallback","jsx","jsxs","TourProvider","TourPicker","FirstRunOffer","useTour","Pressable","Text"],"mappings":";;;;;;;;;AAOO,IAAM,eAAA,GAAkBA,oBAAoC,IAAI,CAAA;AAGhE,SAAS,WAAA,GAA6B;AAC3C,EAAA,MAAM,KAAA,GAAQC,iBAAW,eAAe,CAAA;AACxC,EAAA,IAAI,KAAA,KAAU,IAAA,EAAM,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAC9E,EAAA,OAAO,KAAA;AACT;ACTO,IAAM,oBAAA,GAAuB;AAE7B,IAAM,oBAAA,GAAuB;AAAA,EAClC,QAAA,EAAU,aAAA;AAAA,EACV,YAAA,EAAc;AAChB;AAKO,SAAS,WAAA,CAAY,SAAA,EAAsB,GAAA,EAAa,QAAA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AA,EAAYX,gBAAAA,CAAU,MAAM,UAAU,CAAA,EAAE,EAAI,QAAA,EAAA,KAAA,CAAM,UAAU,CAAA,EAAE;AAAA;AAAA,GACvG;AAEJ","file":"index.js","sourcesContent":["import { createContext, useContext } from 'react';\nimport type { AppTourLabelKey } from './labels';\n\nexport interface AppToursValue {\n label: (key: AppTourLabelKey) => string;\n}\n\nexport const AppToursContext = createContext<AppToursValue | null>(null);\n\n/** Returns the kit labels; must be called inside `AppTours`. */\nexport function useAppTours(): AppToursValue {\n const value = useContext(AppToursContext);\n if (value === null) throw new Error('useAppTours must be used inside AppTours');\n return value;\n}\n","import { defaultTourLabels } from '@dloizides/ui-tour';\nimport type { Tour, TourLabels } from '@dloizides/ui-tour';\n\nexport type Translate = (key: string) => string;\n\nexport const DEFAULT_LABEL_PREFIX = 'tours.labels';\n\nexport const defaultAppTourLabels = {\n takeTour: 'Take a tour',\n takeTourHint: 'Opens the list of guided tours',\n};\n\nexport type AppTourLabelKey = keyof typeof defaultAppTourLabels;\n\n/** Translates `key`; a missing or empty translation returns `fallback`. */\nexport function translateOr(translate: Translate, key: string, fallback: string): string {\n const value = translate(key);\n return typeof value === 'string' && value !== '' && value !== key ? value : fallback;\n}\n\n/** Builds every tour label from `<prefix>.<labelName>` keys, keeping the English default for a missing key. */\nexport function buildTourLabels(translate: Translate, prefix: string = DEFAULT_LABEL_PREFIX): TourLabels {\n const names = Object.keys(defaultTourLabels) as Array<keyof TourLabels>;\n const labels: TourLabels = { ...defaultTourLabels };\n names.forEach((name) => {\n labels[name] = translateOr(translate, `${prefix}.${name}`, defaultTourLabels[name]);\n });\n return labels;\n}\n\n/** Replaces each tour title, category and step text key with its translation. */\nexport function localizeTours(tours: readonly Tour[], translate: Translate): Tour[] {\n const text = (key: string): string => translateOr(translate, key, key);\n return tours.map((tour) => ({\n ...tour,\n title: text(tour.title),\n category: text(tour.category),\n steps: tour.steps.map((step) => ({ ...step, text: text(step.text) })),\n }));\n}\n","import { fontStack } from '@dloizides/ui-tour';\nimport type { TourTheme } from '@dloizides/ui-tour';\n\nexport interface AppThemeColors {\n background: string;\n surface: string;\n surfaceElevated?: string;\n text: string;\n textSecondary: string;\n border: string;\n divider?: string;\n}\n\nexport interface AppThemeSource {\n colors: AppThemeColors;\n palette: { primary: { '300'?: string; '500'?: string; '600'?: string; '700'?: string } };\n mode?: string;\n typography?: { fontFamily?: string };\n}\n\nconst DARK_MODE = 'dark';\nconst TOUR_RADIUS = 12;\nconst SCRIM_STRENGTH = '62%';\n\n/** Maps an app theme (theme-web `ResolvedTheme` or ui-feedback theme) onto the tour colour slots. */\nexport function toTourTheme(theme: AppThemeSource, dark?: boolean): TourTheme {\n const isDark = dark ?? theme.mode === DARK_MODE;\n const { colors, palette } = theme;\n const lightAccent = palette.primary['700'] ?? palette.primary['600'] ?? palette.primary['500'] ?? colors.text;\n const accent = isDark ? palette.primary['300'] ?? colors.text : lightAccent;\n const shade = isDark ? colors.background : colors.text;\n return {\n accent,\n onAccent: isDark ? colors.background : colors.surface,\n surface: colors.surfaceElevated ?? colors.surface,\n onSurface: colors.text,\n muted: colors.textSecondary,\n scrim: `color-mix(in srgb, ${shade} ${SCRIM_STRENGTH}, transparent)`,\n divider: colors.divider ?? colors.border,\n radius: TOUR_RADIUS,\n fontFamily: fontStack(theme.typography?.fontFamily),\n };\n}\n","import type { TourEvent } from '@dloizides/ui-tour';\n\ninterface UmamiWindow {\n umami?: { track: (name: string, data?: Record<string, string>) => void };\n}\n\n/** Sends a tour event to Umami (when its script is loaded) with only the tour id and mode. */\nexport function trackTourEvent(event: TourEvent): void {\n if (typeof window === 'undefined') return;\n (window as unknown as UmamiWindow).umami?.track(event.type, { tourId: event.tourId, mode: event.mode });\n}\n","import { useCallback, useMemo } from 'react';\nimport type { ReactElement, ReactNode } from 'react';\nimport { useRouter } from 'expo-router';\nimport { FirstRunOffer, TourPicker, TourProvider } from '@dloizides/ui-tour';\nimport type { Tour, TourEvent, TourUser, TourVars } from '@dloizides/ui-tour';\nimport { AppToursContext } from './AppToursContext';\nimport type { AppToursValue } from './AppToursContext';\nimport { buildTourLabels, DEFAULT_LABEL_PREFIX, defaultAppTourLabels, localizeTours, translateOr } from './labels';\nimport type { AppTourLabelKey, Translate } from './labels';\nimport { toTourTheme } from './toTourTheme';\nimport type { AppThemeSource } from './toTourTheme';\nimport { trackTourEvent } from './trackTourEvent';\n\nexport interface AppToursProps {\n tours: readonly Tour[];\n translate: Translate;\n theme: AppThemeSource;\n dark?: boolean;\n user?: TourUser | null;\n vars?: TourVars;\n navigate?: (route: string) => void;\n labelPrefix?: string;\n allowWrites?: boolean;\n onEvent?: (event: TourEvent) => void;\n children?: ReactNode;\n}\n\n/** One-line tour setup for an Expo Router app: router, theme, translated labels, Umami events, picker and first-run card. */\nexport function AppTours(props: AppToursProps): ReactElement {\n const router = useRouter();\n const { translate, onEvent: extraEvent } = props;\n const prefix = props.labelPrefix ?? DEFAULT_LABEL_PREFIX;\n const navigate = props.navigate ?? router.push;\n const tours = useMemo(() => localizeTours(props.tours, translate), [props.tours, translate]);\n const labels = useMemo(() => buildTourLabels(translate, prefix), [translate, prefix]);\n const theme = useMemo(() => toTourTheme(props.theme, props.dark), [props.theme, props.dark]);\n const onEvent = useCallback((event: TourEvent) => {\n trackTourEvent(event);\n extraEvent?.(event);\n }, [extraEvent]);\n const appValue = useMemo<AppToursValue>(() => ({\n label: (key: AppTourLabelKey) => translateOr(translate, `${prefix}.${key}`, defaultAppTourLabels[key]),\n }), [translate, prefix]);\n return (\n <AppToursContext.Provider value={appValue}>\n <TourProvider tours={tours} navigate={navigate} theme={theme} labels={labels} user={props.user} vars={props.vars} allowWrites={props.allowWrites} onEvent={onEvent}>\n {props.children}\n <TourPicker />\n <FirstRunOffer />\n </TourProvider>\n </AppToursContext.Provider>\n );\n}\n","import type { ReactElement } from 'react';\nimport { Pressable, Text } from 'react-native';\nimport { fontStack, useTour } from '@dloizides/ui-tour';\nimport { useAppTours } from './AppToursContext';\n\nexport interface TourButtonProps {\n testID?: string;\n}\n\nconst MIN_HIT = 44;\nconst PADDING = 12;\n\n/** \"Take a tour\" button for the shell help slot; opens the tour picker (F2 does the same). */\nexport function TourButton({ testID = 'take-tour' }: TourButtonProps): ReactElement {\n const { openPicker, theme } = useTour();\n const { label } = useAppTours();\n return (\n <Pressable\n testID={testID}\n accessibilityRole=\"button\"\n accessibilityLabel={label('takeTour')}\n accessibilityHint={label('takeTourHint')}\n onPress={openPicker}\n style={{ minHeight: MIN_HIT, minWidth: MIN_HIT, paddingHorizontal: PADDING, justifyContent: 'center', borderWidth: 1, borderColor: theme.divider, borderRadius: theme.radius }}\n >\n <Text style={{ color: theme.onSurface, fontFamily: fontStack(theme.fontFamily) }}>{label('takeTour')}</Text>\n </Pressable>\n );\n}\n"]}
1
+ {"version":3,"sources":["../../src/expo/AppToursContext.ts","../../src/expo/labels.ts","../../src/expo/contrast.ts","../../src/expo/accentInk.ts","../../src/expo/toTourTheme.ts","../../src/expo/trackTourEvent.ts","../../src/expo/AppTours.tsx","../../src/expo/TourButton.tsx"],"names":["createContext","useContext","defaultTourLabels","fontStack","useRouter","useMemo","useCallback","jsx","jsxs","TourProvider","TourPicker","FirstRunOffer","useTour","Pressable","Text"],"mappings":";;;;;;;;;AAOO,IAAM,eAAA,GAAkBA,oBAAoC,IAAI,CAAA;AAGhE,SAAS,WAAA,GAA6B;AAC3C,EAAA,MAAM,KAAA,GAAQC,iBAAW,eAAe,CAAA;AACxC,EAAA,IAAI,KAAA,KAAU,IAAA,EAAM,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAC9E,EAAA,OAAO,KAAA;AACT;ACTO,IAAM,oBAAA,GAAuB;AAE7B,IAAM,oBAAA,GAAuB;AAAA,EAClC,QAAA,EAAU,aAAA;AAAA,EACV,YAAA,EAAc;AAChB;AAKO,SAAS,WAAA,CAAY,SAAA,EAAsB,GAAA,EAAa,QAAA,EAA0B;AACvF,EAAA,MAAM,KAAA,GAAQ,UAAU,GAAG,CAAA;AAC3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EAAA,KAAA,CAAM,UAAU,CAAA,EAAE;AAAA;AAAA,GACvG;AAEJ","file":"index.js","sourcesContent":["import { createContext, useContext } from 'react';\nimport type { AppTourLabelKey } from './labels';\n\nexport interface AppToursValue {\n label: (key: AppTourLabelKey) => string;\n}\n\nexport const AppToursContext = createContext<AppToursValue | null>(null);\n\n/** Returns the kit labels; must be called inside `AppTours`. */\nexport function useAppTours(): AppToursValue {\n const value = useContext(AppToursContext);\n if (value === null) throw new Error('useAppTours must be used inside AppTours');\n return value;\n}\n","import { defaultTourLabels } from '@dloizides/ui-tour';\nimport type { Tour, TourLabels } from '@dloizides/ui-tour';\n\nexport type Translate = (key: string) => string;\n\nexport const DEFAULT_LABEL_PREFIX = 'tours.labels';\n\nexport const defaultAppTourLabels = {\n takeTour: 'Take a tour',\n takeTourHint: 'Opens the list of guided tours',\n};\n\nexport type AppTourLabelKey = keyof typeof defaultAppTourLabels;\n\n/** Translates `key`; a missing or empty translation returns `fallback`. */\nexport function translateOr(translate: Translate, key: string, fallback: string): string {\n const value = translate(key);\n return typeof value === 'string' && value !== '' && value !== key ? value : fallback;\n}\n\n/** Builds every tour label from `<prefix>.<labelName>` keys, keeping the English default for a missing key. */\nexport function buildTourLabels(translate: Translate, prefix: string = DEFAULT_LABEL_PREFIX): TourLabels {\n const names = Object.keys(defaultTourLabels) as Array<keyof TourLabels>;\n const labels: TourLabels = { ...defaultTourLabels };\n names.forEach((name) => {\n labels[name] = translateOr(translate, `${prefix}.${name}`, defaultTourLabels[name]);\n });\n return labels;\n}\n\n/** Replaces each tour title, category and step text key with its translation. */\nexport function localizeTours(tours: readonly Tour[], translate: Translate): Tour[] {\n const text = (key: string): string => translateOr(translate, key, key);\n return tours.map((tour) => ({\n ...tour,\n title: text(tour.title),\n category: text(tour.category),\n steps: tour.steps.map((step) => ({ ...step, text: text(step.text) })),\n }));\n}\n","const CHANNEL_MAX = 255;\nconst HEX_SHORT = 3;\nconst HEX_RADIX = 16;\nconst LINEAR_KNEE = 0.03928;\nconst LINEAR_SLOPE = 12.92;\nconst GAMMA_OFFSET = 0.055;\nconst GAMMA_SCALE = 1.055;\nconst GAMMA = 2.4;\nconst RED_WEIGHT = 0.2126;\nconst GREEN_WEIGHT = 0.7152;\nconst BLUE_WEIGHT = 0.0722;\nconst FLARE = 0.05;\nconst WHITE_KEYWORD = 'white';\nconst RGB_PATTERN = /^rgba?\\(\\s*(\\d+(?:\\.\\d+)?)[\\s,]+(\\d+(?:\\.\\d+)?)[\\s,]+(\\d+(?:\\.\\d+)?)/i;\nconst HEX_PATTERN = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;\n\n/** Minimum WCAG AA contrast for normal-size text. */\nexport const MIN_TEXT_CONTRAST = 4.5;\n\ntype Channels = [number, number, number];\n\nfunction hexChannels(hex: string): Channels {\n const digits = hex.length === HEX_SHORT ? hex.split('').map((digit) => digit + digit).join('') : hex;\n const read = (start: number): number => parseInt(digits.slice(start, start + 2), HEX_RADIX);\n return [read(0), read(2), read(4)];\n}\n\nfunction channels(color: string): Channels | undefined {\n const value = color.trim();\n if (value.toLowerCase() === WHITE_KEYWORD) return [CHANNEL_MAX, CHANNEL_MAX, CHANNEL_MAX];\n const hex = HEX_PATTERN.exec(value)?.[1];\n if (hex !== undefined) return hexChannels(hex);\n const rgb = RGB_PATTERN.exec(value);\n return rgb === null ? undefined : [Number(rgb[1] ?? 0), Number(rgb[2] ?? 0), Number(rgb[3] ?? 0)];\n}\n\nfunction linear(channel: number): number {\n const unit = channel / CHANNEL_MAX;\n return unit <= LINEAR_KNEE ? unit / LINEAR_SLOPE : ((unit + GAMMA_OFFSET) / GAMMA_SCALE) ** GAMMA;\n}\n\n/** WCAG relative luminance of a hex, rgb or white colour, or undefined when it cannot be parsed. */\nexport function luminance(color: string): number | undefined {\n const rgb = channels(color);\n if (rgb === undefined) return undefined;\n const [red, green, blue] = rgb;\n return RED_WEIGHT * linear(red) + GREEN_WEIGHT * linear(green) + BLUE_WEIGHT * linear(blue);\n}\n\n/** WCAG contrast ratio of two hex, rgb or white colours; 0 when either cannot be parsed. */\nexport function contrastRatio(first: string, second: string): number {\n const a = luminance(first);\n const b = luminance(second);\n if (a === undefined || b === undefined) return 0;\n return (Math.max(a, b) + FLARE) / (Math.min(a, b) + FLARE);\n}\n","import { contrastRatio, luminance, MIN_TEXT_CONTRAST } from './contrast';\n\nconst WHITE = 'white';\nconst WHITE_LUMINANCE = 1;\n\ntype Shades = Partial<Record<'300' | '500' | '600' | '700', string>>;\n\nconst LIGHT_FIRST = ['300', '500', '600', '700'] as const;\nconst DARK_FIRST = ['700', '600', '500', '300'] as const;\n\n/** Picks white or the background, whichever contrasts more with the accent fill; `fallback` when the accent cannot be measured. */\nexport function pickOnAccent(accent: string, background: string, surface: string, fallback: string): string {\n if (luminance(accent) === undefined) return fallback;\n const white = luminance(surface) === WHITE_LUMINANCE ? surface : WHITE;\n return contrastRatio(white, accent) >= contrastRatio(background, accent) ? white : background;\n}\n\n/** First primary shade reaching AA on the caption surface (lighter first in dark), else the text colour; `fallback` when the surface cannot be measured. */\nexport function pickAccentText(shades: Shades, captionSurface: string, text: string, isDark: boolean, fallback: string): string {\n if (luminance(captionSurface) === undefined) return fallback;\n const order = isDark ? LIGHT_FIRST : DARK_FIRST;\n const passing = order.map((key) => shades[key]).find((shade) => shade !== undefined && contrastRatio(shade, captionSurface) >= MIN_TEXT_CONTRAST);\n return passing ?? text;\n}\n","import { fontStack } from '@dloizides/ui-tour';\nimport type { TourTheme } from '@dloizides/ui-tour';\n\nimport { pickAccentText, pickOnAccent } from './accentInk';\n\nexport interface AppThemeColors {\n background: string;\n surface: string;\n surfaceElevated?: string;\n text: string;\n textSecondary: string;\n border: string;\n divider?: string;\n}\n\nexport interface AppThemeSource {\n colors: AppThemeColors;\n palette: { primary: { '300'?: string; '500'?: string; '600'?: string; '700'?: string } };\n mode?: string;\n typography?: { fontFamily?: string };\n}\n\nconst DARK_MODE = 'dark';\nconst TOUR_RADIUS = 12;\nconst SCRIM_STRENGTH = '62%';\n\n/** Maps an app theme (theme-web `ResolvedTheme` or ui-feedback theme) onto the tour colour slots. */\nexport function toTourTheme(theme: AppThemeSource, dark?: boolean): TourTheme {\n const isDark = dark ?? theme.mode === DARK_MODE;\n const { colors, palette } = theme;\n const lightAccent = palette.primary['700'] ?? palette.primary['600'] ?? palette.primary['500'] ?? colors.text;\n const accent = isDark ? palette.primary['300'] ?? colors.text : lightAccent;\n const shade = isDark ? colors.background : colors.text;\n const surface = colors.surfaceElevated ?? colors.surface;\n return {\n accent,\n onAccent: pickOnAccent(accent, colors.background, colors.surface, isDark ? colors.background : colors.surface),\n accentText: pickAccentText(palette.primary, surface, colors.text, isDark, accent),\n surface,\n onSurface: colors.text,\n muted: colors.textSecondary,\n scrim: `color-mix(in srgb, ${shade} ${SCRIM_STRENGTH}, transparent)`,\n divider: colors.divider ?? colors.border,\n radius: TOUR_RADIUS,\n fontFamily: fontStack(theme.typography?.fontFamily),\n };\n}\n","import type { TourEvent } from '@dloizides/ui-tour';\n\ninterface UmamiWindow {\n umami?: { track: (name: string, data?: Record<string, string>) => void };\n}\n\n/** Sends a tour event to Umami (when its script is loaded) with only the tour id and mode. */\nexport function trackTourEvent(event: TourEvent): void {\n if (typeof window === 'undefined') return;\n (window as unknown as UmamiWindow).umami?.track(event.type, { tourId: event.tourId, mode: event.mode });\n}\n","import { useCallback, useMemo } from 'react';\nimport type { ReactElement, ReactNode } from 'react';\nimport { useRouter } from 'expo-router';\nimport { FirstRunOffer, TourPicker, TourProvider } from '@dloizides/ui-tour';\nimport type { Tour, TourEvent, TourUser, TourVars } from '@dloizides/ui-tour';\nimport { AppToursContext } from './AppToursContext';\nimport type { AppToursValue } from './AppToursContext';\nimport { buildTourLabels, DEFAULT_LABEL_PREFIX, defaultAppTourLabels, localizeTours, translateOr } from './labels';\nimport type { AppTourLabelKey, Translate } from './labels';\nimport { toTourTheme } from './toTourTheme';\nimport type { AppThemeSource } from './toTourTheme';\nimport { trackTourEvent } from './trackTourEvent';\n\nexport interface AppToursProps {\n tours: readonly Tour[];\n translate: Translate;\n theme: AppThemeSource;\n dark?: boolean;\n user?: TourUser | null;\n vars?: TourVars;\n navigate?: (route: string) => void;\n labelPrefix?: string;\n allowWrites?: boolean;\n onEvent?: (event: TourEvent) => void;\n children?: ReactNode;\n}\n\n/** One-line tour setup for an Expo Router app: router, theme, translated labels, Umami events, picker and first-run card. */\nexport function AppTours(props: AppToursProps): ReactElement {\n const router = useRouter();\n const { translate, onEvent: extraEvent } = props;\n const prefix = props.labelPrefix ?? DEFAULT_LABEL_PREFIX;\n const navigate = props.navigate ?? router.push;\n const tours = useMemo(() => localizeTours(props.tours, translate), [props.tours, translate]);\n const labels = useMemo(() => buildTourLabels(translate, prefix), [translate, prefix]);\n const theme = useMemo(() => toTourTheme(props.theme, props.dark), [props.theme, props.dark]);\n const onEvent = useCallback((event: TourEvent) => {\n trackTourEvent(event);\n extraEvent?.(event);\n }, [extraEvent]);\n const appValue = useMemo<AppToursValue>(() => ({\n label: (key: AppTourLabelKey) => translateOr(translate, `${prefix}.${key}`, defaultAppTourLabels[key]),\n }), [translate, prefix]);\n return (\n <AppToursContext.Provider value={appValue}>\n <TourProvider tours={tours} navigate={navigate} theme={theme} labels={labels} user={props.user} vars={props.vars} allowWrites={props.allowWrites} onEvent={onEvent}>\n {props.children}\n <TourPicker />\n <FirstRunOffer />\n </TourProvider>\n </AppToursContext.Provider>\n );\n}\n","import type { ReactElement } from 'react';\nimport { Pressable, Text } from 'react-native';\nimport { fontStack, useTour } from '@dloizides/ui-tour';\nimport { useAppTours } from './AppToursContext';\n\nexport interface TourButtonProps {\n testID?: string;\n}\n\nconst MIN_HIT = 44;\nconst PADDING = 12;\n\n/** \"Take a tour\" button for the shell help slot; opens the tour picker (F2 does the same). */\nexport function TourButton({ testID = 'take-tour' }: TourButtonProps): ReactElement {\n const { openPicker, theme } = useTour();\n const { label } = useAppTours();\n return (\n <Pressable\n testID={testID}\n accessibilityRole=\"button\"\n accessibilityLabel={label('takeTour')}\n accessibilityHint={label('takeTourHint')}\n onPress={openPicker}\n style={{ minHeight: MIN_HIT, minWidth: MIN_HIT, paddingHorizontal: PADDING, justifyContent: 'center', borderWidth: 1, borderColor: theme.divider, borderRadius: theme.radius }}\n >\n <Text style={{ color: theme.onSurface, fontFamily: fontStack(theme.fontFamily) }}>{label('takeTour')}</Text>\n </Pressable>\n );\n}\n"]}
@@ -37,6 +37,72 @@ function localizeTours(tours, translate) {
37
37
  steps: tour.steps.map((step) => ({ ...step, text: text(step.text) }))
38
38
  }));
39
39
  }
40
+
41
+ // src/expo/contrast.ts
42
+ var CHANNEL_MAX = 255;
43
+ var HEX_SHORT = 3;
44
+ var HEX_RADIX = 16;
45
+ var LINEAR_KNEE = 0.03928;
46
+ var LINEAR_SLOPE = 12.92;
47
+ var GAMMA_OFFSET = 0.055;
48
+ var GAMMA_SCALE = 1.055;
49
+ var GAMMA = 2.4;
50
+ var RED_WEIGHT = 0.2126;
51
+ var GREEN_WEIGHT = 0.7152;
52
+ var BLUE_WEIGHT = 0.0722;
53
+ var FLARE = 0.05;
54
+ var WHITE_KEYWORD = "white";
55
+ var RGB_PATTERN = /^rgba?\(\s*(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)/i;
56
+ var HEX_PATTERN = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
57
+ var MIN_TEXT_CONTRAST = 4.5;
58
+ function hexChannels(hex) {
59
+ const digits = hex.length === HEX_SHORT ? hex.split("").map((digit) => digit + digit).join("") : hex;
60
+ const read = (start) => parseInt(digits.slice(start, start + 2), HEX_RADIX);
61
+ return [read(0), read(2), read(4)];
62
+ }
63
+ function channels(color) {
64
+ const value = color.trim();
65
+ if (value.toLowerCase() === WHITE_KEYWORD) return [CHANNEL_MAX, CHANNEL_MAX, CHANNEL_MAX];
66
+ const hex = HEX_PATTERN.exec(value)?.[1];
67
+ if (hex !== void 0) return hexChannels(hex);
68
+ const rgb = RGB_PATTERN.exec(value);
69
+ return rgb === null ? void 0 : [Number(rgb[1] ?? 0), Number(rgb[2] ?? 0), Number(rgb[3] ?? 0)];
70
+ }
71
+ function linear(channel) {
72
+ const unit = channel / CHANNEL_MAX;
73
+ return unit <= LINEAR_KNEE ? unit / LINEAR_SLOPE : ((unit + GAMMA_OFFSET) / GAMMA_SCALE) ** GAMMA;
74
+ }
75
+ function luminance(color) {
76
+ const rgb = channels(color);
77
+ if (rgb === void 0) return void 0;
78
+ const [red, green, blue] = rgb;
79
+ return RED_WEIGHT * linear(red) + GREEN_WEIGHT * linear(green) + BLUE_WEIGHT * linear(blue);
80
+ }
81
+ function contrastRatio(first, second) {
82
+ const a = luminance(first);
83
+ const b = luminance(second);
84
+ if (a === void 0 || b === void 0) return 0;
85
+ return (Math.max(a, b) + FLARE) / (Math.min(a, b) + FLARE);
86
+ }
87
+
88
+ // src/expo/accentInk.ts
89
+ var WHITE = "white";
90
+ var WHITE_LUMINANCE = 1;
91
+ var LIGHT_FIRST = ["300", "500", "600", "700"];
92
+ var DARK_FIRST = ["700", "600", "500", "300"];
93
+ function pickOnAccent(accent, background, surface, fallback) {
94
+ if (luminance(accent) === void 0) return fallback;
95
+ const white = luminance(surface) === WHITE_LUMINANCE ? surface : WHITE;
96
+ return contrastRatio(white, accent) >= contrastRatio(background, accent) ? white : background;
97
+ }
98
+ function pickAccentText(shades, captionSurface, text, isDark, fallback) {
99
+ if (luminance(captionSurface) === void 0) return fallback;
100
+ const order = isDark ? LIGHT_FIRST : DARK_FIRST;
101
+ const passing = order.map((key) => shades[key]).find((shade) => shade !== void 0 && contrastRatio(shade, captionSurface) >= MIN_TEXT_CONTRAST);
102
+ return passing ?? text;
103
+ }
104
+
105
+ // src/expo/toTourTheme.ts
40
106
  var DARK_MODE = "dark";
41
107
  var TOUR_RADIUS = 12;
42
108
  var SCRIM_STRENGTH = "62%";
@@ -46,10 +112,12 @@ function toTourTheme(theme, dark) {
46
112
  const lightAccent = palette.primary["700"] ?? palette.primary["600"] ?? palette.primary["500"] ?? colors.text;
47
113
  const accent = isDark ? palette.primary["300"] ?? colors.text : lightAccent;
48
114
  const shade = isDark ? colors.background : colors.text;
115
+ const surface = colors.surfaceElevated ?? colors.surface;
49
116
  return {
50
117
  accent,
51
- onAccent: isDark ? colors.background : colors.surface,
52
- surface: colors.surfaceElevated ?? colors.surface,
118
+ onAccent: pickOnAccent(accent, colors.background, colors.surface, isDark ? colors.background : colors.surface),
119
+ accentText: pickAccentText(palette.primary, surface, colors.text, isDark, accent),
120
+ surface,
53
121
  onSurface: colors.text,
54
122
  muted: colors.textSecondary,
55
123
  scrim: `color-mix(in srgb, ${shade} ${SCRIM_STRENGTH}, transparent)`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/expo/AppToursContext.ts","../../src/expo/labels.ts","../../src/expo/toTourTheme.ts","../../src/expo/trackTourEvent.ts","../../src/expo/AppTours.tsx","../../src/expo/TourButton.tsx"],"names":["jsx","fontStack"],"mappings":";;;;;;;AAOO,IAAM,eAAA,GAAkB,cAAoC,IAAI,CAAA;AAGhE,SAAS,WAAA,GAA6B;AAC3C,EAAA,MAAM,KAAA,GAAQ,WAAW,eAAe,CAAA;AACxC,EAAA,IAAI,KAAA,KAAU,IAAA,EAAM,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAC9E,EAAA,OAAO,KAAA;AACT;ACTO,IAAM,oBAAA,GAAuB;AAE7B,IAAM,oBAAA,GAAuB;AAAA,EAClC,QAAA,EAAU,aAAA;AAAA,EACV,YAAA,EAAc;AAChB;AAKO,SAAS,WAAA,CAAY,SAAA,EAAsB,GAAA,EAAa,QAAA,EAA0B;AACvF,EAAA,MAAM,KAAA,GAAQ,UAAU,GAAG,CAAA;AAC3B,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,UAAU,EAAA,IAAM,KAAA,KAAU,MAAM,KAAA,GAAQ,QAAA;AAC9E;AAGO,SAAS,eAAA,CAAgB,SAAA,EAAsB,MAA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,IAAA,EAAM,MAAM,IAAA,EAAM,WAAA,EAAa,KAAA,CAAM,WAAA,EAAa,OAAA,EAC/I,QAAA,EAAA;AAAA,IAAA,KAAA,CAAM,QAAA;AAAA,wBACN,UAAA,EAAA,EAAW,CAAA;AAAA,wBACX,aAAA,EAAA,EAAc;AAAA,GAAA,EACjB,CAAA,EACF,CAAA;AAEJ;AC3CA,IAAM,OAAA,GAAU,EAAA;AAChB,IAAM,OAAA,GAAU,EAAA;AAGT,SAAS,UAAA,CAAW,EAAE,MAAA,GAAS,WAAA,EAAY,EAAkC;AAClF,EAAA,MAAM,EAAE,UAAA,EAAY,KAAA,EAAM,GAAI,OAAA,EAAQ;AACtC,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,WAAA,EAAY;AAC9B,EAAA,uBACEA,GAAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,MAAA;AAAA,MACA,iBAAA,EAAkB,QAAA;AAAA,MAClB,kBAAA,EAAoB,MAAM,UAAU,CAAA;AAAA,MACpC,iBAAA,EAAmB,MAAM,cAAc,CAAA;AAAA,MACvC,OAAA,EAAS,UAAA;AAAA,MACT,OAAO,EAAE,SAAA,EAAW,OAAA,EAAS,QAAA,EAAU,SAAS,iBAAA,EAAmB,OAAA,EAAS,cAAA,EAAgB,QAAA,EAAU,aAAa,CAAA,EAAG,WAAA,EAAa,MAAM,OAAA,EAAS,YAAA,EAAc,MAAM,MAAA,EAAO;AAAA,MAE7K,0BAAAA,GAAAA,CAAC,IAAA,EAAA,EAAK,KAAA,EAAO,EAAE,OAAO,KAAA,CAAM,SAAA,EAAW,UAAA,EAAYC,SAAAA,CAAU,MAAM,UAAU,CAAA,EAAE,EAAI,QAAA,EAAA,KAAA,CAAM,UAAU,CAAA,EAAE;AAAA;AAAA,GACvG;AAEJ","file":"index.mjs","sourcesContent":["import { createContext, useContext } from 'react';\nimport type { AppTourLabelKey } from './labels';\n\nexport interface AppToursValue {\n label: (key: AppTourLabelKey) => string;\n}\n\nexport const AppToursContext = createContext<AppToursValue | null>(null);\n\n/** Returns the kit labels; must be called inside `AppTours`. */\nexport function useAppTours(): AppToursValue {\n const value = useContext(AppToursContext);\n if (value === null) throw new Error('useAppTours must be used inside AppTours');\n return value;\n}\n","import { defaultTourLabels } from '@dloizides/ui-tour';\nimport type { Tour, TourLabels } from '@dloizides/ui-tour';\n\nexport type Translate = (key: string) => string;\n\nexport const DEFAULT_LABEL_PREFIX = 'tours.labels';\n\nexport const defaultAppTourLabels = {\n takeTour: 'Take a tour',\n takeTourHint: 'Opens the list of guided tours',\n};\n\nexport type AppTourLabelKey = keyof typeof defaultAppTourLabels;\n\n/** Translates `key`; a missing or empty translation returns `fallback`. */\nexport function translateOr(translate: Translate, key: string, fallback: string): string {\n const value = translate(key);\n return typeof value === 'string' && value !== '' && value !== key ? value : fallback;\n}\n\n/** Builds every tour label from `<prefix>.<labelName>` keys, keeping the English default for a missing key. */\nexport function buildTourLabels(translate: Translate, prefix: string = DEFAULT_LABEL_PREFIX): TourLabels {\n const names = Object.keys(defaultTourLabels) as Array<keyof TourLabels>;\n const labels: TourLabels = { ...defaultTourLabels };\n names.forEach((name) => {\n labels[name] = translateOr(translate, `${prefix}.${name}`, defaultTourLabels[name]);\n });\n return labels;\n}\n\n/** Replaces each tour title, category and step text key with its translation. */\nexport function localizeTours(tours: readonly Tour[], translate: Translate): Tour[] {\n const text = (key: string): string => translateOr(translate, key, key);\n return tours.map((tour) => ({\n ...tour,\n title: text(tour.title),\n category: text(tour.category),\n steps: tour.steps.map((step) => ({ ...step, text: text(step.text) })),\n }));\n}\n","import { fontStack } from '@dloizides/ui-tour';\nimport type { TourTheme } from '@dloizides/ui-tour';\n\nexport interface AppThemeColors {\n background: string;\n surface: string;\n surfaceElevated?: string;\n text: string;\n textSecondary: string;\n border: string;\n divider?: string;\n}\n\nexport interface AppThemeSource {\n colors: AppThemeColors;\n palette: { primary: { '300'?: string; '500'?: string; '600'?: string; '700'?: string } };\n mode?: string;\n typography?: { fontFamily?: string };\n}\n\nconst DARK_MODE = 'dark';\nconst TOUR_RADIUS = 12;\nconst SCRIM_STRENGTH = '62%';\n\n/** Maps an app theme (theme-web `ResolvedTheme` or ui-feedback theme) onto the tour colour slots. */\nexport function toTourTheme(theme: AppThemeSource, dark?: boolean): TourTheme {\n const isDark = dark ?? theme.mode === DARK_MODE;\n const { colors, palette } = theme;\n const lightAccent = palette.primary['700'] ?? palette.primary['600'] ?? palette.primary['500'] ?? colors.text;\n const accent = isDark ? palette.primary['300'] ?? colors.text : lightAccent;\n const shade = isDark ? colors.background : colors.text;\n return {\n accent,\n onAccent: isDark ? colors.background : colors.surface,\n surface: colors.surfaceElevated ?? colors.surface,\n onSurface: colors.text,\n muted: colors.textSecondary,\n scrim: `color-mix(in srgb, ${shade} ${SCRIM_STRENGTH}, transparent)`,\n divider: colors.divider ?? colors.border,\n radius: TOUR_RADIUS,\n fontFamily: fontStack(theme.typography?.fontFamily),\n };\n}\n","import type { TourEvent } from '@dloizides/ui-tour';\n\ninterface UmamiWindow {\n umami?: { track: (name: string, data?: Record<string, string>) => void };\n}\n\n/** Sends a tour event to Umami (when its script is loaded) with only the tour id and mode. */\nexport function trackTourEvent(event: TourEvent): void {\n if (typeof window === 'undefined') return;\n (window as unknown as UmamiWindow).umami?.track(event.type, { tourId: event.tourId, mode: event.mode });\n}\n","import { useCallback, useMemo } from 'react';\nimport type { ReactElement, ReactNode } from 'react';\nimport { useRouter } from 'expo-router';\nimport { FirstRunOffer, TourPicker, TourProvider } from '@dloizides/ui-tour';\nimport type { Tour, TourEvent, TourUser, TourVars } from '@dloizides/ui-tour';\nimport { AppToursContext } from './AppToursContext';\nimport type { AppToursValue } from './AppToursContext';\nimport { buildTourLabels, DEFAULT_LABEL_PREFIX, defaultAppTourLabels, localizeTours, translateOr } from './labels';\nimport type { AppTourLabelKey, Translate } from './labels';\nimport { toTourTheme } from './toTourTheme';\nimport type { AppThemeSource } from './toTourTheme';\nimport { trackTourEvent } from './trackTourEvent';\n\nexport interface AppToursProps {\n tours: readonly Tour[];\n translate: Translate;\n theme: AppThemeSource;\n dark?: boolean;\n user?: TourUser | null;\n vars?: TourVars;\n navigate?: (route: string) => void;\n labelPrefix?: string;\n allowWrites?: boolean;\n onEvent?: (event: TourEvent) => void;\n children?: ReactNode;\n}\n\n/** One-line tour setup for an Expo Router app: router, theme, translated labels, Umami events, picker and first-run card. */\nexport function AppTours(props: AppToursProps): ReactElement {\n const router = useRouter();\n const { translate, onEvent: extraEvent } = props;\n const prefix = props.labelPrefix ?? DEFAULT_LABEL_PREFIX;\n const navigate = props.navigate ?? router.push;\n const tours = useMemo(() => localizeTours(props.tours, translate), [props.tours, translate]);\n const labels = useMemo(() => buildTourLabels(translate, prefix), [translate, prefix]);\n const theme = useMemo(() => toTourTheme(props.theme, props.dark), [props.theme, props.dark]);\n const onEvent = useCallback((event: TourEvent) => {\n trackTourEvent(event);\n extraEvent?.(event);\n }, [extraEvent]);\n const appValue = useMemo<AppToursValue>(() => ({\n label: (key: AppTourLabelKey) => translateOr(translate, `${prefix}.${key}`, defaultAppTourLabels[key]),\n }), [translate, prefix]);\n return (\n <AppToursContext.Provider value={appValue}>\n <TourProvider tours={tours} navigate={navigate} theme={theme} labels={labels} user={props.user} vars={props.vars} allowWrites={props.allowWrites} onEvent={onEvent}>\n {props.children}\n <TourPicker />\n <FirstRunOffer />\n </TourProvider>\n </AppToursContext.Provider>\n );\n}\n","import type { ReactElement } from 'react';\nimport { Pressable, Text } from 'react-native';\nimport { fontStack, useTour } from '@dloizides/ui-tour';\nimport { useAppTours } from './AppToursContext';\n\nexport interface TourButtonProps {\n testID?: string;\n}\n\nconst MIN_HIT = 44;\nconst PADDING = 12;\n\n/** \"Take a tour\" button for the shell help slot; opens the tour picker (F2 does the same). */\nexport function TourButton({ testID = 'take-tour' }: TourButtonProps): ReactElement {\n const { openPicker, theme } = useTour();\n const { label } = useAppTours();\n return (\n <Pressable\n testID={testID}\n accessibilityRole=\"button\"\n accessibilityLabel={label('takeTour')}\n accessibilityHint={label('takeTourHint')}\n onPress={openPicker}\n style={{ minHeight: MIN_HIT, minWidth: MIN_HIT, paddingHorizontal: PADDING, justifyContent: 'center', borderWidth: 1, borderColor: theme.divider, borderRadius: theme.radius }}\n >\n <Text style={{ color: theme.onSurface, fontFamily: fontStack(theme.fontFamily) }}>{label('takeTour')}</Text>\n </Pressable>\n );\n}\n"]}
1
+ {"version":3,"sources":["../../src/expo/AppToursContext.ts","../../src/expo/labels.ts","../../src/expo/contrast.ts","../../src/expo/accentInk.ts","../../src/expo/toTourTheme.ts","../../src/expo/trackTourEvent.ts","../../src/expo/AppTours.tsx","../../src/expo/TourButton.tsx"],"names":["jsx","fontStack"],"mappings":";;;;;;;AAOO,IAAM,eAAA,GAAkB,cAAoC,IAAI,CAAA;AAGhE,SAAS,WAAA,GAA6B;AAC3C,EAAA,MAAM,KAAA,GAAQ,WAAW,eAAe,CAAA;AACxC,EAAA,IAAI,KAAA,KAAU,IAAA,EAAM,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAC9E,EAAA,OAAO,KAAA;AACT;ACTO,IAAM,oBAAA,GAAuB;AAE7B,IAAM,oBAAA,GAAuB;AAAA,EAClC,QAAA,EAAU,aAAA;AAAA,EACV,YAAA,EAAc;AAChB;AAKO,SAAS,WAAA,CAAY,SAAA,EAAsB,GAAA,EAAa,QAAA,EAA0B;AACvF,EAAA,MAAM,KAAA,GAAQ,UAAU,GAAG,CAAA;AAC3B,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,UAAU,EAAA,IAAM,KAAA,KAAU,MAAM,KAAA,GAAQ,QAAA;AAC9E;AAGO,SAAS,eAAA,CAAgB,SAAA,EAAsB,MAAA,GAAiB,oBAAA,EAAkC;AACvG,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA;AAC3C,EAAA,MAAM,MAAA,GAAqB,EAAE,GAAG,iBAAA,EAAkB;AAClD,EAAA,KAAA,CA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AAA,EAAA,EAAc;AAAA,GAAA,EACjB,CAAA,EACF,CAAA;AAEJ;AC3CA,IAAM,OAAA,GAAU,EAAA;AAChB,IAAM,OAAA,GAAU,EAAA;AAGT,SAAS,UAAA,CAAW,EAAE,MAAA,GAAS,WAAA,EAAY,EAAkC;AAClF,EAAA,MAAM,EAAE,UAAA,EAAY,KAAA,EAAM,GAAI,OAAA,EAAQ;AACtC,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,WAAA,EAAY;AAC9B,EAAA,uBACEA,GAAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,MAAA;AAAA,MACA,iBAAA,EAAkB,QAAA;AAAA,MAClB,kBAAA,EAAoB,MAAM,UAAU,CAAA;AAAA,MACpC,iBAAA,EAAmB,MAAM,cAAc,CAAA;AAAA,MACvC,OAAA,EAAS,UAAA;AAAA,MACT,OAAO,EAAE,SAAA,EAAW,OAAA,EAAS,QAAA,EAAU,SAAS,iBAAA,EAAmB,OAAA,EAAS,cAAA,EAAgB,QAAA,EAAU,aAAa,CAAA,EAAG,WAAA,EAAa,MAAM,OAAA,EAAS,YAAA,EAAc,MAAM,MAAA,EAAO;AAAA,MAE7K,0BAAAA,GAAAA,CAAC,IAAA,EAAA,EAAK,KAAA,EAAO,EAAE,OAAO,KAAA,CAAM,SAAA,EAAW,UAAA,EAAYC,SAAAA,CAAU,MAAM,UAAU,CAAA,EAAE,EAAI,QAAA,EAAA,KAAA,CAAM,UAAU,CAAA,EAAE;AAAA;AAAA,GACvG;AAEJ","file":"index.mjs","sourcesContent":["import { createContext, useContext } from 'react';\nimport type { AppTourLabelKey } from './labels';\n\nexport interface AppToursValue {\n label: (key: AppTourLabelKey) => string;\n}\n\nexport const AppToursContext = createContext<AppToursValue | null>(null);\n\n/** Returns the kit labels; must be called inside `AppTours`. */\nexport function useAppTours(): AppToursValue {\n const value = useContext(AppToursContext);\n if (value === null) throw new Error('useAppTours must be used inside AppTours');\n return value;\n}\n","import { defaultTourLabels } from '@dloizides/ui-tour';\nimport type { Tour, TourLabels } from '@dloizides/ui-tour';\n\nexport type Translate = (key: string) => string;\n\nexport const DEFAULT_LABEL_PREFIX = 'tours.labels';\n\nexport const defaultAppTourLabels = {\n takeTour: 'Take a tour',\n takeTourHint: 'Opens the list of guided tours',\n};\n\nexport type AppTourLabelKey = keyof typeof defaultAppTourLabels;\n\n/** Translates `key`; a missing or empty translation returns `fallback`. */\nexport function translateOr(translate: Translate, key: string, fallback: string): string {\n const value = translate(key);\n return typeof value === 'string' && value !== '' && value !== key ? value : fallback;\n}\n\n/** Builds every tour label from `<prefix>.<labelName>` keys, keeping the English default for a missing key. */\nexport function buildTourLabels(translate: Translate, prefix: string = DEFAULT_LABEL_PREFIX): TourLabels {\n const names = Object.keys(defaultTourLabels) as Array<keyof TourLabels>;\n const labels: TourLabels = { ...defaultTourLabels };\n names.forEach((name) => {\n labels[name] = translateOr(translate, `${prefix}.${name}`, defaultTourLabels[name]);\n });\n return labels;\n}\n\n/** Replaces each tour title, category and step text key with its translation. */\nexport function localizeTours(tours: readonly Tour[], translate: Translate): Tour[] {\n const text = (key: string): string => translateOr(translate, key, key);\n return tours.map((tour) => ({\n ...tour,\n title: text(tour.title),\n category: text(tour.category),\n steps: tour.steps.map((step) => ({ ...step, text: text(step.text) })),\n }));\n}\n","const CHANNEL_MAX = 255;\nconst HEX_SHORT = 3;\nconst HEX_RADIX = 16;\nconst LINEAR_KNEE = 0.03928;\nconst LINEAR_SLOPE = 12.92;\nconst GAMMA_OFFSET = 0.055;\nconst GAMMA_SCALE = 1.055;\nconst GAMMA = 2.4;\nconst RED_WEIGHT = 0.2126;\nconst GREEN_WEIGHT = 0.7152;\nconst BLUE_WEIGHT = 0.0722;\nconst FLARE = 0.05;\nconst WHITE_KEYWORD = 'white';\nconst RGB_PATTERN = /^rgba?\\(\\s*(\\d+(?:\\.\\d+)?)[\\s,]+(\\d+(?:\\.\\d+)?)[\\s,]+(\\d+(?:\\.\\d+)?)/i;\nconst HEX_PATTERN = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;\n\n/** Minimum WCAG AA contrast for normal-size text. */\nexport const MIN_TEXT_CONTRAST = 4.5;\n\ntype Channels = [number, number, number];\n\nfunction hexChannels(hex: string): Channels {\n const digits = hex.length === HEX_SHORT ? hex.split('').map((digit) => digit + digit).join('') : hex;\n const read = (start: number): number => parseInt(digits.slice(start, start + 2), HEX_RADIX);\n return [read(0), read(2), read(4)];\n}\n\nfunction channels(color: string): Channels | undefined {\n const value = color.trim();\n if (value.toLowerCase() === WHITE_KEYWORD) return [CHANNEL_MAX, CHANNEL_MAX, CHANNEL_MAX];\n const hex = HEX_PATTERN.exec(value)?.[1];\n if (hex !== undefined) return hexChannels(hex);\n const rgb = RGB_PATTERN.exec(value);\n return rgb === null ? undefined : [Number(rgb[1] ?? 0), Number(rgb[2] ?? 0), Number(rgb[3] ?? 0)];\n}\n\nfunction linear(channel: number): number {\n const unit = channel / CHANNEL_MAX;\n return unit <= LINEAR_KNEE ? unit / LINEAR_SLOPE : ((unit + GAMMA_OFFSET) / GAMMA_SCALE) ** GAMMA;\n}\n\n/** WCAG relative luminance of a hex, rgb or white colour, or undefined when it cannot be parsed. */\nexport function luminance(color: string): number | undefined {\n const rgb = channels(color);\n if (rgb === undefined) return undefined;\n const [red, green, blue] = rgb;\n return RED_WEIGHT * linear(red) + GREEN_WEIGHT * linear(green) + BLUE_WEIGHT * linear(blue);\n}\n\n/** WCAG contrast ratio of two hex, rgb or white colours; 0 when either cannot be parsed. */\nexport function contrastRatio(first: string, second: string): number {\n const a = luminance(first);\n const b = luminance(second);\n if (a === undefined || b === undefined) return 0;\n return (Math.max(a, b) + FLARE) / (Math.min(a, b) + FLARE);\n}\n","import { contrastRatio, luminance, MIN_TEXT_CONTRAST } from './contrast';\n\nconst WHITE = 'white';\nconst WHITE_LUMINANCE = 1;\n\ntype Shades = Partial<Record<'300' | '500' | '600' | '700', string>>;\n\nconst LIGHT_FIRST = ['300', '500', '600', '700'] as const;\nconst DARK_FIRST = ['700', '600', '500', '300'] as const;\n\n/** Picks white or the background, whichever contrasts more with the accent fill; `fallback` when the accent cannot be measured. */\nexport function pickOnAccent(accent: string, background: string, surface: string, fallback: string): string {\n if (luminance(accent) === undefined) return fallback;\n const white = luminance(surface) === WHITE_LUMINANCE ? surface : WHITE;\n return contrastRatio(white, accent) >= contrastRatio(background, accent) ? white : background;\n}\n\n/** First primary shade reaching AA on the caption surface (lighter first in dark), else the text colour; `fallback` when the surface cannot be measured. */\nexport function pickAccentText(shades: Shades, captionSurface: string, text: string, isDark: boolean, fallback: string): string {\n if (luminance(captionSurface) === undefined) return fallback;\n const order = isDark ? LIGHT_FIRST : DARK_FIRST;\n const passing = order.map((key) => shades[key]).find((shade) => shade !== undefined && contrastRatio(shade, captionSurface) >= MIN_TEXT_CONTRAST);\n return passing ?? text;\n}\n","import { fontStack } from '@dloizides/ui-tour';\nimport type { TourTheme } from '@dloizides/ui-tour';\n\nimport { pickAccentText, pickOnAccent } from './accentInk';\n\nexport interface AppThemeColors {\n background: string;\n surface: string;\n surfaceElevated?: string;\n text: string;\n textSecondary: string;\n border: string;\n divider?: string;\n}\n\nexport interface AppThemeSource {\n colors: AppThemeColors;\n palette: { primary: { '300'?: string; '500'?: string; '600'?: string; '700'?: string } };\n mode?: string;\n typography?: { fontFamily?: string };\n}\n\nconst DARK_MODE = 'dark';\nconst TOUR_RADIUS = 12;\nconst SCRIM_STRENGTH = '62%';\n\n/** Maps an app theme (theme-web `ResolvedTheme` or ui-feedback theme) onto the tour colour slots. */\nexport function toTourTheme(theme: AppThemeSource, dark?: boolean): TourTheme {\n const isDark = dark ?? theme.mode === DARK_MODE;\n const { colors, palette } = theme;\n const lightAccent = palette.primary['700'] ?? palette.primary['600'] ?? palette.primary['500'] ?? colors.text;\n const accent = isDark ? palette.primary['300'] ?? colors.text : lightAccent;\n const shade = isDark ? colors.background : colors.text;\n const surface = colors.surfaceElevated ?? colors.surface;\n return {\n accent,\n onAccent: pickOnAccent(accent, colors.background, colors.surface, isDark ? colors.background : colors.surface),\n accentText: pickAccentText(palette.primary, surface, colors.text, isDark, accent),\n surface,\n onSurface: colors.text,\n muted: colors.textSecondary,\n scrim: `color-mix(in srgb, ${shade} ${SCRIM_STRENGTH}, transparent)`,\n divider: colors.divider ?? colors.border,\n radius: TOUR_RADIUS,\n fontFamily: fontStack(theme.typography?.fontFamily),\n };\n}\n","import type { TourEvent } from '@dloizides/ui-tour';\n\ninterface UmamiWindow {\n umami?: { track: (name: string, data?: Record<string, string>) => void };\n}\n\n/** Sends a tour event to Umami (when its script is loaded) with only the tour id and mode. */\nexport function trackTourEvent(event: TourEvent): void {\n if (typeof window === 'undefined') return;\n (window as unknown as UmamiWindow).umami?.track(event.type, { tourId: event.tourId, mode: event.mode });\n}\n","import { useCallback, useMemo } from 'react';\nimport type { ReactElement, ReactNode } from 'react';\nimport { useRouter } from 'expo-router';\nimport { FirstRunOffer, TourPicker, TourProvider } from '@dloizides/ui-tour';\nimport type { Tour, TourEvent, TourUser, TourVars } from '@dloizides/ui-tour';\nimport { AppToursContext } from './AppToursContext';\nimport type { AppToursValue } from './AppToursContext';\nimport { buildTourLabels, DEFAULT_LABEL_PREFIX, defaultAppTourLabels, localizeTours, translateOr } from './labels';\nimport type { AppTourLabelKey, Translate } from './labels';\nimport { toTourTheme } from './toTourTheme';\nimport type { AppThemeSource } from './toTourTheme';\nimport { trackTourEvent } from './trackTourEvent';\n\nexport interface AppToursProps {\n tours: readonly Tour[];\n translate: Translate;\n theme: AppThemeSource;\n dark?: boolean;\n user?: TourUser | null;\n vars?: TourVars;\n navigate?: (route: string) => void;\n labelPrefix?: string;\n allowWrites?: boolean;\n onEvent?: (event: TourEvent) => void;\n children?: ReactNode;\n}\n\n/** One-line tour setup for an Expo Router app: router, theme, translated labels, Umami events, picker and first-run card. */\nexport function AppTours(props: AppToursProps): ReactElement {\n const router = useRouter();\n const { translate, onEvent: extraEvent } = props;\n const prefix = props.labelPrefix ?? DEFAULT_LABEL_PREFIX;\n const navigate = props.navigate ?? router.push;\n const tours = useMemo(() => localizeTours(props.tours, translate), [props.tours, translate]);\n const labels = useMemo(() => buildTourLabels(translate, prefix), [translate, prefix]);\n const theme = useMemo(() => toTourTheme(props.theme, props.dark), [props.theme, props.dark]);\n const onEvent = useCallback((event: TourEvent) => {\n trackTourEvent(event);\n extraEvent?.(event);\n }, [extraEvent]);\n const appValue = useMemo<AppToursValue>(() => ({\n label: (key: AppTourLabelKey) => translateOr(translate, `${prefix}.${key}`, defaultAppTourLabels[key]),\n }), [translate, prefix]);\n return (\n <AppToursContext.Provider value={appValue}>\n <TourProvider tours={tours} navigate={navigate} theme={theme} labels={labels} user={props.user} vars={props.vars} allowWrites={props.allowWrites} onEvent={onEvent}>\n {props.children}\n <TourPicker />\n <FirstRunOffer />\n </TourProvider>\n </AppToursContext.Provider>\n );\n}\n","import type { ReactElement } from 'react';\nimport { Pressable, Text } from 'react-native';\nimport { fontStack, useTour } from '@dloizides/ui-tour';\nimport { useAppTours } from './AppToursContext';\n\nexport interface TourButtonProps {\n testID?: string;\n}\n\nconst MIN_HIT = 44;\nconst PADDING = 12;\n\n/** \"Take a tour\" button for the shell help slot; opens the tour picker (F2 does the same). */\nexport function TourButton({ testID = 'take-tour' }: TourButtonProps): ReactElement {\n const { openPicker, theme } = useTour();\n const { label } = useAppTours();\n return (\n <Pressable\n testID={testID}\n accessibilityRole=\"button\"\n accessibilityLabel={label('takeTour')}\n accessibilityHint={label('takeTourHint')}\n onPress={openPicker}\n style={{ minHeight: MIN_HIT, minWidth: MIN_HIT, paddingHorizontal: PADDING, justifyContent: 'center', borderWidth: 1, borderColor: theme.divider, borderRadius: theme.radius }}\n >\n <Text style={{ color: theme.onSurface, fontFamily: fontStack(theme.fontFamily) }}>{label('takeTour')}</Text>\n </Pressable>\n );\n}\n"]}
package/dist/index.d.mts CHANGED
@@ -94,6 +94,7 @@ interface TourEvent {
94
94
  type: TourEventType;
95
95
  tourId: string;
96
96
  mode: TourMode;
97
+ skipped?: number;
97
98
  }
98
99
  interface TourUser {
99
100
  id: string;
@@ -102,6 +103,7 @@ type TourVars = Record<string, string | undefined>;
102
103
  interface TourTheme {
103
104
  accent: string;
104
105
  onAccent: string;
106
+ accentText?: string;
105
107
  surface: string;
106
108
  onSurface: string;
107
109
  muted: string;
@@ -168,8 +170,10 @@ interface TourControls {
168
170
  active: ActiveTour | null;
169
171
  paused: boolean;
170
172
  pickerOpen: boolean;
173
+ skipped: number;
171
174
  start: (tourId: string, mode: TourMode) => void;
172
175
  next: () => void;
176
+ skipOptional: () => void;
173
177
  back: () => void;
174
178
  end: () => void;
175
179
  togglePause: () => void;
package/dist/index.d.ts CHANGED
@@ -94,6 +94,7 @@ interface TourEvent {
94
94
  type: TourEventType;
95
95
  tourId: string;
96
96
  mode: TourMode;
97
+ skipped?: number;
97
98
  }
98
99
  interface TourUser {
99
100
  id: string;
@@ -102,6 +103,7 @@ type TourVars = Record<string, string | undefined>;
102
103
  interface TourTheme {
103
104
  accent: string;
104
105
  onAccent: string;
106
+ accentText?: string;
105
107
  surface: string;
106
108
  onSurface: string;
107
109
  muted: string;
@@ -168,8 +170,10 @@ interface TourControls {
168
170
  active: ActiveTour | null;
169
171
  paused: boolean;
170
172
  pickerOpen: boolean;
173
+ skipped: number;
171
174
  start: (tourId: string, mode: TourMode) => void;
172
175
  next: () => void;
176
+ skipOptional: () => void;
173
177
  back: () => void;
174
178
  end: () => void;
175
179
  togglePause: () => void;
package/dist/index.js CHANGED
@@ -284,8 +284,10 @@ function inertTour(tours, theme, labels) {
284
284
  active: null,
285
285
  paused: false,
286
286
  pickerOpen: false,
287
+ skipped: 0,
287
288
  start: ignore,
288
289
  next: ignore,
290
+ skipOptional: ignore,
289
291
  back: ignore,
290
292
  end: ignore,
291
293
  togglePause: ignore,
@@ -411,7 +413,8 @@ async function perform(context, node) {
411
413
  }
412
414
  async function runStep(context) {
413
415
  const { step } = context;
414
- if (step.route !== void 0 && context.getPathname() !== step.route) context.navigate(step.route);
416
+ const route = step.route === void 0 ? void 0 : substitute(step.route, context.vars);
417
+ if (route !== void 0 && context.getPathname() !== route) context.navigate(route);
415
418
  const node = await waitForTarget(step.target, context.vars, step.wait ?? context.timing.waitMs, context.isCancelled);
416
419
  if (context.isCancelled()) return CANCELLED;
417
420
  if (node === null) return { kind: step.optional === true ? "skip" /* Skip */ : "missing" /* Missing */ };
@@ -522,6 +525,8 @@ function useTourControls(options) {
522
525
  const [active, setActiveState] = react.useState(() => loadSession(options.tours));
523
526
  const [paused, setPaused] = react.useState(false);
524
527
  const [pickerOpen, setPickerOpen] = react.useState(false);
528
+ const [skipped, setSkipped] = react.useState(0);
529
+ const skippedSteps = react.useRef(/* @__PURE__ */ new Set());
525
530
  const activeRef = react.useRef(active);
526
531
  const optionsRef = react.useRef(options);
527
532
  optionsRef.current = options;
@@ -534,7 +539,8 @@ function useTourControls(options) {
534
539
  const current = activeRef.current;
535
540
  if (current === null) return;
536
541
  const { onEvent, user } = optionsRef.current;
537
- onEvent?.({ type, tourId: current.tourId, mode: current.mode });
542
+ const event = { type, tourId: current.tourId, mode: current.mode };
543
+ onEvent?.(type === "tour_finish" /* Finish */ ? { ...event, skipped: skippedSteps.current.size } : event);
538
544
  if (type === "tour_finish" /* Finish */ && user !== null) markOfferSeen(user.id);
539
545
  setPaused(false);
540
546
  setActive(null);
@@ -543,6 +549,8 @@ function useTourControls(options) {
543
549
  if (!optionsRef.current.tours.some((tour) => tour.id === tourId)) return;
544
550
  setPickerOpen(false);
545
551
  setPaused(false);
552
+ skippedSteps.current = /* @__PURE__ */ new Set();
553
+ setSkipped(0);
546
554
  setActive({ tourId, step: 0, mode });
547
555
  optionsRef.current.onEvent?.({ type: "tour_start" /* Start */, tourId, mode });
548
556
  }, [setActive]);
@@ -553,6 +561,13 @@ function useTourControls(options) {
553
561
  if (tour === void 0 || current.step + 1 >= tour.steps.length) close("tour_finish" /* Finish */);
554
562
  else setActive({ ...current, step: current.step + 1 });
555
563
  }, [close, setActive]);
564
+ const skipOptional = react.useCallback(() => {
565
+ const current = activeRef.current;
566
+ if (current === null) return;
567
+ skippedSteps.current.add(current.step);
568
+ setSkipped(skippedSteps.current.size);
569
+ next();
570
+ }, [next]);
556
571
  const back = react.useCallback(() => {
557
572
  const current = activeRef.current;
558
573
  if (current !== null && current.step > 0) setActive({ ...current, step: current.step - 1 });
@@ -561,13 +576,13 @@ function useTourControls(options) {
561
576
  const togglePause = react.useCallback(() => setPaused((value) => !value), []);
562
577
  const openPicker = react.useCallback(() => setPickerOpen(true), []);
563
578
  const closePicker = react.useCallback(() => setPickerOpen(false), []);
564
- return { active, paused, pickerOpen, start, next, back, end, togglePause, openPicker, closePicker };
579
+ return { active, paused, pickerOpen, skipped, start, next, skipOptional, back, end, togglePause, openPicker, closePicker };
565
580
  }
566
581
 
567
582
  // src/hooks/useTourEngine.ts
568
583
  function useTourEngine(options) {
569
584
  const controls = useTourControls(options);
570
- const runner = useStepRunner({ ...options, active: controls.active, onSkip: controls.next });
585
+ const runner = useStepRunner({ ...options, active: controls.active, onSkip: controls.skipOptional });
571
586
  const action = stepOf(options.tours, controls.active)?.action ?? null;
572
587
  useTourKeys(controls);
573
588
  useAutoAdvance(controls.active, runner.view.phase, controls.paused, options.timing.autoMs, controls.next);
@@ -637,10 +652,10 @@ function captionStyle(theme, position) {
637
652
  };
638
653
  }
639
654
  function metaStyle(theme) {
640
- return { color: theme.accent, fontSize: 12, fontWeight: 600, letterSpacing: "0.04em", textTransform: "uppercase", marginBottom: 6 };
655
+ return { color: theme.accentText ?? theme.accent, fontSize: 12, fontWeight: 600, letterSpacing: "0.04em", textTransform: "uppercase", marginBottom: 6 };
641
656
  }
642
657
  function noteStyle(theme) {
643
- return { color: theme.accent, fontSize: 14, marginTop: 6 };
658
+ return { color: theme.accentText ?? theme.accent, fontSize: 14, marginTop: 6 };
644
659
  }
645
660
  function rowStyle(theme) {
646
661
  return { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 8, marginTop: 10, color: theme.muted, fontSize: 13 };
@@ -750,7 +765,7 @@ function TourCaption() {
750
765
  if (active === null || current === null || step === void 0) return null;
751
766
  const missing = view.phase === "missing" /* Missing */;
752
767
  const note = noteFor(tour);
753
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, role: "dialog", "aria-live": "polite", "aria-label": current.title, "data-testid": "tour-caption", "data-tour-id": current.id, "data-tour-step": stepIndex + 1, "data-tour-steps": current.steps.length, style: captionStyle(theme, position), children: [
768
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, role: "dialog", "aria-live": "polite", "aria-label": current.title, "data-testid": "tour-caption", "data-tour-id": current.id, "data-tour-step": stepIndex + 1, "data-tour-steps": current.steps.length, "data-tour-skipped": tour.skipped, style: captionStyle(theme, position), children: [
754
769
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: metaStyle(theme), children: formatLabel(labels.captionMeta, current.title, stepIndex + 1, current.steps.length, modeName(tour, active.mode)) }),
755
770
  /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "tour-text", children: substitute(step.text, tour.vars) }),
756
771
  note !== "" ? /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "tour-note", style: noteStyle(theme), children: note }) : null,
@@ -854,7 +869,7 @@ function groupButtonStyle(theme) {
854
869
  borderTop: `1px solid ${theme.divider}`,
855
870
  marginTop: 8,
856
871
  padding: "12px 0",
857
- color: theme.accent,
872
+ color: theme.accentText ?? theme.accent,
858
873
  fontFamily: fontStack(theme.fontFamily),
859
874
  fontSize: 16,
860
875
  fontWeight: 700,