{"version":3,"sources":["../src/stepper.tsx"],"sourcesContent":["import { cx } from \"@chakra-ui/shared-utils\"\nimport {\n  HTMLChakraProps,\n  ThemingProps,\n  chakra,\n  forwardRef,\n  omitThemingProps,\n  useMultiStyleConfig,\n} from \"@chakra-ui/system\"\nimport { Children } from \"react\"\nimport {\n  Orientation,\n  StepContextProvider,\n  StepStatusType,\n  StepperStylesProvider,\n} from \"./step-context\"\n\nexport interface StepperProps\n  extends HTMLChakraProps<\"div\">,\n    ThemingProps<\"Stepper\"> {\n  /**\n   * The active step index\n   */\n  index: number\n  /**\n   * The orientation of the stepper\n   * @default horizontal\n   */\n  orientation?: Orientation\n  /**\n   * Whether to show or not the last separator while in vertical orientation\n   */\n  showLastSeparator?: boolean\n  /**\n   */\n  children: React.ReactNode\n}\n\nexport const Stepper = forwardRef<StepperProps, \"div\">(function Stepper(\n  props: StepperProps,\n  ref,\n) {\n  const styles = useMultiStyleConfig(\"Stepper\", props)\n\n  const {\n    children,\n    index,\n    orientation = \"horizontal\",\n    showLastSeparator = false,\n    ...restProps\n  } = omitThemingProps(props)\n\n  const stepElements = Children.toArray(children)\n\n  const stepCount = stepElements.length\n\n  function getStatus(step: number): StepStatusType {\n    if (step < index) return \"complete\"\n    if (step > index) return \"incomplete\"\n    return \"active\"\n  }\n\n  return (\n    <chakra.div\n      ref={ref}\n      aria-label=\"Progress\"\n      data-orientation={orientation}\n      {...restProps}\n      __css={styles.stepper}\n      className={cx(\"chakra-stepper\", props.className)}\n    >\n      <StepperStylesProvider value={styles}>\n        {stepElements.map((child, index) => (\n          <StepContextProvider\n            key={index}\n            value={{\n              index,\n              status: getStatus(index),\n              orientation,\n              showLastSeparator,\n              count: stepCount,\n              isFirst: index === 0,\n              isLast: index === stepCount - 1,\n            }}\n          >\n            {child}\n          </StepContextProvider>\n        ))}\n      </StepperStylesProvider>\n    </chakra.div>\n  )\n})\n"],"mappings":";;;;;;;AAAA,SAAS,UAAU;AACnB;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AAgEf;AAnCH,IAAM,UAAU,WAAgC,SAASA,SAC9D,OACA,KACA;AACA,QAAM,SAAS,oBAAoB,WAAW,KAAK;AAEnD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,oBAAoB;AAAA,IACpB,GAAG;AAAA,EACL,IAAI,iBAAiB,KAAK;AAE1B,QAAM,eAAe,SAAS,QAAQ,QAAQ;AAE9C,QAAM,YAAY,aAAa;AAE/B,WAAS,UAAU,MAA8B;AAC/C,QAAI,OAAO;AAAO,aAAO;AACzB,QAAI,OAAO;AAAO,aAAO;AACzB,WAAO;AAAA,EACT;AAEA,SACE;AAAA,IAAC,OAAO;AAAA,IAAP;AAAA,MACC;AAAA,MACA,cAAW;AAAA,MACX,oBAAkB;AAAA,MACjB,GAAG;AAAA,MACJ,OAAO,OAAO;AAAA,MACd,WAAW,GAAG,kBAAkB,MAAM,SAAS;AAAA,MAE/C,8BAAC,yBAAsB,OAAO,QAC3B,uBAAa,IAAI,CAAC,OAAOC,WACxB;AAAA,QAAC;AAAA;AAAA,UAEC,OAAO;AAAA,YACL,OAAAA;AAAA,YACA,QAAQ,UAAUA,MAAK;AAAA,YACvB;AAAA,YACA;AAAA,YACA,OAAO;AAAA,YACP,SAASA,WAAU;AAAA,YACnB,QAAQA,WAAU,YAAY;AAAA,UAChC;AAAA,UAEC;AAAA;AAAA,QAXIA;AAAA,MAYP,CACD,GACH;AAAA;AAAA,EACF;AAEJ,CAAC;","names":["Stepper","index"]}