npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@valantify/steps

v0.0.7

Published

Configurator step logic for multi-step product configuration flows.

Downloads

402

Readme

@valantify/steps

Configurator step logic for multi-step product configuration flows.

What it does

This package manages the logic for product configurators where users make selections across multiple steps (e.g., color → design → accessories). It handles:

  • Conditional visibility: Steps appear/hide based on prior selections
  • Cascading selections: Changing one step auto-updates dependent steps
  • Variation matching: Maps feature combinations to actual product variations

Core concepts

Variation

A valid feature combination from your product catalog metadata (product.json + variant.json):

{
  folder: "./jetgate/gray-mesh-electric/",
  features: { color: "gray", design: "mesh", meshAccessory: "electric" }
}

Step

A configuration stage with selectable options:

{
  type: "color",           // "color" | "image" | "text"
  title: "Choose color",
  options: [
    { color: "#A51717", features: { color: "red" } },
    { color: "#818181", features: { color: "gray" } }
  ]
}

VisibleStep

A computed step showing what's currently available:

{
  step: { /* original step */ },
  stepIndex: 0,
  availableOptions: [ /* options valid given prior selections */ ],
  selectedOption: { /* currently selected option or null */ }
}

API

Finding variations

// Get features for the currently displayed variation
getCurrentFeatures(variations, "./jetgate/gray-linear/")
// → { color: "gray", design: "linear" }

// Find exact variation match
findVariation(variations, { color: "gray", design: "linear" })
// → Variation | null

// Find closest match (useful when exact match doesn't exist)
findClosestVariation(variations, { color: "gray" })
// → Variation with most matching features

Computing step visibility

// Get visible steps and their available options
const visibleSteps = getVisibleSteps(steps, currentFeatures, variations);
// → VisibleStep[]
// Only includes steps with 2+ available options
// Auto-selects first available if current selection is invalid

Handling user selections

// Resolve full state after user picks an option
const result = resolveSelection(
  steps,
  variations,
  currentFeatures,
  changedStepIndex,      // which step changed
  newOptionFeatures       // features from the new option
);
// → { features, variation, visibleSteps }
// Cascades through subsequent steps, auto-fixing invalid selections

Example flow

const variations = [
  { folder: "./shoe/red-linear/", features: { color: "red", design: "linear" } },
  { folder: "./shoe/red-mesh-electric/", features: { color: "red", design: "mesh", meshAccessory: "electric" } },
  // ... more variations
];

const steps = [
  {
    type: "color",
    title: "Choose color",
    options: [
      { color: "#A51717", features: { color: "red" } },
      { color: "#818181", features: { color: "gray" } }
    ]
  },
  {
    type: "image",
    title: "Choose design",
    options: [
      { image: "./mesh.webp", features: { design: "mesh" } },
      { image: "./linear.webp", features: { design: "linear" } }
    ]
  },
  {
    type: "image",
    title: "Mesh accessory",  // Only visible if design=mesh
    options: [
      { image: "./electric.webp", features: { meshAccessory: "electric" } },
      { image: "./wire.webp", features: { meshAccessory: "wire" } }
    ]
  }
];

// Initial state
let visibleSteps = getVisibleSteps(steps, {}, variations);
// Shows: Color step (red, gray)

// User picks red
const result = resolveSelection(steps, variations, {}, 0, { color: "red" });
// Shows: Color step (red selected), Design step (mesh, linear)

// User picks mesh design
const result2 = resolveSelection(steps, variations, result.features, 1, { design: "mesh" });
// Shows: Color, Design, Mesh accessory (electric, wire now visible)

Key behaviors

  • Auto-selection: If current selection becomes invalid, automatically picks first available option
  • Auto-hiding: Steps with 0-1 options are hidden (no choice to make)
  • Feature locking: Each step locks features for subsequent steps in order
  • Cascade updates: Changing a step revalidates all subsequent steps

Development

yarn typecheck    # Type check
yarn test         # Run tests
yarn test:watch   # Watch mode

Integration

Used by configurator UIs to:

  1. Render only visible steps
  2. Show available options per step
  3. Handle option clicks and update state
  4. Display the matching variation's images

See test file for detailed examples.