'use client';
import {Check} from 'lucide-react';
import React from 'react';
import {composeRenderProps} from 'react-aria-components/composeRenderProps';
import {
Wizard as AriaWizard,
WizardPanel as AriaWizardPanel,
type WizardPanelProps,
WizardPanels as AriaWizardPanels,
type WizardPanelsProps,
type WizardProps,
WizardStep as AriaWizardStep,
WizardStepList as AriaWizardStepList,
type WizardStepListProps,
type WizardStepProps
} from 'react-aria-components/Wizard';
import {tv} from 'tailwind-variants';
import {Button} from './Button';
import {composeTailwindRenderProps, focusRing} from './utils';
export function Wizard(props: WizardProps) {
return (
);
}
export function WizardStepList(props: WizardStepListProps) {
return (
);
}
const stepStyles = tv({
base: [
// The marker sits between two connector lines, with the label below.
'group/wizard-step grid flex-1 grid-cols-[1fr_auto_1fr] items-center gap-2 text-center text-neutral-800 dark:text-neutral-200 cursor-default outline-0 [-webkit-tap-highlight-color:transparent] selected:font-semibold',
'disabled:text-neutral-600 dark:disabled:text-neutral-400 forced-colors:disabled:text-[GrayText] hover:text-neutral-950 dark:hover:text-white',
// Each step draws its half of the line to each neighbor, so the lines connect the markers even when steps have different widths.
'before:col-start-1 before:row-start-1 before:border-t before:border-neutral-400 forced-colors:before:border-[ButtonBorder] first:before:hidden',
'after:col-start-3 after:row-start-1 after:border-t after:border-neutral-400 forced-colors:after:border-[ButtonBorder] last:after:hidden',
// Highlight the line between two steps that are both selected or completed.
'[:is([data-selected],[data-completed])+&:is([data-selected],[data-completed])]:before:border-blue-600 forced-colors:[:is([data-selected],[data-completed])+&:is([data-selected],[data-completed])]:before:border-[Highlight]',
'[&:is([data-selected],[data-completed]):has(+:is([data-selected],[data-completed]))]:after:border-blue-600 forced-colors:[&:is([data-selected],[data-completed]):has(+:is([data-selected],[data-completed]))]:after:border-[Highlight]'
].join(' ')
});
const markerStyles = tv({
extend: focusRing,
base: 'col-start-2 row-start-1 flex items-center justify-center size-6 box-border rounded-full border text-xs',
variants: {
isUpcoming: {
true: 'border-neutral-500 dark:border-neutral-400',
false:
'border-transparent bg-blue-600 text-white forced-color-adjust-none forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]'
}
}
});
export function WizardStep(props: WizardStepProps) {
return (
{composeRenderProps(
props.children,
(children, {isSelected, isCompleted, isFocusVisible, stepNumber}) => (
<>
{/* The step already announces whether it is completed, so the marker is hidden. */}
{isCompleted ? : stepNumber}
{children}
>
)
)}
);
}
export function WizardPanels(props: WizardPanelsProps) {
return ;
}
const panelStyles = tv({
extend: focusRing,
base: 'box-border p-4 text-sm text-neutral-900 dark:text-neutral-100'
});
export function WizardPanel(props: WizardPanelProps) {
return (
panelStyles({...renderProps, className})
)}
/>
);
}
// Back and Next buttons that move between steps, skipping disabled steps. They can render anywhere
// inside the , and are disabled when there is no previous or next step.
export function WizardButtons() {
return (