{"version":3,"sources":["../src/lib/components/Stepper.tsx","../src/lib/context/index.tsx","../src/lib/components/Step.tsx"],"sourcesContent":["import React from 'react';\nimport StepperContext from '../context';\nimport { useStepper } from '../hooks/useStepper';\nimport { useIsomorphicId } from '../hooks/useId';\nimport type { PolymorphicComponentType, StepperOrientation } from '../types';\nimport type { StepComponentProps } from './Step';\n\nexport type StepperComponentProps = React.PropsWithChildren<\n  React.HTMLAttributes<HTMLElement> & {\n    currentStep?: number;\n    orientation?: StepperOrientation;\n    as?: PolymorphicComponentType;\n  }\n>;\n\nconst Stepper = React.forwardRef<HTMLDivElement, StepperComponentProps>(\n  (\n    {\n      currentStep = 0,\n      orientation = 'horizontal',\n      children,\n      className,\n      as,\n      ...rest\n    },\n    ref\n  ) => {\n    const AsComponent = as || 'nav';\n    const id = useIsomorphicId();\n    const stepsAsChildren = React.Children.toArray(\n      children\n    ) as React.ReactElement<StepComponentProps>[];\n\n    /** Values passed to the context. */\n    const stepperHookValues = React.useMemo(() => {\n      return {\n        currentStep,\n        orientation,\n        steps: stepsAsChildren.map((step) => step.props),\n      };\n    }, [currentStep, orientation, stepsAsChildren]);\n\n    /** Use the hook to build the entire logic of navigation. */\n    const stepperHook = useStepper(stepperHookValues);\n\n    /** Content props used to make the glue between each step with the content. */\n    const contentProps = React.useMemo(\n      () => ({\n        role: 'tabpanel',\n        id: `step-content-${id}-${\n          stepperHook.stepsProps[stepperHook?.state?.currentStep]?.id\n        }`,\n        'aria-labelledby': `step-label-${id}-${\n          stepperHook.stepsProps[stepperHook?.state?.currentStep]?.id\n        }`,\n        'aria-expanded': true,\n      }),\n      [id, stepperHook.state.currentStep, stepperHook.stepsProps]\n    ) as React.HTMLAttributes<HTMLElement>;\n\n    /** Step items to display. */\n    const items = stepsAsChildren.reduce<React.ReactElement[]>(\n      (acc, step, index) => {\n        const isDisabled = step.props.disabled;\n        acc.push(\n          React.cloneElement(step, {\n            disabled: isDisabled,\n            'aria-controls': `step-content-${id}-${\n              stepperHook?.stepsProps[stepperHook?.state?.currentStep]?.id\n            }`,\n            ...stepperHook?.stepsProps[index],\n          })\n        );\n        return acc;\n      },\n      []\n    );\n\n    const stepContent =\n      stepsAsChildren[stepperHook?.state?.currentStep]?.props?.children;\n\n    /** Return the Context and the steps list. */\n    return (\n      <StepperContext.Provider value={stepperHook}>\n        <AsComponent ref={ref} id={id} {...stepperHook.stepperProps} {...rest}>\n          {items}\n        </AsComponent>\n        <div {...contentProps}>{stepContent}</div>\n      </StepperContext.Provider>\n    );\n  }\n);\n\nStepper.displayName = 'Stepper.Root';\n\nexport { Stepper };\n","import React from 'react';\nimport type { UseStepper } from '../hooks/useStepper';\n\n/**\n * Context for the stepper.\n */\nconst StepperContext = React.createContext<UseStepper | null>(null);\n\nStepperContext.displayName = 'StepperContext';\n\nexport default StepperContext;\n","import React from 'react';\nimport type { PolymorphicComponentType, Steps } from '../types';\n\nexport type StepComponentProps = React.PropsWithChildren<\n  React.HTMLAttributes<HTMLElement> &\n    Steps & {\n      as?: PolymorphicComponentType;\n    }\n>;\n\nexport const Step = React.forwardRef<HTMLDivElement, StepComponentProps>(\n  (props, ref) => {\n    const { label, disabled, style, as, ...rest } = props;\n    const AsComponent = as || 'button';\n\n    return (\n      <AsComponent\n        ref={ref}\n        style={{\n          pointerEvents: disabled ? 'none' : 'auto',\n          opacity: disabled ? 0.5 : 1,\n          ...style,\n        }}\n        {...rest}\n      >\n        {label}\n      </AsComponent>\n    );\n  }\n);\n\nStep.displayName = 'Stepper.Step';\n"],"mappings":";;;;;;AAAA,OAAOA,YAAW;;;ACAlB,OAAO,WAAW;AAMlB,IAAM,iBAAiB,MAAM,cAAiC,IAAI;AAElE,eAAe,cAAc;AAE7B,IAAO,kBAAQ;;;ADyET,SACE,KADF;AApEN,IAAM,UAAUC,OAAM;AAAA,EACpB,CACE;AAAA,IACE,cAAc;AAAA,IACd,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;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