{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "step-tracker",
  "type": "registry:item",
  "title": "Step Tracker",
  "description": "Progress through a multi-step flow: the line fills on a spring, steps take a check and the new one sends a ring.",
  "categories": [
    "feedback"
  ],
  "dependencies": [
    "react-native-reanimated",
    "react-native-worklets"
  ],
  "registryDependencies": [
    "https://kinetik-ui.dev/r/kinetik-tokens.json",
    "https://kinetik-ui.dev/r/kinetik-motion.json"
  ],
  "files": [
    {
      "path": "src/components/kinetik/step-tracker.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/step-tracker.tsx",
      "content": "import { useEffect, useState } from 'react';\nimport { Pressable, StyleSheet, Text, View, type StyleProp, type ViewStyle } from 'react-native';\nimport Animated, {\n  interpolateColor,\n  useAnimatedStyle,\n  useSharedValue,\n  withDelay,\n  withSequence,\n  withSpring,\n  withTiming,\n} from 'react-native-reanimated';\n\nimport { useReduceMotion } from '../../lib/kinetik/hooks/use-reduce-motion';\nimport { durations, easings, spring } from '../../lib/kinetik/motion/motion';\nimport { useKinetikTheme } from '../../lib/kinetik/tokens/theme';\n\nexport type StepTrackerProps = {\n  /** One short label per step, e.g. ['Cart', 'Address', 'Payment', 'Review']. */\n  steps: readonly string[];\n  /** Index of the current step. `steps.length` means every step is done. */\n  current: number;\n  /** Lets people go back to a finished step. Only finished steps respond. */\n  onStepPress?: (index: number) => void;\n  testID?: string;\n  style?: StyleProp<ViewStyle>;\n};\n\nconst NODE = 28;\nconst LINE = 2;\n\n/**\n * Progress through a multi-step flow. The line fills toward the next step on\n * a spring, finished steps fill and take a check as the line reaches them,\n * and the step you arrive at sends out one soft ring.\n */\nexport function StepTracker({ steps, current, onStepPress, testID, style }: StepTrackerProps) {\n  const { colors } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const [width, setWidth] = useState(0);\n  const count = steps.length;\n  const clamped = Math.max(0, Math.min(count, current));\n\n  const p = useSharedValue(Math.min(clamped, count - 1));\n  useEffect(() => {\n    p.set(withSpring(Math.min(clamped, count - 1), spring('smooth', reduced)));\n  }, [clamped, count, reduced, p]);\n\n  const column = count > 0 ? width / count : 0;\n  const span = Math.max(0, width - column);\n  const fill = useAnimatedStyle(() => ({\n    width: count > 1 ? (span * p.get()) / (count - 1) : 0,\n  }));\n\n  return (\n    <View testID={testID} style={style} onLayout={(e) => setWidth(e.nativeEvent.layout.width)}>\n      <View\n        style={[\n          styles.track,\n          { left: column / 2, right: column / 2, backgroundColor: colors.track },\n        ]}\n      />\n      <Animated.View\n        style={[styles.track, { left: column / 2, backgroundColor: colors.azure }, fill]}\n      />\n      <View style={styles.row}>\n        {steps.map((label, i) => (\n          <Step\n            key={`${i}-${label}`}\n            index={i}\n            count={count}\n            label={label}\n            state={i < clamped ? 'done' : i === clamped ? 'current' : 'upcoming'}\n            reduced={reduced}\n            onPress={onStepPress && i < clamped ? () => onStepPress(i) : undefined}\n          />\n        ))}\n      </View>\n    </View>\n  );\n}\n\ntype StepState = 'done' | 'current' | 'upcoming';\n\ntype StepProps = {\n  index: number;\n  count: number;\n  label: string;\n  state: StepState;\n  reduced: boolean;\n  onPress?: () => void;\n};\n\nfunction Step({ index, count, label, state, reduced, onPress }: StepProps) {\n  const { colors, font } = useKinetikTheme();\n  const done = useSharedValue(state === 'done' ? 1 : 0);\n  const active = useSharedValue(state === 'current' ? 1 : 0);\n  const halo = useSharedValue(0);\n\n  useEffect(() => {\n    // Wait for the line to arrive before a step changes, so the eye follows the fill.\n    const wait = reduced ? 0 : durations.quick;\n    done.set(withDelay(wait, withSpring(state === 'done' ? 1 : 0, spring('bouncy', reduced))));\n    active.set(withDelay(wait, withSpring(state === 'current' ? 1 : 0, spring('smooth', reduced))));\n    if (state === 'current' && !reduced) {\n      halo.set(\n        withDelay(\n          wait,\n          withSequence(\n            withTiming(0, { duration: 0 }),\n            withTiming(1, { duration: durations.slow * 1.5, easing: easings.standard }),\n          ),\n        ),\n      );\n    }\n  }, [state, reduced, done, active, halo]);\n\n  const node = useAnimatedStyle(() => ({\n    backgroundColor: interpolateColor(done.get(), [0, 1], [colors.surface, colors.azure]),\n    borderColor: interpolateColor(\n      Math.max(done.get(), active.get()),\n      [0, 1],\n      [colors.borderStrong, colors.azure],\n    ),\n    transform: [{ scale: 1 + Math.sin(Math.min(1, Math.max(0, done.get())) * Math.PI) * 0.12 }],\n  }));\n  const ring = useAnimatedStyle(() => ({\n    opacity: halo.get() > 0 && halo.get() < 1 ? (1 - halo.get()) * 0.5 : 0,\n    transform: [{ scale: 1 + halo.get() * 0.9 }],\n  }));\n  const dot = useAnimatedStyle(() => ({\n    opacity: active.get() * (1 - done.get()),\n    transform: [{ scale: active.get() }],\n  }));\n  const check = useAnimatedStyle(() => ({\n    opacity: done.get(),\n    transform: [{ rotate: '45deg' }, { scale: 0.5 + Math.max(0, done.get()) * 0.5 }],\n  }));\n  const number = useAnimatedStyle(() => ({ opacity: 1 - Math.max(done.get(), active.get()) }));\n\n  const status = state === 'done' ? 'done' : state === 'current' ? 'current step' : 'not started';\n\n  return (\n    <Pressable\n      disabled={!onPress}\n      onPress={onPress}\n      accessibilityRole={onPress ? 'button' : 'text'}\n      accessibilityLabel={`${label}, step ${index + 1} of ${count}, ${status}`}\n      accessibilityHint={onPress ? 'Goes back to this step' : undefined}\n      style={styles.step}\n    >\n      <View style={styles.nodeBox}>\n        <Animated.View style={[styles.halo, { backgroundColor: colors.azure }, ring]} />\n        <Animated.View style={[styles.node, node]}>\n          <Animated.Text\n            style={[\n              styles.number,\n              { color: colors.textMuted, fontSize: font.size.xs, fontWeight: font.weight.semibold },\n              number,\n            ]}\n          >\n            {index + 1}\n          </Animated.Text>\n          <Animated.View style={[styles.dot, { backgroundColor: colors.azure }, dot]} />\n          <Animated.View style={[styles.check, { borderColor: colors.onAzure }, check]} />\n        </Animated.View>\n      </View>\n      <Text\n        numberOfLines={2}\n        style={[\n          styles.label,\n          {\n            color: { done: colors.textMuted, current: colors.text, upcoming: colors.textSubtle }[\n              state\n            ],\n            fontSize: font.size.xs,\n            fontWeight: state === 'current' ? font.weight.semibold : font.weight.medium,\n          },\n        ]}\n      >\n        {label}\n      </Text>\n    </Pressable>\n  );\n}\n\nconst styles = StyleSheet.create({\n  track: { position: 'absolute', top: NODE / 2 - LINE / 2 + 8, height: LINE, borderRadius: LINE },\n  row: { flexDirection: 'row' },\n  step: { flex: 1, alignItems: 'center', gap: 8, paddingTop: 8, minHeight: 44 },\n  nodeBox: { width: NODE, height: NODE, alignItems: 'center', justifyContent: 'center' },\n  halo: { position: 'absolute', width: NODE, height: NODE, borderRadius: NODE / 2 },\n  node: {\n    width: NODE,\n    height: NODE,\n    borderRadius: NODE / 2,\n    borderWidth: 2,\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n  number: { position: 'absolute' },\n  dot: { position: 'absolute', width: 10, height: 10, borderRadius: 5 },\n  check: {\n    position: 'absolute',\n    width: 6,\n    height: 11,\n    marginTop: -3,\n    borderBottomWidth: 2,\n    borderRightWidth: 2,\n  },\n  label: { textAlign: 'center', paddingHorizontal: 2 },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "component",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "feedback",
    "web": "live",
    "perf": {
      "budget": "Plain views: one shared value for the line and three per step, changed only when the step changes. Nothing runs at rest.",
      "measurements": [
        {
          "device": "Pixel 9 emulator, API 35",
          "kind": "emulator",
          "date": "2026-10-13",
          "build": "release",
          "frameMs": 17,
          "p90Ms": 18,
          "baselineMs": 20,
          "jankyPercent": 3.43,
          "atRest": "idle",
          "memoryMb": 146
        }
      ]
    },
    "a11y": {
      "reducedMotion": "The line, the checks and the current step change at once, without the ring.",
      "screenReader": "Each step reads its label, its place and its status (\"Payment, step 3 of 4, current step\"). Finished steps are buttons when onStepPress is set.",
      "touchTarget": "Each step's column is the target, at least 44 pt tall and a share of the width."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { StepTracker } from '@/components/kinetik/step-tracker';\n\n<StepTracker\n  steps={['Cart', 'Address', 'Payment', 'Review']}\n  current={step}\n  onStepPress={setStep}\n/>;\n```\n\n`current` is the index of the step in progress. Set it to `steps.length` when the flow is finished and every step shows a check.\n\n## When to use\n\n- Checkout, sign-up and setup flows with three to five steps.\n- Any flow where knowing how much is left keeps people going.\n\n## When not to use\n\n- More than five steps, or long labels. Show \"Step 3 of 8\" with a progress bar instead.\n- Flows whose steps can be done in any order. Use a checklist.\n\n## Notes\n\n- Steps share the width equally, so keep labels to a word or two.\n- With `onStepPress`, finished steps become buttons that go back. Steps ahead never respond.\n- A step changes a moment after the line starts to move, so the eye follows the fill to it.\n- With reduced motion everything changes at once.\n"
  },
  "docs": "Prefer `npx kinetik-ui add step-tracker`: it installs dependencies with expo install, so versions match your Expo SDK."
}
