{"version":3,"file":"Tour.context.mjs","names":[],"sources":["../../../src/components/Tour/Tour.context.ts"],"sourcesContent":["import { createContext, use } from 'react';\nimport type { GetStylesApi, MantineColor } from '../../core';\nimport type { TransitionOverride } from '../Transition';\nimport type { TourFactory } from './Tour';\nimport type { TourRootFactory } from './TourRoot/TourRoot';\n\nexport interface TourLabels {\n  /** Label for the skip button @default \"Skip\" */\n  skip: string;\n\n  /** Label for the back button @default \"Back\" */\n  back: string;\n\n  /** Label for the next button @default \"Next\" */\n  next: string;\n\n  /** Label for the close/finish button @default \"Close\" */\n  close: string;\n\n  /** Function that returns step counter text @default (current, total) => `${current} of ${total}` */\n  stepCounter: (current: number, total: number) => string;\n\n  /** Label for the beacon button, the step title is appended when it is a string @default \"Start tour\" */\n  beacon: string;\n}\n\nexport const defaultLabels: TourLabels = {\n  skip: 'Skip',\n  back: 'Back',\n  next: 'Next',\n  close: 'Close',\n  stepCounter: (current, total) => `${current} of ${total}`,\n  beacon: 'Start tour',\n};\n\nexport interface TourContextValue {\n  /** Returns styles for the given selector */\n  getStyles: GetStylesApi<TourFactory & TourRootFactory>;\n\n  /** Current active step index */\n  step: number;\n\n  /** Sets the active step index */\n  setStep: (step: number) => void;\n\n  /** Total number of steps */\n  stepsCount: number;\n\n  /** Closes the tour */\n  close: () => void;\n\n  /** Whether `Tour.Overlay` is rendered */\n  withOverlay: boolean;\n\n  /** Whether pointer events pass through the spotlight cutout to the target element */\n  withOverlayInteraction: boolean;\n\n  /** Whether `Tour.CloseButton` is rendered */\n  withCloseButton: boolean;\n\n  /** Key of `theme.colors` or any valid CSS color passed to `Tour.Navigation` next button */\n  color?: MantineColor;\n\n  /** Padding around the spotlight cutout in px */\n  spotlightPadding: number;\n\n  /** Border radius of the spotlight cutout in px */\n  spotlightRadius: number;\n\n  /** Whether clicking the overlay closes the tour */\n  closeOnOverlayClick: boolean;\n\n  /** Default transition props of `Tour.Tooltip` */\n  transitionProps: TransitionOverride | undefined;\n\n  /** Labels for tour UI elements */\n  labels: TourLabels;\n\n  /** Id of the mounted `Tour.Title` (or the generated fallback), referenced by the tooltip `aria-labelledby` */\n  titleId: string;\n\n  /** Id of the mounted `Tour.Body` (or the generated fallback), referenced by the tooltip `aria-describedby` */\n  bodyId: string;\n\n  /** Whether `Tour.Title` is currently mounted */\n  titleMounted: boolean;\n\n  /** Whether `Tour.Body` is currently mounted */\n  bodyMounted: boolean;\n\n  /** Registers the id of the mounted `Tour.Title`, `null` when it unmounts */\n  registerTitle: (id: string | null) => void;\n\n  /** Registers the id of the mounted `Tour.Body`, `null` when it unmounts */\n  registerBody: (id: string | null) => void;\n\n  /** Registers the current step target element, used to skip arrow hotkeys fired from inside it */\n  setTargetElement: (element: HTMLElement | null) => void;\n}\n\nexport const TourContext = createContext<TourContextValue | null>(null);\n\nexport function useTourContext() {\n  const ctx = use(TourContext);\n\n  if (ctx === null) {\n    throw new Error('Tour component was not found in tree');\n  }\n\n  return ctx;\n}\n\nexport const TourProvider = TourContext.Provider;\n"],"mappings":";;;AA0BA,MAAa,gBAA4B;CACvC,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,cAAc,SAAS,UAAU,GAAG,QAAQ,MAAM;CAClD,QAAQ;AACV;AAmEA,MAAa,cAAc,cAAuC,IAAI;AAEtE,SAAgB,iBAAiB;CAC/B,MAAM,MAAM,IAAI,WAAW;CAE3B,IAAI,QAAQ,MACV,MAAM,IAAI,MAAM,sCAAsC;CAGxD,OAAO;AACT;AAEA,MAAa,eAAe,YAAY"}